Travis Walter
Travis Walter

Reputation: 11

How do I "includeDerivedMembership" on the members.get() call with Google Directory API?

I am currently working on a Human Resources program in Python that can do specific tasks related to managing users in a Google Workspace. I am trying to automate the process of adding and removing users for Google groups with the Google Directory API. To add a member to a group I know I have to have a member object in the request body, as shown here: https://developers.google.com/admin-sdk/directory/reference/rest/v1/members/insert, but I do not want to have to manually create these member objects. My thought was to use the members.get method to search for the user in a group that contains every member of the organization and return their specific member object.

However, the way that we have the full team group set up is with the "All users in the organization" utility (provided by Google Workspace) as a member of the group. This allows the group's members to fluctuate automatically so I am not planning on changing this.

After a little exploring, I found the "includeDerivedMembership" parameter for the members.list method that, when set to true, allowed the API to return the whole list of users in the organization. When not set it would not return the full list!

My question is, has anyone figured out a way to "includeDerivedMembership" with the members.get method. I've tried attaching the parameter to the API query for members.get but no joy.

I REALLY don't want to traverse the huge array of member objects returned by the members.list method, but if there is no better way then I will :L

Thanks in advance,

Travis W

Upvotes: 1

Views: 319

Answers (1)

ziganotschka
ziganotschka

Reputation: 26836

The method members.get returns you a member resource object with the following information:

{
  "kind": string,
  "email": string,
  "role": string,
  "etag": string,
  "type": string,
  "status": string,
  "delivery_settings": string,
  "id": string
}

So as you can see, unfortunately it is not possible to retrieve the DerivedMembership status through this method.

As a workaround, you might want to call the members.list method twice - once with includeDerivedMembership set to true and once to false. The overlap of the two results arrays will allow you to establish which members are direct and not derived.

Upvotes: 0

Related Questions