Method: googleapis.cloudresourcemanager.v3.projects.setIamPolicy

Sets the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. The following constraints apply when using setIamPolicy(): + Project does not support allUsers and allAuthenticatedUsers as members in a Binding of a Policy. + The owner role can be granted to a user, serviceAccount, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using setIamPolicy(); they must be sent only using the Cloud Platform Console. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling setIamPolicy() to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible. + Calling this method requires enabling the App Engine Admin API.

Arguments

Parameters
resource

string

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

body

object (SetIamPolicyRequest)

Required.

Raised exceptions

Exceptions
ConnectionError In case of a network problem (such as DNS failure or refused connection).
HttpError If the response status is >= 400 (excluding 429 and 503).
TimeoutError If a long-running operation takes longer to finish than the specified timeout limit.
TypeError If an operation or function receives an argument of the wrong type.
ValueError If an operation or function receives an argument of the right type but an inappropriate value. For example, a negative timeout.

Response

If successful, the response contains an instance of Policy.

Subworkflow snippet

Some fields might be optional or required. To identify required fields, refer to the API documentation.

YAML

- setIamPolicy:
    call: googleapis.cloudresourcemanager.v3.projects.setIamPolicy
    args:
        resource: ...
        body:
            policy:
                auditConfigs: ...
                bindings: ...
                etag: ...
                version: ...
            updateMask: ...
    result: setIamPolicyResult

JSON

[
  {
    "setIamPolicy": {
      "call": "googleapis.cloudresourcemanager.v3.projects.setIamPolicy",
      "args": {
        "resource": "...",
        "body": {
          "policy": {
            "auditConfigs": "...",
            "bindings": "...",
            "etag": "...",
            "version": "..."
          },
          "updateMask": "..."
        }
      },
      "result": "setIamPolicyResult"
    }
  }
]