POSIX_NAME : nom que vous souhaitez attribuer au groupe POSIX.
GROUP_ID: ID de groupe que vous souhaitez attribuer au groupe POSIX.
Python
L'exemple suivant montre une fonction d'assistance qui permet de mettre à jour un groupe Google vers un groupe POSIX à l'aide de la bibliothèque cliente Python :
ORGANIZATION_ID : organisation à laquelle le groupe appartient. Un ID ("123456789") ou le domaine associé ("example.com").
GROUP_ID : ID de groupe que vous avez défini pour le groupe.
POSIX_NAME : nom que vous avez défini pour le groupe.
REST
Pour créer un groupe, appelez la méthode groups.create() accompagnée de l'adresse e-mail, de l'ID de l'organisation, des groupes POSIX et des libellés du nouveau groupe.
initialGroupConfig=WITH_INITIAL_OWNER : ?initialGroupConfig=WITH_INITIAL_OWNER ou vide. Les groupes vides ne peuvent être créés que par les administrateurs de l'organisation.
L'exemple suivant montre une fonction d'assistance qui permet de mettre à jour un groupe Google vers un groupe POSIX à l'aide de la bibliothèque cliente Python :
Une fois que le groupe POSIX existe, vous pouvez le récupérer et lister ses appartenances.
Pour en savoir plus, consultez la section Récupérer et lister les groupes POSIX.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003ePOSIX groups are deprecated and will no longer be available for creation after September 26, 2024.\u003c/p\u003e\n"],["\u003cp\u003eThis document outlines the steps to create a POSIX group from an existing or new Google group using gcloud, REST, or Python.\u003c/p\u003e\n"],["\u003cp\u003eYou must use the beta version of the Cloud Identity Groups API to create and delete POSIX groups and have Cloud Identity setup before doing so.\u003c/p\u003e\n"],["\u003cp\u003eDeleting a POSIX group only removes the POSIX information from a Google group, but does not delete the underlying Google group.\u003c/p\u003e\n"],["\u003cp\u003eThe document also covers how to remove POSIX group information from a google group, using gcloud, REST, and Python.\u003c/p\u003e\n"]]],[],null,["# Creating and deleting POSIX groups\n==================================\n\n| **Caution:** POSIX groups are [deprecated](/identity/docs/deprecations). As of September 26, 2024, you can no longer create new POSIX groups. For more information, see [POSIX groups deprecation](/identity/docs/deprecations/posix-groups).\n\nThis document explains how to create and delete a POSIX group.\n|\n| **Preview**\n|\n|\n| This product is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n| **Note:** You must use the beta version of the Cloud Identity Groups API to create and delete POSIX groups.\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/setup) 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\nCreating a POSIX group\n----------------------\n\nYou can create a POSIX group from an existing Google group, or by creating a new\nGoogle group and adding POSIX information.\n\n### Creating a POSIX group from an existing Google group\n\nThe following examples show how to create a POSIX group from an existing\nGoogle group: \n\n### gcloud\n\n\nUse the\n[`gcloud beta identity groups update` command](/sdk/gcloud/reference/beta/identity/groups/update)\nto update an existing Google group to a POSIX group: \n\n```\ngcloud beta identity groups update EMAIL \\\n --add-posix-group=gid=GROUP_ID,name=POSIX_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eEMAIL\u003c/var\u003e: the email address of the group to update\n- \u003cvar translate=\"no\"\u003eGROUP_ID\u003c/var\u003e: the group ID (GID) you want to assign to the POSIX group\n- \u003cvar translate=\"no\"\u003ePOSIX_NAME\u003c/var\u003e: the name you want to assign to the POSIX group\n\n### REST\n\nTo update a Google Group to a POSIX group, call the\n[`groups.patch()` method](/identity/docs/reference/rest/v1beta1/groups/patch)\nwith the POSIX groups field specified. \n\n```\nPATCH 'https://cloudidentity.googleapis.com/v1beta1/groups/GROUP_RESOURCE_NAME?updateMask=posix_group\n\n{\n \"posixGroups\": [\n {\n \"name\": \"POSIX_NAME\",\n \"gid\": GROUP_ID\n }\n ]\n}\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eGROUP_RESOURCE_NAME\u003c/var\u003e: the resource name of the Google group. To find a group's resource name, run the [`gcloud identity groups describe` command](/sdk/gcloud/reference/identity/groups/describe)\n- \u003cvar translate=\"no\"\u003ePOSIX_NAME\u003c/var\u003e: the name you want to assign to the POSIX group\n- \u003cvar translate=\"no\"\u003eGROUP_ID\u003c/var\u003e: the group ID (GID) you want to assign to the POSIX group\n\n### Python\n\nThe following example shows a helper function to update a Google Group to a\nPOSIX group using the Python client library: \n\n def add_posix_group_data_to_group(service, group_name, posix_name, posix_gid):\n group = {\n \"posix_groups\": [\n {\n \"name\": posix_name,\n \"gid\": posix_gid,\n }\n ]\n }\n try:\n request = service.groups().patch(name=group_name, body=group)\n request.uri = request.uri + '&updateMask=posix_groups'\n response = request.execute()\n print(response)\n except Exception as e:\n print(e)\n\n### Creating a POSIX group from a new Google group\n\nThe following examples show how to create a POSIX group from a new Google group: \n\n### gcloud\n\nUse the\n[`gcloud beta identity groups create` command](/sdk/gcloud/reference/beta/identity/groups/create)\nto create a POSIX group: \n\n```\ngcloud beta identity groups create EMAIL \\\n --organization=ORGANIZATION_ID \\\n --labels=cloudidentity.googleapis.com/groups.discussion_forum \\\n --posix-group=gid=GROUP_ID,name=POSIX_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eEMAIL\u003c/var\u003e: the email address of the group to be created\n- \u003cvar translate=\"no\"\u003eORGANIZATION_ID\u003c/var\u003e: the organization the group belongs to. Either an ID (\"123456789\") or the associated domain (\"example.com\").\n- \u003cvar translate=\"no\"\u003eGROUP_ID\u003c/var\u003e: the group ID (GID) you set for the group\n- \u003cvar translate=\"no\"\u003ePOSIX_NAME\u003c/var\u003e: the name you set for the group\n\n### REST\n\nTo create a group, call the\n[`groups.create()` method](/identity/docs/reference/rest/v1beta1/groups/create)\nwith the email address, organization ID, POSIX groups, and labels for the new\ngroup. \n\n```\nPOST 'https://cloudidentity.googleapis.com/v1beta1/groups?initialGroupConfig=WITH_INITIAL_OWNER\n\n{\n\"parent\": \"customers/CUSTOMER_ID\",\n\"groupKey\": {\"id\": \"EMAIL\"},\n\"labels\": {\"cloudidentity.googleapis.com/groups.discussion_forum\": \"\"},\n\"posixGroups\": [\n {\n \"name\": \"POSIX_NAME\",\n \"gid\": GROUP_ID,\n }\n]\n}\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003einitialGroupConfig=WITH_INITIAL_OWNER\u003c/var\u003e: Either `?initialGroupConfig=WITH_INITIAL_OWNER` or empty. Any empty group can only be created by organization admins.\n- \u003cvar translate=\"no\"\u003eCUSTOMER_ID\u003c/var\u003e: the customer ID for your organization. To find the customer ID run the [`gcloud organizations list` command](/sdk/gcloud/reference/organizations/list)\n- \u003cvar translate=\"no\"\u003eEMAIL\u003c/var\u003e: the email address of the group to be created\n- \u003cvar translate=\"no\"\u003ePOSIX_NAME\u003c/var\u003e: the name you want to assign to the POSIX group\n- \u003cvar translate=\"no\"\u003eGROUP_ID\u003c/var\u003e: the group ID (GID) you want to assign to the POSIX group\n\n### Python\n\nThe following example shows a helper function to create a POSIX group using\nthe Python client library: \n\n def create_posix_group(customer_id, email, query, posix_name, posix_gid):\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 \"posixGroups\": [\n {\n \"name\": posix_name,\n \"gid\": posix_gid,\n }\n ]\n }\n request = service.groups().create(body=groupDef)\n request.uri += \"&initialGroupConfig=WITH_INITIAL_OWNER\"\n response = request.execute()\n return response\n\nDeleting a POSIX group\n----------------------\n\nThe following examples show how to remove POSIX information from a Google\ngroup.\n**Note:** When you remove POSIX information from a Google group, the Google group isn't deleted. \n\n### gcloud\n\nUse the\n[`gcloud beta identity groups update` command](/sdk/gcloud/reference/beta/identity/groups/update)\nand specify the `--remove-posix-groups` flag with the\n\u003cvar translate=\"no\"\u003eGROUP_ID\u003c/var\u003e or \u003cvar translate=\"no\"\u003ePOSIX_NAME\u003c/var\u003e value: \n\n```\ngcloud beta identity groups update \\\n EMAIL \\\n --remove-posix-groups=GROUP_ID_or_POSIX_NAME\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eEMAIL\u003c/var\u003e: the email address of the group to be deleted\n- \u003cvar translate=\"no\"\u003eGROUP_ID_or_POSIX_NAME\u003c/var\u003e: the group ID or POSIX group name of the group to be deleted\n\n### REST\n\nTo update a Google Group to a POSIX group, call the\n[`groups.patch()` method](/identity/docs/reference/rest/tt1/groups/patch) with\nthe POSIX groups field specified. \n\n```\nPATCH 'https://cloudidentity.googleapis.com/v1beta1/groups/GROUP_RESOURCE_NAME?updateMask=posix_group\n\n{\n \"posixGroups\": []\n}\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eGROUP_RESOURCE_NAME\u003c/var\u003e: the resource name of the Google group. To find a group's resource name, run the [`gcloud identity groups describe` command](/sdk/gcloud/reference/identity/groups/describe)\n\n### Python\n\nThe following example shows a helper function to update a Google Group to a\nPOSIX group using the Python client library: \n\n def remove_posix_data_from_group(service, group_name, posix_name, posix_gid):\n group = {\n \"posix_groups\": []\n }\n try:\n request = service.groups().patch(name=group_name, body=group)\n request.uri = request.uri + '&updateMask=posix_groups'\n response = request.execute()\n print(response)\n except Exception as e:\n print(e)\n\nWhat's next\n-----------\n\nAfter the POSIX group exists, you can retrieve it and list its memberships.\nFor more information, see\n[Retrieving and listing POSIX groups](/identity/docs/how-to/retrieve-list-posix-groups)."]]