I'm currently writing an Add-on to manage Google Groups, and it uses the Admin SDK Directory API to loop through and retrieve all group members and make changes etc.
One curious issue I've found is that when 'All members of the domain' have been added to the group, no member email is supplied. For example, if I retrieve all members of the group, each member will be returned in the format:
{
"kind": "admin#directory#member",
"etag": "\"ABCDEFGHIJKLMNOPQRSTUV123456789\"",
"id": "123455678910",
"email": "email#myDomain.com",
"role": "MEMBER",
"type": "USER"
},
However, if you've added all users within the domain to a group, when you retrieve this 'member', it's returned in the format:
{
"kind": "admin#directory#member",
"etag": "\"ABCDEFGHIJKLMNOPQRSTUV123456789\"",
"id": "123455678910",
"role": "MEMBER",
"type": "CUSTOMER"
},
This is fine for retrieval, as I can identify that it's 'All users in the domain' by the 'type' always being 'Customer', then I just give it an arbitrary email address to display in my interface (I'm using '*#domain.com' just because).
However, when I'm updating the group members list using the 'Insert' method, it requires an email Address (It refers to 'memberkey', but I understand that this must be an email address).
It won't accept dummy addresses such as *#domain.com (It returns an error that this particular address exists, so I gues it's in use in the background), and if I use an existing address and try to overwrite the 'type' from 'User' to 'Customer' in an attempt to convert an existing member to the 'All users' value, this doesn't work (I suspect the 'type' field does not allow 'Customer' as a writable field, only a readable one).
My question: There does not seem to be a method to 'Add all users in the domain' to a group neatly, without looping through the domain and literally adding all members one by one. Does this method exist and I've just missed it? Or is there a neater way to add all members to the group without looping through all the members on the domain and adding them to the group one by one?
No API method has existed for this even back into the provisioning API days. Nothing in Group Settings is different for a group of this kind, it seems to be an unsupported Member Resource. Trying to modify existing members to become type: 'CUSTOMER' also fail.
You can, however, set a single group in the Admin Panel UI to be your "All Members" and then use the address of that group as a proxy member. i.e. it is a propagated all member feature. This is a workaround as opposed to a direct answer, but as I state above the real answer is "No".
Related
I want to create a add-on that processes all the comments added by the user in a Google Docs document. I can use Drive.Comments.list to get the list of all comments in the doc and Session.getEffectiveUser to get the identify of the user running the script.
I tried filtering by email address. However, the results of Drive.Comments.list do not include author.emailAddress. Here is an example to show that displayName is included. Here is an example that shows that emailAddress is not included. The documentation for emailAddress does say This may not be present in certain contexts if the user has not made their email address visible to the requester. However, emailAddress is not present even for comments added by the user running the script. And so filtering by email address does not work.
I then tried filtering by display name. However, Session.getEffectiveUser does not provide a way to get the display name. Is there any other way to get the display name of the user running the script?
Try about.get This returns the users email address.
{
"kind": "drive#about",
"user": {
"kind": "drive#user",
"displayName": "Linda Lawton",
"photoLink": "https://lh3.googleusercontent.com/a-/AOh14GhroCYJp2P9xeYeYk1npchBPK-zbtTxzNQo0WAHI20=s64",
"me": true,
"permissionId": ddd88225573437243",
"emailAddress": "xxxxx#gmail.com"
},
I want to bulk-load some emails in the Gsuite account using a csv file. However there's this field called "building id" which is NOT REQUIRED but is handy for my requirements; I just realized that out of the box, Gsuite cannot locate a record by the mentioned field as the search term. My question is, is there a workaround to this problem? Better yet, does Gsuite support the creation of custom fields that can be used to discover information when used as search strings? Anyone who knows a solution to this problem?
When using the Directory API to list the members, using the query parameter to get the members with a specific buildingId is not an option. The available queries that can be made are listed here.
However, you can create your own custom field using the below Directory API schemas.insert request:
POST https://admin.googleapis.com/admin/directory/v1/customer/{customerId}/schemas
With the following request body:
{
"schemaId": string,
"schemaName": string,
"fields": [
{
"displayName": "",
"fieldName": "",
"fieldType": ""
}
],
"displayName": string,
}
Afterwards, when you want to retrieve the users with a particular value, you will have to make the below request:
GET https://admin.googleapis.com/admin/directory/v1/users
With the following fields:
customFieldMask > set to the name of the schema;
projection > set to custom;
query=schemaName.FIELD='VALUE' > this will query the users who have the field from the custom field with the value 'VALUE'.
Reference
Directory API Users:list;
Directory API Schemas.insert.
I am new to spring boot and rest and hence pardon me if this question is very trivial.
I have a situation where the application allows users to register and place order.
On registration of user, the service should be able to send a response with the user information including - User Name, email, contact Number, address etc.
However, while placing orders, I would like the order response object to include within the order details, only the customer (username, email). I do not want to include the address and other information part of the User object.
Currently, what is happening is whenever, I refer to an existing user instance within the Order instance, the Order response has the complete tuple information of the registered user.
In the Order confirmation response, I really do not want the entire User information.
However, if the same Order entity is being referenced for user register, I want the service to include all fields from the Order entity.
I have tried referring to the following links -
Jackson Change JsonIgnore Dynamically
How do I exclude fields with Jackson not using annotations?
However, the solutions mentioned here will always ignore the attribute in response irrespective of the scenario in which the entity is being referenced.
For example - Response from Order service is as below.
{
"id": "ORD-1000",
"priority": null,
"status": "Open",
"customer": {
"id": "1000",
"name": "Avion Solutions",
"email": "support-na#avionsolutions.com",
"contact": null,
"customerType": "gold-sx",
"shipToContactId": null,
"billToContactId": null
},
"urgency": null
}
In the above response tuple, lets say, I just want the order information with basic customer information such as name & email.
And if the customer is registering, then the response should contain all the information as mentioned in the above tuple.
How can i dynamically ignore the attributes in response of the REST service based on the context in which the entity object is being used?
Thanks in advance.
Try to use #JsonView annotation. You can define visibility for given property and on REST Controller you can define level you want to show. For more information and examples, please, read below:
Jackson JSON Views
Jackson – Bidirectional Relationships
Using #JsonView with Spring MVC
I want to get a list of groups where i have member access and also i want to know which role I have in those Google groups.
for example, assume a user is a member of 70 groups. Through admin console I can check which role is assigned to that particular user, But its a lengthy process.
Can I list Google groups,where a user has membership access(atleast) along with the role(member,manager or owner) assigned to the user in those groups.
I would like to do it using Google App Script.
Thanks in advance
You can use the Group:list API where a userKey can be specified. It returns all the groups the user is a member of. Use the following HTTP request and include the authorization described in Authorize requests .
There's a JSON request were you can get the role of the group member, a group member's role can be (OWNER, MANAGER, MEMBER).
Here's a successful response returns an HTTP 200 status code and the member's information:
{
"kind": "directory#member",
"id": "group member's unique ID",
"email": "liz#example.com",
"role": "MEMBER",
"type": "GROUP"
}
For more information regarding Group members, click here: https://developers.google.com/admin-sdk/directory/v1/guides/manage-group-members#create_member
I send over proper json formatted code, according to v2 api docs:
lists/subscribe.json
"GROUPINGS":[{"id":removed_id,"name":"grouping_name","groups":["group_name"]}]
I get back information about a member... It does not say they are interested in that group name..
lists/member-info.json
"GROUPINGS":[{"id":removed_id,"name":"grouping_name","form_field":"hidden","groups":
[{"name":"group_name","interested":false},{"name":"other_group_name","interested":false},
{"name":"other_group_name2","interested":false},{"name":"other_group_name3","interested":false}]}]
I do not understand how I can get these users to show up as "subscribed" to a group within my grouping. I have been trying for nearly 5 hours now. I have tried:
making sure the groups: value is an [] array.
trying out making that value a string (which surprisingly did not throw errors)
capitalizing "GROUPINGS" when sending it in merge_vars
not capitalizing "groupings" when sending in merge_vars
using the lists/update-member.json method to update these groups
using the name of my interest group instead of grouping in the grouping array.
using the option replace_interests on both true and false
In conclusion,
I had to email mailchimp a support ticket. Without changing my code at all - it works this morning. Interestingly enough, mailchimp was experiencing many issues yesterday with servers being down and alleged email hackings.
To be clear about which version of my code worked - following the API exactly for v2.
It was an error on mailchimp's end.
{
"id":"MY LIST ID",
"email":{
"email":"THE EMAIL TO SUBSCRIBE"
},
"merge_vars":{
"GROUPINGS":[
{
"id":THE GROUPING ID,
"groups":[
"THE NAME OF MY GROUP"
]
}
]
},
"double_optin":false,
"replace_interests":true,
"apikey":"MY API KEY"
}
Also, in case you are curious, replace_interests is true when the groups you send are supposed to replace existing groups the subscriber is interested in. False indicates that the groups you pass should be added to the interest groups.
If you are updating a member (method: lists/update-member), it may be best to set replace_interests to false just to make sure it does not overwrite your existing interest groups (possibly with blank groups). The default value for it is true, so this could be another place prone to error.