Class PolicyBindingsClient (1.60.0)

GitHub RepositoryProduct Reference

Service Description: An interface for managing Identity and Access Management (IAM) policy bindings.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   PolicyBindingName name =
       PolicyBindingName.ofProjectLocationPolicyBindingName(
           "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]");
   PolicyBinding response = policyBindingsClient.getPolicyBinding(name);
 }
 

Note: close() needs to be called on the PolicyBindingsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

CreatePolicyBinding

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createPolicyBindingAsync(CreatePolicyBindingRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • createPolicyBindingAsync(FolderLocationName parent, PolicyBinding policyBinding, String policyBindingId)

  • createPolicyBindingAsync(LocationName parent, PolicyBinding policyBinding, String policyBindingId)

  • createPolicyBindingAsync(OrganizationLocationName parent, PolicyBinding policyBinding, String policyBindingId)

  • createPolicyBindingAsync(String parent, PolicyBinding policyBinding, String policyBindingId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createPolicyBindingOperationCallable()

  • createPolicyBindingCallable()

GetPolicyBinding

Gets a policy binding.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getPolicyBinding(GetPolicyBindingRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getPolicyBinding(PolicyBindingName name)

  • getPolicyBinding(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getPolicyBindingCallable()

UpdatePolicyBinding

Updates a policy binding and returns a long-running operation. Callers will need the IAM permissions on the policy and target in the binding to update, and the IAM permission to remove the existing policy from the binding. Target is immutable and cannot be updated. Once the binding is updated, the new policy is applied to the target.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updatePolicyBindingAsync(UpdatePolicyBindingRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • updatePolicyBindingAsync(PolicyBinding policyBinding, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updatePolicyBindingOperationCallable()

  • updatePolicyBindingCallable()

DeletePolicyBinding

Deletes a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deletePolicyBindingAsync(DeletePolicyBindingRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deletePolicyBindingAsync(PolicyBindingName name)

  • deletePolicyBindingAsync(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deletePolicyBindingOperationCallable()

  • deletePolicyBindingCallable()

ListPolicyBindings

Lists policy bindings.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listPolicyBindings(ListPolicyBindingsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listPolicyBindings(FolderLocationName parent)

  • listPolicyBindings(LocationName parent)

  • listPolicyBindings(OrganizationLocationName parent)

  • listPolicyBindings(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listPolicyBindingsPagedCallable()

  • listPolicyBindingsCallable()

SearchTargetPolicyBindings

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • searchTargetPolicyBindings(SearchTargetPolicyBindingsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • searchTargetPolicyBindings(FolderLocationName parent, String target)

  • searchTargetPolicyBindings(LocationName parent, String target)

  • searchTargetPolicyBindings(OrganizationLocationName parent, String target)

  • searchTargetPolicyBindings(String parent, String target)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • searchTargetPolicyBindingsPagedCallable()

  • searchTargetPolicyBindingsCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of PolicyBindingsSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 PolicyBindingsSettings policyBindingsSettings =
     PolicyBindingsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create(policyBindingsSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 PolicyBindingsSettings policyBindingsSettings =
     PolicyBindingsSettings.newBuilder().setEndpoint(myEndpoint).build();
 PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create(policyBindingsSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 PolicyBindingsSettings policyBindingsSettings =
     PolicyBindingsSettings.newHttpJsonBuilder().build();
 PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create(policyBindingsSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > PolicyBindingsClient

Static Methods

create()

public static final PolicyBindingsClient create()

Constructs an instance of PolicyBindingsClient with default settings.

Returns
Type Description
PolicyBindingsClient
Exceptions
Type Description
IOException

create(PolicyBindingsSettings settings)

public static final PolicyBindingsClient create(PolicyBindingsSettings settings)

Constructs an instance of PolicyBindingsClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings PolicyBindingsSettings
Returns
Type Description
PolicyBindingsClient
Exceptions
Type Description
IOException

create(PolicyBindingsStub stub)

public static final PolicyBindingsClient create(PolicyBindingsStub stub)

Constructs an instance of PolicyBindingsClient, using the given stub for making calls. This is for advanced usage - prefer using create(PolicyBindingsSettings).

Parameter
Name Description
stub PolicyBindingsStub
Returns
Type Description
PolicyBindingsClient

Constructors

PolicyBindingsClient(PolicyBindingsSettings settings)

protected PolicyBindingsClient(PolicyBindingsSettings settings)

Constructs an instance of PolicyBindingsClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings PolicyBindingsSettings

PolicyBindingsClient(PolicyBindingsStub stub)

protected PolicyBindingsClient(PolicyBindingsStub stub)
Parameter
Name Description
stub PolicyBindingsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

createPolicyBindingAsync(CreatePolicyBindingRequest request)

public final OperationFuture<PolicyBinding,OperationMetadata> createPolicyBindingAsync(CreatePolicyBindingRequest request)

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   CreatePolicyBindingRequest request =
       CreatePolicyBindingRequest.newBuilder()
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPolicyBindingId("policyBindingId1375821166")
           .setPolicyBinding(PolicyBinding.newBuilder().build())
           .setValidateOnly(true)
           .build();
   PolicyBinding response = policyBindingsClient.createPolicyBindingAsync(request).get();
 }
 
Parameter
Name Description
request CreatePolicyBindingRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<PolicyBinding,OperationMetadata>

createPolicyBindingAsync(FolderLocationName parent, PolicyBinding policyBinding, String policyBindingId)

public final OperationFuture<PolicyBinding,OperationMetadata> createPolicyBindingAsync(FolderLocationName parent, PolicyBinding policyBinding, String policyBindingId)

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
   PolicyBinding policyBinding = PolicyBinding.newBuilder().build();
   String policyBindingId = "policyBindingId1375821166";
   PolicyBinding response =
       policyBindingsClient
           .createPolicyBindingAsync(parent, policyBinding, policyBindingId)
           .get();
 }
 
Parameters
Name Description
parent FolderLocationName

Required. The parent resource where this policy binding will be created. The binding parent is the closest Resource Manager resource (project, folder or organization) to the binding target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

policyBinding PolicyBinding

Required. The policy binding to create.

policyBindingId String

Required. The ID to use for the policy binding, which will become the final component of the policy binding's resource name.

This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, hyphens, or dots. Pattern, /a-z{2,62}/.

Returns
Type Description
OperationFuture<PolicyBinding,OperationMetadata>

createPolicyBindingAsync(LocationName parent, PolicyBinding policyBinding, String policyBindingId)

public final OperationFuture<PolicyBinding,OperationMetadata> createPolicyBindingAsync(LocationName parent, PolicyBinding policyBinding, String policyBindingId)

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   PolicyBinding policyBinding = PolicyBinding.newBuilder().build();
   String policyBindingId = "policyBindingId1375821166";
   PolicyBinding response =
       policyBindingsClient
           .createPolicyBindingAsync(parent, policyBinding, policyBindingId)
           .get();
 }
 
Parameters
Name Description
parent LocationName

Required. The parent resource where this policy binding will be created. The binding parent is the closest Resource Manager resource (project, folder or organization) to the binding target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

policyBinding PolicyBinding

Required. The policy binding to create.

policyBindingId String

Required. The ID to use for the policy binding, which will become the final component of the policy binding's resource name.

This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, hyphens, or dots. Pattern, /a-z{2,62}/.

Returns
Type Description
OperationFuture<PolicyBinding,OperationMetadata>

createPolicyBindingAsync(OrganizationLocationName parent, PolicyBinding policyBinding, String policyBindingId)

public final OperationFuture<PolicyBinding,OperationMetadata> createPolicyBindingAsync(OrganizationLocationName parent, PolicyBinding policyBinding, String policyBindingId)

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
   PolicyBinding policyBinding = PolicyBinding.newBuilder().build();
   String policyBindingId = "policyBindingId1375821166";
   PolicyBinding response =
       policyBindingsClient
           .createPolicyBindingAsync(parent, policyBinding, policyBindingId)
           .get();
 }
 
Parameters
Name Description
parent OrganizationLocationName

Required. The parent resource where this policy binding will be created. The binding parent is the closest Resource Manager resource (project, folder or organization) to the binding target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

policyBinding PolicyBinding

Required. The policy binding to create.

policyBindingId String

Required. The ID to use for the policy binding, which will become the final component of the policy binding's resource name.

This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, hyphens, or dots. Pattern, /a-z{2,62}/.

Returns
Type Description
OperationFuture<PolicyBinding,OperationMetadata>

createPolicyBindingAsync(String parent, PolicyBinding policyBinding, String policyBindingId)

public final OperationFuture<PolicyBinding,OperationMetadata> createPolicyBindingAsync(String parent, PolicyBinding policyBinding, String policyBindingId)

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   String parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
   PolicyBinding policyBinding = PolicyBinding.newBuilder().build();
   String policyBindingId = "policyBindingId1375821166";
   PolicyBinding response =
       policyBindingsClient
           .createPolicyBindingAsync(parent, policyBinding, policyBindingId)
           .get();
 }
 
Parameters
Name Description
parent String

Required. The parent resource where this policy binding will be created. The binding parent is the closest Resource Manager resource (project, folder or organization) to the binding target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

policyBinding PolicyBinding

Required. The policy binding to create.

policyBindingId String

Required. The ID to use for the policy binding, which will become the final component of the policy binding's resource name.

This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, hyphens, or dots. Pattern, /a-z{2,62}/.

Returns
Type Description
OperationFuture<PolicyBinding,OperationMetadata>

createPolicyBindingCallable()

public final UnaryCallable<CreatePolicyBindingRequest,Operation> createPolicyBindingCallable()

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   CreatePolicyBindingRequest request =
       CreatePolicyBindingRequest.newBuilder()
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPolicyBindingId("policyBindingId1375821166")
           .setPolicyBinding(PolicyBinding.newBuilder().build())
           .setValidateOnly(true)
           .build();
   ApiFuture<Operation> future =
       policyBindingsClient.createPolicyBindingCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreatePolicyBindingRequest,Operation>

createPolicyBindingOperationCallable()

public final OperationCallable<CreatePolicyBindingRequest,PolicyBinding,OperationMetadata> createPolicyBindingOperationCallable()

Creates a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   CreatePolicyBindingRequest request =
       CreatePolicyBindingRequest.newBuilder()
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPolicyBindingId("policyBindingId1375821166")
           .setPolicyBinding(PolicyBinding.newBuilder().build())
           .setValidateOnly(true)
           .build();
   OperationFuture<PolicyBinding, OperationMetadata> future =
       policyBindingsClient.createPolicyBindingOperationCallable().futureCall(request);
   // Do something.
   PolicyBinding response = future.get();
 }
 
Returns
Type Description
OperationCallable<CreatePolicyBindingRequest,PolicyBinding,OperationMetadata>

deletePolicyBindingAsync(DeletePolicyBindingRequest request)

public final OperationFuture<Empty,OperationMetadata> deletePolicyBindingAsync(DeletePolicyBindingRequest request)

Deletes a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   DeletePolicyBindingRequest request =
       DeletePolicyBindingRequest.newBuilder()
           .setName(
               PolicyBindingName.ofProjectLocationPolicyBindingName(
                       "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]")
                   .toString())
           .setEtag("etag3123477")
           .setValidateOnly(true)
           .build();
   policyBindingsClient.deletePolicyBindingAsync(request).get();
 }
 
Parameter
Name Description
request DeletePolicyBindingRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<Empty,OperationMetadata>

deletePolicyBindingAsync(PolicyBindingName name)

public final OperationFuture<Empty,OperationMetadata> deletePolicyBindingAsync(PolicyBindingName name)

Deletes a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   PolicyBindingName name =
       PolicyBindingName.ofProjectLocationPolicyBindingName(
           "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]");
   policyBindingsClient.deletePolicyBindingAsync(name).get();
 }
 
Parameter
Name Description
name PolicyBindingName

Required. The name of the policy binding to delete.

Format:

  • projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}
  • projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}
  • folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}
  • organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}

Returns
Type Description
OperationFuture<Empty,OperationMetadata>

deletePolicyBindingAsync(String name)

public final OperationFuture<Empty,OperationMetadata> deletePolicyBindingAsync(String name)

Deletes a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   String name =
       PolicyBindingName.ofOrganizationLocationPolicyBindingName(
               "[ORGANIZATION]", "[LOCATION]", "[POLICY_BINDING]")
           .toString();
   policyBindingsClient.deletePolicyBindingAsync(name).get();
 }
 
Parameter
Name Description
name String

Required. The name of the policy binding to delete.

Format:

  • projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}
  • projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}
  • folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}
  • organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}

