Class for Identity and Access Management (IAM) policies. IAM policies are used to specify access
settings for Cloud Platform resources. A policy is a list of bindings. A binding assigns a set of
identities to a role, where the identities can be user accounts, Google groups, Google domains,
and service accounts. A role is a named list of permissions defined by IAM.
See Also: Policy
Etags are used for optimistic concurrency control as a way to help prevent simultaneous
updates of a policy from overwriting each other. It is strongly suggested that systems make use
of the etag in the read-modify-write cycle to perform policy updates in order to avoid race
conditions. An etag is returned in the response to getIamPolicy, and systems are expected to
put that etag in the request to setIamPolicy to ensure that their change will be applied to the
same version of the policy. If no etag is provided in the call to setIamPolicy, then the
existing policy is overwritten blindly.
Returns the version of the policy. The default version is 0, meaning only the "owner",
"editor", and "viewer" roles are permitted. If the version is 1, you may also use other roles.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-15 UTC."],[],[],null,["# Class Policy (2.59.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.59.0 (latest)](/java/docs/reference/google-cloud-core/latest/com.google.cloud.Policy)\n- [2.58.2](/java/docs/reference/google-cloud-core/2.58.2/com.google.cloud.Policy)\n- [2.57.0](/java/docs/reference/google-cloud-core/2.57.0/com.google.cloud.Policy)\n- [2.56.0](/java/docs/reference/google-cloud-core/2.56.0/com.google.cloud.Policy)\n- [2.55.0](/java/docs/reference/google-cloud-core/2.55.0/com.google.cloud.Policy)\n- [2.53.1](/java/docs/reference/google-cloud-core/2.53.1/com.google.cloud.Policy)\n- [2.52.0](/java/docs/reference/google-cloud-core/2.52.0/com.google.cloud.Policy)\n- [2.51.0](/java/docs/reference/google-cloud-core/2.51.0/com.google.cloud.Policy)\n- [2.50.0](/java/docs/reference/google-cloud-core/2.50.0/com.google.cloud.Policy)\n- [2.49.1](/java/docs/reference/google-cloud-core/2.49.1/com.google.cloud.Policy)\n- [2.48.0](/java/docs/reference/google-cloud-core/2.48.0/com.google.cloud.Policy)\n- [2.47.0](/java/docs/reference/google-cloud-core/2.47.0/com.google.cloud.Policy)\n- [2.45.0](/java/docs/reference/google-cloud-core/2.45.0/com.google.cloud.Policy)\n- [2.44.1](/java/docs/reference/google-cloud-core/2.44.1/com.google.cloud.Policy)\n- [2.43.0](/java/docs/reference/google-cloud-core/2.43.0/com.google.cloud.Policy)\n- [2.42.0](/java/docs/reference/google-cloud-core/2.42.0/com.google.cloud.Policy)\n- [2.41.0](/java/docs/reference/google-cloud-core/2.41.0/com.google.cloud.Policy)\n- [2.40.0](/java/docs/reference/google-cloud-core/2.40.0/com.google.cloud.Policy)\n- [2.39.0](/java/docs/reference/google-cloud-core/2.39.0/com.google.cloud.Policy)\n- [2.38.1](/java/docs/reference/google-cloud-core/2.38.1/com.google.cloud.Policy)\n- [2.37.0](/java/docs/reference/google-cloud-core/2.37.0/com.google.cloud.Policy)\n- [2.36.1](/java/docs/reference/google-cloud-core/2.36.1/com.google.cloud.Policy)\n- [2.35.0](/java/docs/reference/google-cloud-core/2.35.0/com.google.cloud.Policy)\n- [2.33.0](/java/docs/reference/google-cloud-core/2.33.0/com.google.cloud.Policy)\n- [2.32.0](/java/docs/reference/google-cloud-core/2.32.0/com.google.cloud.Policy)\n- [2.31.0](/java/docs/reference/google-cloud-core/2.31.0/com.google.cloud.Policy)\n- [2.29.0](/java/docs/reference/google-cloud-core/2.29.0/com.google.cloud.Policy)\n- [2.28.0](/java/docs/reference/google-cloud-core/2.28.0/com.google.cloud.Policy)\n- [2.27.0](/java/docs/reference/google-cloud-core/2.27.0/com.google.cloud.Policy)\n- [2.26.0](/java/docs/reference/google-cloud-core/2.26.0/com.google.cloud.Policy)\n- [2.25.0](/java/docs/reference/google-cloud-core/2.25.0/com.google.cloud.Policy)\n- [2.24.1](/java/docs/reference/google-cloud-core/2.24.1/com.google.cloud.Policy)\n- [2.23.0](/java/docs/reference/google-cloud-core/2.23.0/com.google.cloud.Policy)\n- [2.22.1](/java/docs/reference/google-cloud-core/2.22.1/com.google.cloud.Policy)\n- [2.21.1](/java/docs/reference/google-cloud-core/2.21.1/com.google.cloud.Policy)\n- [2.20.1](/java/docs/reference/google-cloud-core/2.20.1/com.google.cloud.Policy)\n- [2.13.0](/java/docs/reference/google-cloud-core/2.13.0/com.google.cloud.Policy)\n- [2.12.0](/java/docs/reference/google-cloud-core/2.12.0/com.google.cloud.Policy)\n- [2.11.0](/java/docs/reference/google-cloud-core/2.11.0/com.google.cloud.Policy)\n- [2.9.4](/java/docs/reference/google-cloud-core/2.9.4/com.google.cloud.Policy)\n- [2.8.27](/java/docs/reference/google-cloud-core/2.8.27/com.google.cloud.Policy)\n- [2.7.1](/java/docs/reference/google-cloud-core/2.7.1/com.google.cloud.Policy)\n- [2.6.1](/java/docs/reference/google-cloud-core/2.6.1/com.google.cloud.Policy)\n- [2.5.11](/java/docs/reference/google-cloud-core/2.5.11/com.google.cloud.Policy)\n- [2.4.0](/java/docs/reference/google-cloud-core/2.4.0/com.google.cloud.Policy)\n- [2.3.5](/java/docs/reference/google-cloud-core/2.3.5/com.google.cloud.Policy) \n\n public final class Policy implements Serializable\n\nClass for Identity and Access Management (IAM) policies. IAM policies are used to specify access\nsettings for Cloud Platform resources. A policy is a list of bindings. A binding assigns a set of\nidentities to a role, where the identities can be user accounts, Google groups, Google domains,\nand service accounts. A role is a named list of permissions defined by IAM.\nSee Also: [Policy](https://cloud.google.com/iam/docs/reference/rest/v1/Policy) \n\nInheritance\n-----------\n\n[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e Policy \n\nImplements\n----------\n\n[Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html) \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### newBuilder()\n\n public static Policy.Builder newBuilder()\n\nReturns a builder for `Policy` objects.\n\nMethods\n-------\n\n### equals(Object obj)\n\n public boolean equals(Object obj)\n\n**Overrides** \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)\n\n### getBindings()\n\n public Map\u003cRole,Set\u003cIdentity\u003e\u003e getBindings()\n\nReturns the map of bindings that comprises the policy.\n\n### getBindingsList()\n\n public ImmutableList\u003cBinding\u003e getBindingsList()\n\nReturns the list of bindings that comprises the policy for version 3.\n\n### getEtag()\n\n public String getEtag()\n\nReturns the policy's etag.\n\nEtags are used for optimistic concurrency control as a way to help prevent simultaneous\nupdates of a policy from overwriting each other. It is strongly suggested that systems make use\nof the etag in the read-modify-write cycle to perform policy updates in order to avoid race\nconditions. An etag is returned in the response to getIamPolicy, and systems are expected to\nput that etag in the request to setIamPolicy to ensure that their change will be applied to the\nsame version of the policy. If no etag is provided in the call to setIamPolicy, then the\nexisting policy is overwritten blindly.\n\n### getVersion()\n\n public int getVersion()\n\nReturns the version of the policy. The default version is 0, meaning only the \"owner\",\n\"editor\", and \"viewer\" roles are permitted. If the version is 1, you may also use other roles.\n\n### hashCode()\n\n public int hashCode()\n\n**Overrides** \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)\n\n### toBuilder()\n\n public Policy.Builder toBuilder()\n\nReturns a builder containing the properties of this IAM Policy.\n\n### toString()\n\n public String toString()\n\n**Overrides** \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)"]]