Untuk membuat Google Grup, panggil
groups.create() dengan
instance grup baru. Instance grup harus menyertakan groupKey,
Parent, dan label yang ditetapkan ke cloudidentity.googleapis.com/groups.discussion_forum.
Anda juga perlu menetapkan parameter initialGroupConfig, yang menentukan
pemilik awal grup. Anda dapat menggunakan nilai berikut untuk parameter
ini:
WITH_INITIAL_OWNER: Membuat orang yang mengirim permintaan menjadi pemilik
grup. Dalam sebagian besar kasus, Anda harus menggunakan nilai ini.
EMPTY: Membuat grup tanpa pemilik awal. Anda hanya dapat menggunakan nilai ini
jika Anda adalah Admin Super Google Workspace atau Admin Grup. Untuk mengetahui informasi
selengkapnya tentang peran Google Workspace, lihat Peran administrator
standar.
Python
Contoh berikut menunjukkan fungsi bantuan untuk membuat Google Grup menggunakan
library klien Python:
defcreate_google_group(service,customer_id,group_id,group_display_name,group_description):group_key={"id":group_id}group={"parent":"customers/"+customer_id,"description":group_description,"displayName":group_display_name,"groupKey":group_key,# Set the label to specify creation of a Google Group."labels":{"cloudidentity.googleapis.com/groups.discussion_forum":""}}try:request=service.groups().create(body=group)request.uri+="&initialGroupConfig=WITH_INITIAL_OWNER"response=request.execute()print(response)exceptExceptionase:print(e)
Menelusuri Google Grup
REST
Untuk menelusuri Grup Google, panggil
groups.search() dengan
string kueri. Untuk menelusuri semua grup, Anda hanya perlu memberikan label
cloudidentity.googleapis.com/groups.discussion_forum.
Python
Contoh berikut menunjukkan fungsi bantuan yang digunakan untuk menelusuri Grup Google menggunakan library klien Python:
fromurllib.parseimporturlencodedefsearch_google_groups(service,customer_id):search_query=urlencode({"query":"parent=='customerId/{}' && 'cloudidentity.googleapis.com/groups.discussion_forum' in labels".format(customer_id)})search_group_request=service.groups().search()param="&"+search_querysearch_group_request.uri+=paramresponse=search_group_request.execute()returnresponse
Langkah selanjutnya
Setelah grup ada, Anda dapat membuat langganan untuk grup tersebut. Untuk membuat
keanggotaan Google Grup, lihat
Mengelola keanggotaan Google Grup.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[[["\u003cp\u003eThis page details the process of creating and searching for Google Groups using the Cloud Identity Groups API, highlighting the use of REST and Python client library methods.\u003c/p\u003e\n"],["\u003cp\u003eTo create a Google Group, you must use the \u003ccode\u003egroups.create()\u003c/code\u003e method, providing a \u003ccode\u003egroupKey\u003c/code\u003e, \u003ccode\u003eParent\u003c/code\u003e, and the label \u003ccode\u003ecloudidentity.googleapis.com/groups.discussion_forum\u003c/code\u003e, as well as defining an initial owner via the \u003ccode\u003einitialGroupConfig\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eSearching for Google Groups involves calling the \u003ccode\u003egroups.search()\u003c/code\u003e method with a query string that includes the \u003ccode\u003ecloudidentity.googleapis.com/groups.discussion_forum\u003c/code\u003e label, and optionally a parent customer ID to filter results.\u003c/p\u003e\n"],["\u003cp\u003eBefore utilizing the Cloud Identity APIs, including the Groups API, it's crucial to complete the necessary setup steps as outlined in the "Setting up Cloud Identity" guide and the "Set up the Groups API" guide.\u003c/p\u003e\n"],["\u003cp\u003eThe customer ID format for these methods requires prepending a 'C' to the ID that is found in the Google Admin console.\u003c/p\u003e\n"]]],[],null,["# Creating and searching for Google Groups\n========================================\n\nThis page explains how to perform some fundamental operations with the\nCloud Identity Groups API.\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- [Set up the Groups API](/identity/docs/how-to/setup).\n\n| **Note:** When a method requires the `customer_id`, you must prepend a \"C\" to the ID that you can view in the Google Admin console (for example, 'C046psxkn').\n\nCreating a Google Group\n-----------------------\n\n### REST\n\nTo create a Google Group, call\n[`groups.create()`](/identity/docs/reference/rest/v1/groups/create) with\nan instance of the new group. The group instance must include a `groupKey`,\n`Parent`, and `label` set to `cloudidentity.googleapis.com/groups.discussion_forum`.\n\nYou also need to set the `initialGroupConfig` parameter, which defines the\ninitial owner of the group. You can use the following values for this\nparameter:\n\n- `WITH_INITIAL_OWNER`: Makes the person sending the request the owner of the group. You should use this value in most cases.\n- `EMPTY`: Creates a group with no initial owners. You can only use this value if you're a Google Workspace Super Admin or Groups Admin. For more information about Google Workspace roles, see [Pre-built administrator\n roles](https://support.google.com/a/answer/2405986).\n\n### Python\n\nThe following example shows a helper function to create a Google Group using\nthe Python client library: \n\n def create_google_group(service, customer_id, group_id, group_display_name, group_description):\n group_key = {\"id\": group_id}\n group = {\n \"parent\": \"customers/\" + customer_id,\n \"description\": group_description,\n \"displayName\": group_display_name,\n \"groupKey\": group_key,\n # Set the label to specify creation of a Google Group.\n \"labels\": {\n \"cloudidentity.googleapis.com/groups.discussion_forum\": \"\"\n }\n }\n\n try:\n request = service.groups().create(body=group)\n request.uri += \"&initialGroupConfig=WITH_INITIAL_OWNER\"\n response = request.execute()\n print(response)\n except Exception as e:\n print(e)\n\nSearching for a Google Group\n----------------------------\n\n### REST\n\nTo search for a Google Group, call\n[`groups.search()`](/identity/docs/reference/rest/v1/groups/search) with\na query string. To search for all groups, you only need to provide the label\n`cloudidentity.googleapis.com/groups.discussion_forum`.\n\n### Python\n\nThe following example shows a helper function used to search for a Google\nGroup using the Python client library: \n\n from urllib.parse import urlencode\n\n def search_google_groups(service, customer_id):\n search_query = urlencode({\n \"query\": \"parent=='customerId/{}' && 'cloudidentity.googleapis.com/groups.discussion_forum' in labels\".format(customer_id)\n })\n search_group_request = service.groups().search()\n param = \"&\" + search_query\n search_group_request.uri += param\n response = search_group_request.execute()\n\n return response\n\nWhat's next\n-----------\n\n- After a group exists, you can create memberships for it. To create\n memberships for a Google Group, refer to\n [Managing memberships for Google Groups](/identity/docs/how-to/memberships-google-groups).\n\n- You can [update a Google Group to a security group](/identity/docs/how-to/update-group-to-security-group)."]]