Returns
Type Description
OperationFuture<Empty,OperationMetadata>

deletePolicyBindingCallable()

public final UnaryCallable<DeletePolicyBindingRequest,Operation> deletePolicyBindingCallable()

Deletes a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   DeletePolicyBindingRequest request =
       DeletePolicyBindingRequest.newBuilder()
           .setName(
               PolicyBindingName.ofProjectLocationPolicyBindingName(
                       "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]")
                   .toString())
           .setEtag("etag3123477")
           .setValidateOnly(true)
           .build();
   ApiFuture<Operation> future =
       policyBindingsClient.deletePolicyBindingCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeletePolicyBindingRequest,Operation>

deletePolicyBindingOperationCallable()

public final OperationCallable<DeletePolicyBindingRequest,Empty,OperationMetadata> deletePolicyBindingOperationCallable()

Deletes a policy binding and returns a long-running operation. Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   DeletePolicyBindingRequest request =
       DeletePolicyBindingRequest.newBuilder()
           .setName(
               PolicyBindingName.ofProjectLocationPolicyBindingName(
                       "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]")
                   .toString())
           .setEtag("etag3123477")
           .setValidateOnly(true)
           .build();
   OperationFuture<Empty, OperationMetadata> future =
       policyBindingsClient.deletePolicyBindingOperationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
