O exemplo a seguir mostra como recuperar um grupo dinâmico por e-mail:
REST
Para recuperar um grupo dinâmico por e-mail, chame
groups.get()
com o endereço de e-mail do grupo.
Python
No exemplo a seguir, mostramos como recuperar um grupo dinâmico por e-mail usando a
biblioteca Python:
defget_dynamic_group_by_email(email):service=build_service()# First we use the email to get the groups name calling lookup()lookup_group_name_request=service.groups().lookup()param="&groupKey.id="+emaillookup_group_name_request.uri+=paramlookup_group_name_response=lookup_group_name_request.execute()name=lookup_group_name_response.get("name")# Then we can call get() by passing in the group's nameresponse=service.groups().get(name=name).execute()returnresponse
Como listar assinaturas de um grupo dinâmico
Veja na amostra a seguir como listar as assinaturas de um grupo dinâmico:
REST
Para listar as assinaturas de um grupo, chame
groups.memberships.get()
com o nome do recurso do grupo.
Python
No exemplo a seguir, veja como listar assinaturas de um grupo dinâmico usando
a biblioteca Python:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 UTC."],[[["\u003cp\u003eDynamic groups can be retrieved using either their name or email address.\u003c/p\u003e\n"],["\u003cp\u003eTo retrieve a dynamic group by name, use the \u003ccode\u003egroups.get()\u003c/code\u003e method with the group's resource name.\u003c/p\u003e\n"],["\u003cp\u003eRetrieving a dynamic group by email requires using the \u003ccode\u003egroups().lookup()\u003c/code\u003e method initially to get the group name, and subsequently calling \u003ccode\u003egroups.get()\u003c/code\u003e with the name.\u003c/p\u003e\n"],["\u003cp\u003eTo list the memberships of a dynamic group, the \u003ccode\u003egroups.memberships.get()\u003c/code\u003e method is used with the group's resource name, or \u003ccode\u003egroups().memberships().list\u003c/code\u003e in python.\u003c/p\u003e\n"],["\u003cp\u003eDynamic groups are only accessible to premium Cloud Identity accounts.\u003c/p\u003e\n"]]],[],null,["# Retrieving a dynamic group and listing members\n==============================================\n\nYou can retrieve dynamic groups by name or email. After you retrieve a group,\nyou can list its memberships.\n| **Note:** Dynamic groups are only available to Cloud Identity premium accounts.\n\nRetrieving a dynamic group by name\n----------------------------------\n\nThe following sample shows how to retrieve a dynamic group by name: \n\n### REST\n\n\nTo retrieve a dynamic group by name, call\n[`groups.get()`](/identity/docs/reference/rest/v1/groups/get) with the\nresource name of the group.\n\n### Python\n\n\nThe following example shows how to retrieve a dynamic group by name using the\npython library: \n\n def get_dynamic_group_by_name(name):\n service = build_service()\n response = service.groups().get(name=name).execute()\n return response\n\nRetrieving a dynamic group by email\n-----------------------------------\n\nThe following sample shows how to retrieve a dynamic group by email: \n\n### REST\n\n\nTo retrieve a dynamic group by email, call\n[`groups.get()`](/identity/docs/reference/rest/v1/groups/get)\nwith the group email address.\n\n### Python\n\n\nThe following example shows how to retrieve a dynamic group by email using the\npython library: \n\n def get_dynamic_group_by_email(email):\n service = build_service()\n\n # First we use the email to get the groups name calling lookup()\n lookup_group_name_request = service.groups().lookup()\n param = \"&groupKey.id=\" + email\n lookup_group_name_request.uri += param\n lookup_group_name_response = lookup_group_name_request.execute()\n name = lookup_group_name_response.get(\"name\")\n\n # Then we can call get() by passing in the group's name\n response = service.groups().get(name=name).execute()\n return response\n\nListing memberships of a dynamic group\n--------------------------------------\n\nThe following sample shows how to list the memberships of a dynamic group: \n\n### REST\n\n\nTo list memberships of a group, call\n[`groups.memberships.get()`](/identity/docs/reference/rest/v1/groups.memberships/get)\nwith the resource name of the group.\n\n### Python\n\nThe following example shows how to list memberships of a dynamic group using\nthe python library: \n\n def get_dynamic_group_memberships(name):\n service = build_service()\n\n members_request = service.groups().memberships().list(parent=name)\n members_request.uri += \"&view=FULL\"\n response = members_request.execute()\n return response"]]