Package com.google.cloud
Class Policy.Builder
java.lang.Object
com.google.cloud.Policy.Builder
- Enclosing class:
- Policy
A builder for
Policy objects.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Policy.BuilderaddIdentity(Role role, Identity first, Identity... others) Adds one or more identities to the policy under the role specified.final Policybuild()Creates aPolicyobject.final Policy.BuilderremoveIdentity(Role role, Identity first, Identity... others) Removes one or more identities from an existing binding.final Policy.BuilderremoveRole(Role role) Removes the role (and all identities associated with that role) from the policy.final Policy.BuildersetBindings(List<Binding> bindings) Replaces the builder's List of bindings with the given List of Bindings.final Policy.BuildersetBindings(Map<Role, Set<Identity>> bindings) Replaces the builder's map of bindings with the given map of bindings.final Policy.BuilderSets the policy's etag.final Policy.BuildersetVersion(int version) Sets the version of the policy.
-
Constructor Details
-
Builder
-
Builder
@InternalApi("This class should only be extended within google-cloud-java") protected Builder(Policy policy)
-
-
Method Details
-
setBindings
Replaces the builder's map of bindings with the given map of bindings.- Throws:
NullPointerException- if the given map is null or contains any null keys or valuesIllegalArgumentException- if any identities in the given map are null or if policy version is equal to 3 or has conditional bindings because conditional policies are not supported
-
setBindings
Replaces the builder's List of bindings with the given List of Bindings.- Throws:
NullPointerException- if the given list is null, role is null, or contains any null members in bindings
-
removeRole
Removes the role (and all identities associated with that role) from the policy.- Throws:
IllegalArgumentException- if policy version is equal to 3 or has conditional bindings because conditional policies are not supported
-
addIdentity
Adds one or more identities to the policy under the role specified.- Throws:
NullPointerException- if the role or any of the identities is null.IllegalArgumentException- if policy version is equal to 3 or has conditional bindings.
-
removeIdentity
Removes one or more identities from an existing binding. Does nothing if the binding associated with the provided role doesn't exist.- Throws:
IllegalArgumentException- if policy version is equal to 3 or has conditional bindings
-
setEtag
Sets the policy's etag.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.
-
setVersion
Sets the version of the policy. -
build
Creates aPolicyobject.
-