OperationCallable<DeletePolicyBindingRequest,Empty,OperationMetadata>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description
OperationsClient

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description
OperationsClient

getPolicyBinding(GetPolicyBindingRequest request)

public final PolicyBinding getPolicyBinding(GetPolicyBindingRequest request)

Gets a policy binding.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   GetPolicyBindingRequest request =
       GetPolicyBindingRequest.newBuilder()
           .setName(
               PolicyBindingName.ofProjectLocationPolicyBindingName(
                       "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]")
                   .toString())
           .build();
   PolicyBinding response = policyBindingsClient.getPolicyBinding(request);
 }
 
Parameter
Name Description
request GetPolicyBindingRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
PolicyBinding

getPolicyBinding(PolicyBindingName name)

public final PolicyBinding getPolicyBinding(PolicyBindingName name)

Gets a policy binding.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   PolicyBindingName name =
       PolicyBindingName.ofProjectLocationPolicyBindingName(
           "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]");
   PolicyBinding response = policyBindingsClient.getPolicyBinding(name);
 }
 
Parameter
Name Description
name PolicyBindingName

Required. The name of the policy binding to retrieve.

Format:

  • projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}
  • projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}
  • folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}
  • organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}

Returns
Type Description
PolicyBinding

getPolicyBinding(String name)

