How to get only specific fields with Google Directory API users.list - google-api

The documentation (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/list#query-parameters) says you can use customFieldMask to get only specific fields. I cannot figure out the format/structure of this property.
For example, given this for a user:
{
"kind": "admin#directory#user",
"id": "...",
"etag": "\"...\"",
"primaryEmail": "...",
"name": {
"givenName": "...",
"familyName": "...",
"fullName": "......"
},
"emails": [
{
"address": "...",
"primary": true
}
]
}
I only want to get primaryEmail but I can't figure out how.

Send "users(primaryEmail)" in the fields parameter, not in the customFieldMask parameter.

The Directory API can't retrieve the 'primaryEmail' with the customFieldMask attribute, with this attribute you can only specify the custom schema names that you create in the Admin console.

Related

Drive REST API no longer returning user name for deleted comments?

We've been using the Google Drive REST v3 API to retrieve comments with the includeDeleted option.
Until sometime within just the last few days this returned the user name of the person who made the deleted comment, though the content itself was no longer available.
Now we're not getting the user name, either. Has anyone else experienced this?
API parameters:
https://www.googleapis.com/drive/v3/files/{MyFileId}/comments?includeDeleted=true&pageSize=100&fields=comments
Output for two deleted comments containing no user information:
{
"kind": "drive#comment",
"id": "AAAAC8EryOw",
"createdTime": "2019-05-08T14:47:46.931Z",
"modifiedTime": "2019-05-08T14:48:01.276Z",
"deleted": true,
"replies": []
},
{
"kind": "drive#comment",
"id": "AAAAC4otGzE",
"createdTime": "2019-05-06T09:33:32.862Z",
"modifiedTime": "2019-05-08T14:37:48.699Z",
"deleted": true,
"replies": []
},
I think you might be having an issue with the partial response of the Google Drive api v3. Try setting fields = *
https://www.googleapis.com/drive/v3/files/{MyFileId}/comments?includeDeleted=true&pageSize=100&fields=*
If that doesnt work i suspect you will need to do a comment.get which will allow you to see the full comment response for each comment.
{
"kind": "drive#comment",
"id": string,
"createdTime": datetime,
"modifiedTime": datetime,
"author": {
"kind": "drive#user",
"displayName": string,
"photoLink": string,
"me": boolean,
"permissionId": string,
"emailAddress": string
},
"htmlContent": string,
"content": string,
"deleted": boolean,
"resolved": boolean,
"quotedFileContent": {
"mimeType": string,
"value": string
},
"anchor": string,
"replies": [
replies Resource
]
}

Cannot save a very simple fhir patient bundle

I am trying to save this very simple fhir patient bundle against https://vonk.fire.ly/Bundle, by doing a PUT using Postman, however I am not able to get it working. When I simply copy the inner Patient resource data and do a PUT directly to the https://vonk.fire.ly/Patient endpoint it works just fine (for example - I just did it to this url https://vonk.fire.ly/Patient/deb7338181).
Can someone please please point me in the direction of what exactly it is going wrong here in this bundle??
{
"resourceType": "Bundle",
"id": "b6ec685a-26a2-4bb3-814b-841fba6a6edb",
"meta": {
"lastUpdated": "2018-05-29T23:45:32Z"
}
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "deb73381811",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Some narrative</div>"
},
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers1",
"given": [
"Peter1",
"James1"
]
}
],
"gender": "male",
"birthDate": "1974-12-25"
},
"request": {
"method": "POST",
"url": "Patient"
}
}
]
}
If you want to send a transaction to a FHIR server, you do a POST of the transaction Bundle to the endpoint, just like you mention in your comment. Within the transaction, for each entry you have to set the request part to the kind of request you want.
For your Patient entry you have asked the server to do a POST, which means a create with a server assigned ID. If you want the server to use your own ID, you should instruct it to perform a PUT, which is usually an update, but can also be used for create with your own ID.
The syntax for the update request is:
"request": {
"method": "PUT",
"url": "Patient/<my_patient_id>"
}
Please note that although it is a valid FHIR request and Vonk allows it, not all servers will.

Status attribute for external group membership

I have G-Suite group containing external users (from gmail.com). When I call Get all members API, until 2018-12-17 google returns status attribute for all members, but now it's empty for external users:
{
"kind": "admin#directory#member",
"etag": "",
"id": "1234",
"email": "user#internal.domain",
"role": "MEMBER",
"type": "USER",
"status": "ACTIVE"
},
{
"kind": "admin#directory#member",
"etag": "",
"id": "4321",
"email": "some+user#gmail.com",
"role": "MEMBER",
"type": "USER"
}
Documentation says nothing if status is mandatory attribute or not.
Can you please explain how to get all active members of certain group?
Maybe try using the Members: list API method instead?
Perhaps also try setting the flag for includeDerivedMembership to true (defaults to false)

Access control at property level (hiding/showing properties in api response based on the role)

I have a spring-boot based micro-service generated using JHipster.
I am using keycloak as my Auth Server. I could enable Role-based & scope based authorization on my resources(apis).
Now the requirement is: based on the role of the client, I need to restrict the information to send in the response (either mask the attributes or nullify them).
eg:
consider the following api to get the person's profile
/api/person/{id}
{
"name": {
"firstName": "Jack",
"lastName": "Sparrow"
},
"gender": "MALE",
"emails": {
"details": [
{
"emailId": "jack.sparrow#gmail.com"
}
]
},
"phones": {
"details": [
{
"phoneNumber": "1234567890",
"countryCode": "+1"
}
]
},
"addresses": {
"details": [
{
"addressLine1": "aaaaaaaa",
"addressLine2": "bbbbbbb",
"city": "cccccc",
"state": "ddddd",
"country": "South Africa",
"postalCode": "987654"
}
]
},
"photo": "string",
"nationality": "South Africa",
"countryOfResidence": "string",
"active": true,
"createdAt": 1537431339569,
"modifiedAt": 1537436600693,
"createdBy": "admin",
"modifiedBy": "admin"
}
Now, when a person with BASIC role calls this API, the requirement is to show only basic information like:
- name, gender
If he has INTERMEDIATE role then we can send something more than basic but not full information. eg: name, gender, photo, nationality
If he has ADMIN role then we can send the complete information.
Can anyone please let me know What is the best approach to achieve this.
-- Thanks in advance :)

How to edit nested data with admin on rest?

I don't know how to handle nested data with admin on rest.
My GET request returns the full object without additional calls for filters and thumbnails (see below).
Example object:
{
"id": "58bd633e4b77c718e63bf931",
"title": "Project A",
"description": "Blabla",
"image": "https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150",
"disable": false,
"filters": [
{
"id": "58c662aa4ea73e3d4373dad7",
"filterValue": {
"label": "Filter value",
"color": "#0094d8",
"id": "58c7999162700623b4aac559"
},
"isMain": true
}
],
"thumbnails": [
{
"id": "58bfeac780021c56cc71bfac",
"image": "http://lorempixel.com/1024/768/",
"description": "Bla",
"device": "desktop"
},
{
"id": "58bfeacf80021c56cc71bfad",
"image": "http://lorempixel.com/800/600/",
"description": "Bla",
"device": "laptop"
}
]
}
My first idea was to create custom Input Components but I don't know if it's the best solution? Any ideas or examples?
Admin-on-rest relies on redux-form, which supports nested attributes. Just set the source of your input as the path to the nested property, with dot separator:
<TextInput source="foo.bar" />
For your filters and thumbnails, you'll have to use redux-form's <Fields> component, and create a custom input component with it.

Resources