Identity and Access Management¶
Non-API-specific IAM policy definitions
For allowed roles / permissions, see: https://cloud.google.com/iam/docs/understanding-roles
Example usage:
# ``get_iam_policy`` returns a :class:'~google.api_core.iam.Policy`.
policy = resource.get_iam_policy()
phred = policy.user("phred@example.com")
admin_group = policy.group("admins@groups.example.com")
account = policy.service_account("account-1234@accounts.example.com")
policy["roles/owner"] = [phred, admin_group, account]
policy["roles/editor"] = policy.authenticated_users()
policy["roles/viewer"] = policy.all_users()
resource.set_iam_policy(policy)
-
google.api_core.iam.
OWNER_ROLE
= 'roles/owner'¶ Generic role implying all rights to an object.
-
google.api_core.iam.
EDITOR_ROLE
= 'roles/editor'¶ Generic role implying rights to modify an object.
-
google.api_core.iam.
VIEWER_ROLE
= 'roles/viewer'¶ Generic role implying rights to access an object.
-
class
google.api_core.iam.
Policy
(etag=None, version=None)[source]¶ Bases:
collections.abc.MutableMapping
IAM Policy
See https://cloud.google.com/iam/reference/rest/v1/Policy
- Parameters
-
property
owners
¶ Legacy access to owner role.
DEPRECATED: use
policy["roles/owners"]
instead.
-
property
editors
¶ Legacy access to editor role.
DEPRECATED: use
policy["roles/editors"]
instead.
-
property
viewers
¶ Legacy access to viewer role.
DEPRECATED: use
policy["roles/viewers"]
instead
-
static
all_users
()[source]¶ Factory method for a member representing all users.
- Returns
A member string representing all users.
- Return type
-
static
authenticated_users
()[source]¶ Factory method for a member representing all authenticated users.
- Returns
A member string representing all authenticated users.
- Return type