public final PolicyBinding getPolicyBinding(String name)

Gets a policy binding.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   String name =
       PolicyBindingName.ofOrganizationLocationPolicyBindingName(
               "[ORGANIZATION]", "[LOCATION]", "[POLICY_BINDING]")
           .toString();
   PolicyBinding response = policyBindingsClient.getPolicyBinding(name);
 }
 
Parameter
Name Description
name String

Required. The name of the policy binding to retrieve.

Format:

  • projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}
  • projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}
  • folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}
  • organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}

Returns
Type Description
PolicyBinding

getPolicyBindingCallable()

public final UnaryCallable<GetPolicyBindingRequest,PolicyBinding> getPolicyBindingCallable()

Gets a policy binding.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   GetPolicyBindingRequest request =
       GetPolicyBindingRequest.newBuilder()
           .setName(
               PolicyBindingName.ofProjectLocationPolicyBindingName(
                       "[PROJECT]", "[LOCATION]", "[POLICY_BINDING]")
                   .toString())
           .build();
   ApiFuture<PolicyBinding> future =
       policyBindingsClient.getPolicyBindingCallable().futureCall(request);
   // Do something.
   PolicyBinding response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetPolicyBindingRequest,PolicyBinding>

getSettings()

public final PolicyBindingsSettings getSettings()
Returns
Type Description
PolicyBindingsSettings

