Accessing list of groups along with user's role - google-apps-script

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

Related

How to check the identity of the person who added a Google Doc comment

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"
},

How to dynamically avoid sending response containing all properties from relationship data

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

Get Product List with more details in Magento2 API

I am working on a native application and need to get the list of product based on category.
Like when user clicks on a category I have to show list of products inside that category.
I tried a service but its only giving three field in return
http://www.dexample.com/index.php/rest/V1/categories/1680/products
response
{
"sku": "FB-Bridgewater",
"position": 1,
"category_id": "1680"
}
I need more information like name, image, price and more.
You can use the search API to fetch the more information of the Product.
This API will get you the products with details:
http://www.dexample.com/index.php/rest/V1/products?
searchCriteria[filter_groups][0][filters][0][field]=category_id&
searchCriteria[filter_groups][0][filters][0][value]=1680&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
The Generic Search API of Magento2 is
searchCriteria[filter_groups][<index>][filters][<index>][field]=<field_name>
searchCriteria[filter_groups][<index>][filters][<index>][value]=<search_value>
searchCriteria[filter_groups][<index>][filters][<index>][condition_type]=<operator>
where:
field is an attribute name.
value specifies the value to search for.
condition_type specifies condition[ex: eq , finset, like, from, to]

Get users for a given group Activiti Rest API

I'm looking for some advice on how to approach retrieving the users from a given group of the activti-app. Having read the documentation I've attempted to hit the endpoint associated with users and their groups by a posting a JSON body containing an array of user task filter ids.
Testing this in Postman returns a 500 internal server error "exception": "Request method 'POST' not supported". Obviously this is because I should be making a GET request however I cannot attach a JSON body in that case.
Aforementioned example endpoint: localhost:8080/activiti-app/api/enterprise/groups/{group_id}/users
Aforementioned docs:
https://docs.alfresco.com/activiti/docs/dev-guide/1.5.0/#_user_and_group_lists
Specifically this section Screencap of activti docs
Any suggestions would be greatly appreciated!
Thanks!
First, we have to make sure we are talking about "organization groups" not "capabilities groups". That was my original confusion. Once I create the right kind of group I could successfully use the REST API to fetch both a list of groups and a list of group members.
As the docs point out, to get a list of groups, do this:
curl -uadmin#app.activiti.com http://localhost:8080/activiti-app/api/enterprise/groups
Which returns:
{
"size":2,
"total":2,
"start":0,
"data":[
{"id":5,"name":"test-org-group-1","externalId":null,"status":"active","groups":null},
{"id":6,"name":"test-org-group-2","externalId":null,"status":"active","groups":null}
]
}
If you want to pass a filter, do it with "?filter=some-group-name".
Now, to see the members of a specific group, pass in the group ID, which is a numeric. So to see the members of test-org-group-1 I would use:
curl -uadmin#app.activiti.com http://localhost:8080/activiti-app/api/enterprise/groups/5/users
Which returns:
{
"size":2,
"total":2,
"start":0,
"data": [
{"id":2,"firstName":"Test","lastName":"User1","email":"tuser1#metaversant.com"},
{"id":3,"firstName":"Test","lastName":"User2","email":"tuser2#metaversant.com"}
]
}

Insert all domain members into Group

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".