동적 그룹을 만들려면 그룹의 인스턴스로 groups.create()를 호출합니다. 그룹의 인스턴스에는 그룹을 채우는 데 사용되는 쿼리와 함께 dynamicGroupMetadata가 포함되어야 합니다.
Python
동적 그룹을 만들려면 그룹의 인스턴스로 service.groups().create 메서드를 호출합니다. 그룹의 인스턴스에는 그룹을 채우는 데 사용되는 쿼리와 함께 dynamicGroupMetadata가 포함되어야 합니다. 다음 샘플은 엔지니어링 부서의 기존 사용자가 모두 포함된 동적 그룹을 만드는 방법을 보여줍니다.
동적 그룹을 업데이트하려면 그룹의 인스턴스로 groups.patch()를 호출합니다. 그룹의 인스턴스에는 그룹을 채우는 데 사용되는 새 쿼리와 함께 dynamicGroupMetadata가 포함되어야 합니다.
Python
동적 그룹을 업데이트하려면 업데이트할 그룹의 이름과 그룹의 인스턴스로 service.groups().patch 메서드를 호출합니다. 그룹의 인스턴스에는 그룹을 채우는 데 사용되는 쿼리와 함께 dynamicGroupMetadata가 포함되어야 합니다. 다음 샘플은 엔지니어링의 모든 사용자를 포함하는 동적 그룹을 엔지니어링 또는 재무 부서의 모든 사용자가 포함된 그룹으로 업데이트하는 방법을 보여줍니다.
# name (i.e. groups/01234abcdeef) uniquely identifies the groupdefupdate_dynamic_group(name,query):service=build_service()groupDef={"dynamicGroupMetadata":{"queries":[{"resourceType":"USER","query":"user.organizations.exists(org, org.department=='engineering' || org.department=='finance')"}]}}request=service.groups().patch(name=name,body=groupDef)request.uri+="&updateMask=dynamicGroupMetadata"response=request.execute()returnresponse
다음 단계
동적 그룹이 존재하면 이를 검색하고 멤버십을 나열할 수 있습니다.
자세한 내용은 동적 그룹 검색 및 구성원 나열을 참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eDynamic groups are available to specific Google Workspace and Cloud Identity premium accounts, with a limit of 500 per customer, which can be increased by contacting Google Workspace Support.\u003c/p\u003e\n"],["\u003cp\u003eCreating a dynamic group involves calling the \u003ccode\u003egroups.create()\u003c/code\u003e method (REST) or \u003ccode\u003eservice.groups().create\u003c/code\u003e (Python), ensuring the \u003ccode\u003edynamicGroupMetadata\u003c/code\u003e contains the query to populate the group.\u003c/p\u003e\n"],["\u003cp\u003eUpdating a dynamic group requires using \u003ccode\u003egroups.patch()\u003c/code\u003e (REST) or \u003ccode\u003eservice.groups().patch\u003c/code\u003e (Python), and includes modifying the \u003ccode\u003edynamicGroupMetadata\u003c/code\u003e with a new query.\u003c/p\u003e\n"],["\u003cp\u003eBefore creating or updating dynamic groups, users must set up Cloud Identity and familiarize themselves with the Groups API, dynamic groups overview, and set up the Groups API.\u003c/p\u003e\n"]]],[],null,["# Creating and updating a dynamic group\n=====================================\n\nThis page explains how to create and update a dynamic group.\n| **Note:** Dynamic groups are only available to Google Workspace Enterprise Standard, Enterprise Plus, Enterprise for Education, and Cloud Identity premium accounts. You can create up to 500 dynamic groups per customer. This limit can be increased on a case-by-case basis---contact [Google Workspace Support](https://support.google.com/a/answer/1047213) with your specific use case to request an increase.wss\n\nBefore you begin\n----------------\n\n| **Note:** Before you use any of the Cloud Identity APIs, you must set up Cloud Identity. See [Setting up Cloud Identity](/identity/docs/set-up-cloud-identity-admin) for instructions.\n\nPerform the following tasks before proceeding with the information on this page:\n\n- Read the [Groups API overview](/identity/docs/groups).\n\n- Read the [dynamic groups overview](/identity/docs/concepts/overview-dynamic-groups).\n\n- [Set up the Groups API](/identity/docs/how-to/setup).\n\n- (Optional) [Formulate and test a membership query](/identity/docs/how-to/test-query-dynamic-groups).\n\nCreating a dynamic group\n------------------------\n\nThe following is an example of creating a dynamic group: \n\n### REST\n\n\nTo create a dynamic group, call\n[`groups.create()`](/identity/docs/reference/rest/v1/groups/create)\nwith an instance of the group. The instance of the group must contain the\n`dynamicGroupMetadata` with the query used to populate the group.\n\n### Python\n\nTo create a dynamic group, call the `service.groups().create` method with\nan instance of the group. The instance of the group must contain the\n`dynamicGroupMetadata` with the query used to populate the group. The\nfollowing sample shows how to create a dynamic group containing all users\nexisting in the Engineering department: \n\n def create_dynamic_group(customer_id, email, query):\n service = build_service()\n groupDef = {\n \"parent\": \"customerId/{}\".format(customer_id),\n \"groupKey\": {\"id\": email},\n \"labels\": {\"cloudidentity.googleapis.com/groups.discussion_forum\": \"\"},\n \"dynamicGroupMetadata\": {\n \"queries\": [\n {\n \"resourceType\": \"USER\",\n \"query\": \"user.organizations.exists(org, org.department=='engineering')\"\n }\n ]\n }\n }\n request = service.groups().create(body=groupDef)\n request.uri += \"&initialGroupConfig=EMPTY\"\n response = request.execute()\n return response\n\nUpdating a dynamic group\n------------------------\n\nThe following is an example of updating a dynamic group: \n\n### REST\n\n\nTo update a dynamic group, call\n[`groups.patch()`](/identity/docs/reference/rest/v1/groups/patch)\nwith an instance of the group. The instance of the group must contain the\n`dynamicGroupMetadata` with the new query used to populate the group.\n\n### Python\n\nTo update a dynamic group, call the `service.groups().patch` method with\nthe name of the group to update and an instance of the group. The instance\nof the group must contain the\n`dynamicGroupMetadata` with the query used to populate the group. The\nfollowing sample shows how to update a dynamic group containing all users in\nEngineering to a group containing all users in either Engineering or Finance\ndepartments: \n\n # name (i.e. groups/01234abcdeef) uniquely identifies the group\n def update_dynamic_group(name, query):\n service = build_service()\n groupDef = {\n \"dynamicGroupMetadata\": {\n \"queries\": [\n {\n \"resourceType\": \"USER\",\n \"query\": \"user.organizations.exists(org, org.department=='engineering' || org.department=='finance')\"\n }\n ]\n }\n }\n request = service.groups().patch(name=name, body=groupDef)\n request.uri += \"&updateMask=dynamicGroupMetadata\"\n response = request.execute()\n\n return response\n\nWhat's next\n-----------\n\nAfter the dynamic group exists, you can retrieve it and list its memberships.\nFor more information, refer to\n[Retrieving a dynamic group and listing members](/identity/docs/how-to/retrieve-list-dynamic-groups)."]]