getStub()

public PolicyBindingsStub getStub()
Returns
Type Description
PolicyBindingsStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listPolicyBindings(FolderLocationName parent)

public final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(FolderLocationName parent)

Lists policy bindings.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
   for (PolicyBinding element : policyBindingsClient.listPolicyBindings(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent FolderLocationName

Required. The parent resource, which owns the collection of policy bindings.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

Returns
Type Description
PolicyBindingsClient.ListPolicyBindingsPagedResponse

listPolicyBindings(ListPolicyBindingsRequest request)

public final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(ListPolicyBindingsRequest request)

Lists policy bindings.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   ListPolicyBindingsRequest request =
       ListPolicyBindingsRequest.newBuilder()
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (PolicyBinding element : policyBindingsClient.listPolicyBindings(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListPolicyBindingsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
PolicyBindingsClient.ListPolicyBindingsPagedResponse

listPolicyBindings(LocationName parent)

public final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(LocationName parent)

Lists policy bindings.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (PolicyBinding element : policyBindingsClient.listPolicyBindings(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent LocationName

Required. The parent resource, which owns the collection of policy bindings.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

Returns
Type Description
PolicyBindingsClient.ListPolicyBindingsPagedResponse

listPolicyBindings(OrganizationLocationName parent)

public final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(OrganizationLocationName parent)

Lists policy bindings.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
   for (PolicyBinding element : policyBindingsClient.listPolicyBindings(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent OrganizationLocationName

Required. The parent resource, which owns the collection of policy bindings.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

Returns
Type Description
PolicyBindingsClient.ListPolicyBindingsPagedResponse

listPolicyBindings(String parent)

public final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(String parent)

Lists policy bindings.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   String parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
   for (PolicyBinding element : policyBindingsClient.listPolicyBindings(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent resource, which owns the collection of policy bindings.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

Returns
Type Description
PolicyBindingsClient.ListPolicyBindingsPagedResponse

listPolicyBindingsCallable()

public final UnaryCallable<ListPolicyBindingsRequest,ListPolicyBindingsResponse> listPolicyBindingsCallable()

Lists policy bindings.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   ListPolicyBindingsRequest request =
       ListPolicyBindingsRequest.newBuilder()
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListPolicyBindingsResponse response =
         policyBindingsClient.listPolicyBindingsCallable().call(request);
     for (PolicyBinding element : response.getPolicyBindingsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListPolicyBindingsRequest,ListPolicyBindingsResponse>

listPolicyBindingsPagedCallable()

public final UnaryCallable<ListPolicyBindingsRequest,PolicyBindingsClient.ListPolicyBindingsPagedResponse> listPolicyBindingsPagedCallable()

Lists policy bindings.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   ListPolicyBindingsRequest request =
       ListPolicyBindingsRequest.newBuilder()
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<PolicyBinding> future =
       policyBindingsClient.listPolicyBindingsPagedCallable().futureCall(request);
   // Do something.
   for (PolicyBinding element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListPolicyBindingsRequest,ListPolicyBindingsPagedResponse>

searchTargetPolicyBindings(FolderLocationName parent, String target)

public final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(FolderLocationName parent, String target)

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
   String target = "target-880905839";
   for (PolicyBinding element :
       policyBindingsClient.searchTargetPolicyBindings(parent, target).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
Name Description
parent FolderLocationName

Required. The parent resource where this search will be performed. This should be the nearest Resource Manager resource (project, folder, or organization) to the target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

target String

Required. The target resource, which is bound to the policy in the binding.

Format:

  • //iam.googleapis.com/locations/global/workforcePools/POOL_ID
  • //iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID
  • //iam.googleapis.com/locations/global/workspace/WORKSPACE_ID
  • //cloudresourcemanager.googleapis.com/projects/{project_number}
  • //cloudresourcemanager.googleapis.com/folders/{folder_id}
  • //cloudresourcemanager.googleapis.com/organizations/{organization_id}

Returns
Type Description
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse

searchTargetPolicyBindings(LocationName parent, String target)

public final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(LocationName parent, String target)

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   String target = "target-880905839";
   for (PolicyBinding element :
       policyBindingsClient.searchTargetPolicyBindings(parent, target).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
Name Description
parent LocationName

Required. The parent resource where this search will be performed. This should be the nearest Resource Manager resource (project, folder, or organization) to the target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

target String

Required. The target resource, which is bound to the policy in the binding.

Format:

  • //iam.googleapis.com/locations/global/workforcePools/POOL_ID
  • //iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID
  • //iam.googleapis.com/locations/global/workspace/WORKSPACE_ID
  • //cloudresourcemanager.googleapis.com/projects/{project_number}
  • //cloudresourcemanager.googleapis.com/folders/{folder_id}
  • //cloudresourcemanager.googleapis.com/organizations/{organization_id}

Returns
Type Description
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse

searchTargetPolicyBindings(OrganizationLocationName parent, String target)

public final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(OrganizationLocationName parent, String target)

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
   String target = "target-880905839";
   for (PolicyBinding element :
       policyBindingsClient.searchTargetPolicyBindings(parent, target).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
Name Description
parent OrganizationLocationName

Required. The parent resource where this search will be performed. This should be the nearest Resource Manager resource (project, folder, or organization) to the target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

target String

Required. The target resource, which is bound to the policy in the binding.

Format:

  • //iam.googleapis.com/locations/global/workforcePools/POOL_ID
  • //iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID
  • //iam.googleapis.com/locations/global/workspace/WORKSPACE_ID
  • //cloudresourcemanager.googleapis.com/projects/{project_number}
  • //cloudresourcemanager.googleapis.com/folders/{folder_id}
  • //cloudresourcemanager.googleapis.com/organizations/{organization_id}

Returns
Type Description
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse

searchTargetPolicyBindings(SearchTargetPolicyBindingsRequest request)

public final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(SearchTargetPolicyBindingsRequest request)

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   SearchTargetPolicyBindingsRequest request =
       SearchTargetPolicyBindingsRequest.newBuilder()
           .setTarget("target-880905839")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .build();
   for (PolicyBinding element :
       policyBindingsClient.searchTargetPolicyBindings(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request SearchTargetPolicyBindingsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse

searchTargetPolicyBindings(String parent, String target)

public final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(String parent, String target)

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   String parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
   String target = "target-880905839";
   for (PolicyBinding element :
       policyBindingsClient.searchTargetPolicyBindings(parent, target).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
Name Description
parent String

Required. The parent resource where this search will be performed. This should be the nearest Resource Manager resource (project, folder, or organization) to the target.

Format:

  • projects/{project_id}/locations/{location}
  • projects/{project_number}/locations/{location}
  • folders/{folder_id}/locations/{location}
  • organizations/{organization_id}/locations/{location}

target String

Required. The target resource, which is bound to the policy in the binding.

Format:

  • //iam.googleapis.com/locations/global/workforcePools/POOL_ID
  • //iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID
  • //iam.googleapis.com/locations/global/workspace/WORKSPACE_ID
  • //cloudresourcemanager.googleapis.com/projects/{project_number}
  • //cloudresourcemanager.googleapis.com/folders/{folder_id}
  • //cloudresourcemanager.googleapis.com/organizations/{organization_id}

Returns
Type Description
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse

searchTargetPolicyBindingsCallable()

public final UnaryCallable<SearchTargetPolicyBindingsRequest,SearchTargetPolicyBindingsResponse> searchTargetPolicyBindingsCallable()

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   SearchTargetPolicyBindingsRequest request =
       SearchTargetPolicyBindingsRequest.newBuilder()
           .setTarget("target-880905839")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .build();
   while (true) {
     SearchTargetPolicyBindingsResponse response =
         policyBindingsClient.searchTargetPolicyBindingsCallable().call(request);
     for (PolicyBinding element : response.getPolicyBindingsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<SearchTargetPolicyBindingsRequest,SearchTargetPolicyBindingsResponse>

searchTargetPolicyBindingsPagedCallable()

public final UnaryCallable<SearchTargetPolicyBindingsRequest,PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse> searchTargetPolicyBindingsPagedCallable()

Search policy bindings by target. Returns all policy binding objects bound directly to target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   SearchTargetPolicyBindingsRequest request =
       SearchTargetPolicyBindingsRequest.newBuilder()
           .setTarget("target-880905839")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .build();
   ApiFuture<PolicyBinding> future =
       policyBindingsClient.searchTargetPolicyBindingsPagedCallable().futureCall(request);
   // Do something.
   for (PolicyBinding element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<SearchTargetPolicyBindingsRequest,SearchTargetPolicyBindingsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updatePolicyBindingAsync(PolicyBinding policyBinding, FieldMask updateMask)

public final OperationFuture<PolicyBinding,OperationMetadata> updatePolicyBindingAsync(PolicyBinding policyBinding, FieldMask updateMask)

Updates a policy binding and returns a long-running operation. Callers will need the IAM permissions on the policy and target in the binding to update, and the IAM permission to remove the existing policy from the binding. Target is immutable and cannot be updated. Once the binding is updated, the new policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   PolicyBinding policyBinding = PolicyBinding.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   PolicyBinding response =
       policyBindingsClient.updatePolicyBindingAsync(policyBinding, updateMask).get();
 }
 
Parameters
Name Description
policyBinding PolicyBinding

Required. The policy binding to update.

The policy binding's name field is used to identify the policy binding to update.

updateMask FieldMask

Optional. The list of fields to update

Returns
Type Description
OperationFuture<PolicyBinding,OperationMetadata>

updatePolicyBindingAsync(UpdatePolicyBindingRequest request)

public final OperationFuture<PolicyBinding,OperationMetadata> updatePolicyBindingAsync(UpdatePolicyBindingRequest request)

Updates a policy binding and returns a long-running operation. Callers will need the IAM permissions on the policy and target in the binding to update, and the IAM permission to remove the existing policy from the binding. Target is immutable and cannot be updated. Once the binding is updated, the new policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   UpdatePolicyBindingRequest request =
       UpdatePolicyBindingRequest.newBuilder()
           .setPolicyBinding(PolicyBinding.newBuilder().build())
           .setValidateOnly(true)
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   PolicyBinding response = policyBindingsClient.updatePolicyBindingAsync(request).get();
 }
 
Parameter
Name Description
request UpdatePolicyBindingRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<PolicyBinding,OperationMetadata>

updatePolicyBindingCallable()

public final UnaryCallable<UpdatePolicyBindingRequest,Operation> updatePolicyBindingCallable()

Updates a policy binding and returns a long-running operation. Callers will need the IAM permissions on the policy and target in the binding to update, and the IAM permission to remove the existing policy from the binding. Target is immutable and cannot be updated. Once the binding is updated, the new policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   UpdatePolicyBindingRequest request =
       UpdatePolicyBindingRequest.newBuilder()
           .setPolicyBinding(PolicyBinding.newBuilder().build())
           .setValidateOnly(true)
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       policyBindingsClient.updatePolicyBindingCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdatePolicyBindingRequest,Operation>

updatePolicyBindingOperationCallable()

public final OperationCallable<UpdatePolicyBindingRequest,PolicyBinding,OperationMetadata> updatePolicyBindingOperationCallable()

Updates a policy binding and returns a long-running operation. Callers will need the IAM permissions on the policy and target in the binding to update, and the IAM permission to remove the existing policy from the binding. Target is immutable and cannot be updated. Once the binding is updated, the new policy is applied to the target.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PolicyBindingsClient policyBindingsClient = PolicyBindingsClient.create()) {
   UpdatePolicyBindingRequest request =
       UpdatePolicyBindingRequest.newBuilder()
           .setPolicyBinding(PolicyBinding.newBuilder().build())
           .setValidateOnly(true)
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   OperationFuture<PolicyBinding, OperationMetadata> future =
       policyBindingsClient.updatePolicyBindingOperationCallable().futureCall(request);
   // Do something.
   PolicyBinding response = future.get();
 }
 
Returns
Type Description
OperationCallable<UpdatePolicyBindingRequest,PolicyBinding,OperationMetadata>