To create a security group, you must first create a Google Group, and then update that Google Group to a security group. This page explains how to update a Google Group to a security group.
Before you begin
Perform the following tasks before proceeding with the information on this page:
Read the Groups API overview.
Read the dynamic groups overview.
As a Google Group Admin, create a Google Group.
Updating a Google Group to a security group
Security groups can only contain users, service accounts, and other security groups. Security groups cannot contain external groups, external groups that are security groups, or internal groups that aren't security groups. You cannot apply a label to a Google Group that doesn't meet these conditions.
REST
To update a Google Group to a security group, call
groups.patch()
with
the label
set to cloudidentity.googleapis.com/groups.security
and
cloudidentity.googleapis.com/groups.discussion_forum
.
Python
The following example shows a helper function to update a Google Group to a security group using the Python client library:
def add_security_label_to_group(service, group_name):
group = {
"labels": {
"cloudidentity.googleapis.com/groups.security": "",
"cloudidentity.googleapis.com/groups.discussion_forum": ""
}
}
try:
request = service.groups().patch(name=group_name, body=group)
request.uri = request.uri + '&updateMask=labels'
response = request.execute()
print(response)
except Exception as e:
print(e)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-12-14 UTC.