@BetaApi @Generated(value="by gapic-generator-java") public class PolicyBindingsClient extends Object implements com.google.api.gax.core.BackgroundResource
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().
| 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.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetPolicyBinding |
Gets a policy binding. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListPolicyBindings |
Lists policy bindings. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
PolicyBindingsClient.ListPolicyBindingsFixedSizeCollection |
static class |
PolicyBindingsClient.ListPolicyBindingsPage |
static class |
PolicyBindingsClient.ListPolicyBindingsPagedResponse |
static class |
PolicyBindingsClient.SearchTargetPolicyBindingsFixedSizeCollection |
static class |
PolicyBindingsClient.SearchTargetPolicyBindingsPage |
static class |
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
PolicyBindingsClient(PolicyBindingsSettings settings)
Constructs an instance of PolicyBindingsClient, using the given settings.
|
protected |
PolicyBindingsClient(PolicyBindingsStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static PolicyBindingsClient |
create()
Constructs an instance of PolicyBindingsClient with default settings.
|
static PolicyBindingsClient |
create(PolicyBindingsSettings settings)
Constructs an instance of PolicyBindingsClient, using the given settings.
|
static PolicyBindingsClient |
create(PolicyBindingsStub stub)
Constructs an instance of PolicyBindingsClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
createPolicyBindingAsync(com.google.iam.v3beta.CreatePolicyBindingRequest request)
Creates a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
createPolicyBindingAsync(com.google.iam.v3beta.FolderLocationName parent,
com.google.iam.v3beta.PolicyBinding policyBinding,
String policyBindingId)
Creates a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
createPolicyBindingAsync(com.google.iam.v3beta.LocationName parent,
com.google.iam.v3beta.PolicyBinding policyBinding,
String policyBindingId)
Creates a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
createPolicyBindingAsync(com.google.iam.v3beta.OrganizationLocationName parent,
com.google.iam.v3beta.PolicyBinding policyBinding,
String policyBindingId)
Creates a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
createPolicyBindingAsync(String parent,
com.google.iam.v3beta.PolicyBinding policyBinding,
String policyBindingId)
Creates a policy binding and returns a long-running operation.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.CreatePolicyBindingRequest,com.google.longrunning.Operation> |
createPolicyBindingCallable()
Creates a policy binding and returns a long-running operation.
|
com.google.api.gax.rpc.OperationCallable<com.google.iam.v3beta.CreatePolicyBindingRequest,com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
createPolicyBindingOperationCallable()
Creates a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> |
deletePolicyBindingAsync(com.google.iam.v3beta.DeletePolicyBindingRequest request)
Deletes a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> |
deletePolicyBindingAsync(com.google.iam.v3beta.PolicyBindingName name)
Deletes a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> |
deletePolicyBindingAsync(String name)
Deletes a policy binding and returns a long-running operation.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.DeletePolicyBindingRequest,com.google.longrunning.Operation> |
deletePolicyBindingCallable()
Deletes a policy binding and returns a long-running operation.
|
com.google.api.gax.rpc.OperationCallable<com.google.iam.v3beta.DeletePolicyBindingRequest,com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> |
deletePolicyBindingOperationCallable()
Deletes a policy binding and returns a long-running operation.
|
com.google.api.gax.httpjson.longrunning.OperationsClient |
getHttpJsonOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
com.google.iam.v3beta.PolicyBinding |
getPolicyBinding(com.google.iam.v3beta.GetPolicyBindingRequest request)
Gets a policy binding.
|
com.google.iam.v3beta.PolicyBinding |
getPolicyBinding(com.google.iam.v3beta.PolicyBindingName name)
Gets a policy binding.
|
com.google.iam.v3beta.PolicyBinding |
getPolicyBinding(String name)
Gets a policy binding.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.GetPolicyBindingRequest,com.google.iam.v3beta.PolicyBinding> |
getPolicyBindingCallable()
Gets a policy binding.
|
PolicyBindingsSettings |
getSettings() |
PolicyBindingsStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
PolicyBindingsClient.ListPolicyBindingsPagedResponse |
listPolicyBindings(com.google.iam.v3beta.FolderLocationName parent)
Lists policy bindings.
|
PolicyBindingsClient.ListPolicyBindingsPagedResponse |
listPolicyBindings(com.google.iam.v3beta.ListPolicyBindingsRequest request)
Lists policy bindings.
|
PolicyBindingsClient.ListPolicyBindingsPagedResponse |
listPolicyBindings(com.google.iam.v3beta.LocationName parent)
Lists policy bindings.
|
PolicyBindingsClient.ListPolicyBindingsPagedResponse |
listPolicyBindings(com.google.iam.v3beta.OrganizationLocationName parent)
Lists policy bindings.
|
PolicyBindingsClient.ListPolicyBindingsPagedResponse |
listPolicyBindings(String parent)
Lists policy bindings.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.ListPolicyBindingsRequest,com.google.iam.v3beta.ListPolicyBindingsResponse> |
listPolicyBindingsCallable()
Lists policy bindings.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.ListPolicyBindingsRequest,PolicyBindingsClient.ListPolicyBindingsPagedResponse> |
listPolicyBindingsPagedCallable()
Lists policy bindings.
|
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse |
searchTargetPolicyBindings(com.google.iam.v3beta.FolderLocationName parent,
String target)
Search policy bindings by target.
|
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse |
searchTargetPolicyBindings(com.google.iam.v3beta.LocationName parent,
String target)
Search policy bindings by target.
|
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse |
searchTargetPolicyBindings(com.google.iam.v3beta.OrganizationLocationName parent,
String target)
Search policy bindings by target.
|
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse |
searchTargetPolicyBindings(com.google.iam.v3beta.SearchTargetPolicyBindingsRequest request)
Search policy bindings by target.
|
PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse |
searchTargetPolicyBindings(String parent,
String target)
Search policy bindings by target.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.SearchTargetPolicyBindingsRequest,com.google.iam.v3beta.SearchTargetPolicyBindingsResponse> |
searchTargetPolicyBindingsCallable()
Search policy bindings by target.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.SearchTargetPolicyBindingsRequest,PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse> |
searchTargetPolicyBindingsPagedCallable()
Search policy bindings by target.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
updatePolicyBindingAsync(com.google.iam.v3beta.PolicyBinding policyBinding,
com.google.protobuf.FieldMask updateMask)
Updates a policy binding and returns a long-running operation.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
updatePolicyBindingAsync(com.google.iam.v3beta.UpdatePolicyBindingRequest request)
Updates a policy binding and returns a long-running operation.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.UpdatePolicyBindingRequest,com.google.longrunning.Operation> |
updatePolicyBindingCallable()
Updates a policy binding and returns a long-running operation.
|
com.google.api.gax.rpc.OperationCallable<com.google.iam.v3beta.UpdatePolicyBindingRequest,com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> |
updatePolicyBindingOperationCallable()
Updates a policy binding and returns a long-running operation.
|
protected PolicyBindingsClient(PolicyBindingsSettings settings) throws IOException
IOExceptionprotected PolicyBindingsClient(PolicyBindingsStub stub)
public static final PolicyBindingsClient create() throws IOException
IOExceptionpublic static final PolicyBindingsClient create(PolicyBindingsSettings settings) throws IOException
IOExceptionpublic static final PolicyBindingsClient create(PolicyBindingsStub stub)
public final PolicyBindingsSettings getSettings()
public PolicyBindingsStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> createPolicyBindingAsync(com.google.iam.v3beta.FolderLocationName parent,
com.google.iam.v3beta.PolicyBinding policyBinding,
String policyBindingId)
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();
}
parent - 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:
policyBinding - Required. The policy binding to create.policyBindingId - 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][a-z0-9-\\.]{2,62}/.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> createPolicyBindingAsync(com.google.iam.v3beta.LocationName parent,
com.google.iam.v3beta.PolicyBinding policyBinding,
String policyBindingId)
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();
}
parent - 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:
policyBinding - Required. The policy binding to create.policyBindingId - 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][a-z0-9-\\.]{2,62}/.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> createPolicyBindingAsync(com.google.iam.v3beta.OrganizationLocationName parent,
com.google.iam.v3beta.PolicyBinding policyBinding,
String policyBindingId)
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();
}
parent - 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:
policyBinding - Required. The policy binding to create.policyBindingId - 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][a-z0-9-\\.]{2,62}/.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> createPolicyBindingAsync(String parent, com.google.iam.v3beta.PolicyBinding policyBinding, String policyBindingId)
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();
}
parent - 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:
policyBinding - Required. The policy binding to create.policyBindingId - 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][a-z0-9-\\.]{2,62}/.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> createPolicyBindingAsync(com.google.iam.v3beta.CreatePolicyBindingRequest request)
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();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<com.google.iam.v3beta.CreatePolicyBindingRequest,com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> createPolicyBindingOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.CreatePolicyBindingRequest,com.google.longrunning.Operation> createPolicyBindingCallable()
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();
}
public final com.google.iam.v3beta.PolicyBinding getPolicyBinding(com.google.iam.v3beta.PolicyBindingName name)
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);
}
name - Required. The name of the policy binding to retrieve.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v3beta.PolicyBinding getPolicyBinding(String name)
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);
}
name - Required. The name of the policy binding to retrieve.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v3beta.PolicyBinding getPolicyBinding(com.google.iam.v3beta.GetPolicyBindingRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.GetPolicyBindingRequest,com.google.iam.v3beta.PolicyBinding> getPolicyBindingCallable()
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();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> updatePolicyBindingAsync(com.google.iam.v3beta.PolicyBinding policyBinding,
com.google.protobuf.FieldMask updateMask)
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();
}
policyBinding - Required. The policy binding to update.
The policy binding's `name` field is used to identify the policy binding to update.
updateMask - Optional. The list of fields to updatecom.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> updatePolicyBindingAsync(com.google.iam.v3beta.UpdatePolicyBindingRequest request)
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();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<com.google.iam.v3beta.UpdatePolicyBindingRequest,com.google.iam.v3beta.PolicyBinding,com.google.iam.v3beta.OperationMetadata> updatePolicyBindingOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.UpdatePolicyBindingRequest,com.google.longrunning.Operation> updatePolicyBindingCallable()
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();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> deletePolicyBindingAsync(com.google.iam.v3beta.PolicyBindingName name)
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();
}
name - Required. The name of the policy binding to delete.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> deletePolicyBindingAsync(String name)
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();
}
name - Required. The name of the policy binding to delete.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> deletePolicyBindingAsync(com.google.iam.v3beta.DeletePolicyBindingRequest request)
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();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<com.google.iam.v3beta.DeletePolicyBindingRequest,com.google.protobuf.Empty,com.google.iam.v3beta.OperationMetadata> deletePolicyBindingOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.DeletePolicyBindingRequest,com.google.longrunning.Operation> deletePolicyBindingCallable()
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();
}
public final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(com.google.iam.v3beta.FolderLocationName parent)
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);
}
}
parent - Required. The parent resource, which owns the collection of policy bindings.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(com.google.iam.v3beta.LocationName parent)
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);
}
}
parent - Required. The parent resource, which owns the collection of policy bindings.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(com.google.iam.v3beta.OrganizationLocationName parent)
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);
}
}
parent - Required. The parent resource, which owns the collection of policy bindings.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(String parent)
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);
}
}
parent - Required. The parent resource, which owns the collection of policy bindings.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.ListPolicyBindingsPagedResponse listPolicyBindings(com.google.iam.v3beta.ListPolicyBindingsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.ListPolicyBindingsRequest,PolicyBindingsClient.ListPolicyBindingsPagedResponse> listPolicyBindingsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.ListPolicyBindingsRequest,com.google.iam.v3beta.ListPolicyBindingsResponse> listPolicyBindingsCallable()
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;
}
}
}
public final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(com.google.iam.v3beta.FolderLocationName parent, String 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);
}
}
parent - 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:
target - Required. The target resource, which is bound to the policy in the binding.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(com.google.iam.v3beta.LocationName parent, String 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);
}
}
parent - 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:
target - Required. The target resource, which is bound to the policy in the binding.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(com.google.iam.v3beta.OrganizationLocationName parent, String 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);
}
}
parent - 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:
target - Required. The target resource, which is bound to the policy in the binding.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(String parent, String 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);
}
}
parent - 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:
target - Required. The target resource, which is bound to the policy in the binding.
Format:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse searchTargetPolicyBindings(com.google.iam.v3beta.SearchTargetPolicyBindingsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.SearchTargetPolicyBindingsRequest,PolicyBindingsClient.SearchTargetPolicyBindingsPagedResponse> searchTargetPolicyBindingsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v3beta.SearchTargetPolicyBindingsRequest,com.google.iam.v3beta.SearchTargetPolicyBindingsResponse> searchTargetPolicyBindingsCallable()
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;
}
}
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.