@BetaApi @Generated(value="by gapic-generator-java") public class PoliciesClient 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
String name = "name3373707";
Policy response = policiesClient.getPolicy(name);
}
Note: close() needs to be called on the PoliciesClient 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 |
|---|---|---|
ListPolicies |
Retrieves the policies of the specified kind that are attached to a resource. The response lists only policy metadata. In particular, policy rules are omitted. |
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.
|
GetPolicy |
Gets a policy. |
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.
|
CreatePolicy |
Creates a policy. |
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.
|
UpdatePolicy |
Updates the specified policy. You can update only the rules and the display name for the policy. To update a policy, you should use a read-modify-write loop: 1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. This pattern helps prevent conflicts between concurrent updates. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeletePolicy |
Deletes a policy. This action is permanent. |
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.
|
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 PoliciesSettings 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
PoliciesSettings policiesSettings =
PoliciesSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
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
PoliciesSettings policiesSettings =
PoliciesSettings.newBuilder().setEndpoint(myEndpoint).build();
PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
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
PoliciesSettings policiesSettings = PoliciesSettings.newHttpJsonBuilder().build();
PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
PoliciesClient.ListPoliciesFixedSizeCollection |
static class |
PoliciesClient.ListPoliciesPage |
static class |
PoliciesClient.ListPoliciesPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
PoliciesClient(PoliciesSettings settings)
Constructs an instance of PoliciesClient, using the given settings.
|
protected |
PoliciesClient(PoliciesStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static PoliciesClient |
create()
Constructs an instance of PoliciesClient with default settings.
|
static PoliciesClient |
create(PoliciesSettings settings)
Constructs an instance of PoliciesClient, using the given settings.
|
static PoliciesClient |
create(PoliciesStub stub)
Constructs an instance of PoliciesClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
createPolicyAsync(com.google.iam.v2beta.CreatePolicyRequest request)
Creates a policy.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
createPolicyAsync(String parent,
com.google.iam.v2beta.Policy policy,
String policyId)
Creates a policy.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.CreatePolicyRequest,com.google.longrunning.Operation> |
createPolicyCallable()
Creates a policy.
|
com.google.api.gax.rpc.OperationCallable<com.google.iam.v2beta.CreatePolicyRequest,com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
createPolicyOperationCallable()
Creates a policy.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
deletePolicyAsync(com.google.iam.v2beta.DeletePolicyRequest request)
Deletes a policy.
|
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
deletePolicyAsync(String name)
Deletes a policy.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.DeletePolicyRequest,com.google.longrunning.Operation> |
deletePolicyCallable()
Deletes a policy.
|
com.google.api.gax.rpc.OperationCallable<com.google.iam.v2beta.DeletePolicyRequest,com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
deletePolicyOperationCallable()
Deletes a policy.
|
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.v2beta.Policy |
getPolicy(com.google.iam.v2beta.GetPolicyRequest request)
Gets a policy.
|
com.google.iam.v2beta.Policy |
getPolicy(String name)
Gets a policy.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.GetPolicyRequest,com.google.iam.v2beta.Policy> |
getPolicyCallable()
Gets a policy.
|
PoliciesSettings |
getSettings() |
PoliciesStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
PoliciesClient.ListPoliciesPagedResponse |
listPolicies(com.google.iam.v2beta.ListPoliciesRequest request)
Retrieves the policies of the specified kind that are attached to a resource.
|
PoliciesClient.ListPoliciesPagedResponse |
listPolicies(String parent)
Retrieves the policies of the specified kind that are attached to a resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.ListPoliciesRequest,com.google.iam.v2beta.ListPoliciesResponse> |
listPoliciesCallable()
Retrieves the policies of the specified kind that are attached to a resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.ListPoliciesRequest,PoliciesClient.ListPoliciesPagedResponse> |
listPoliciesPagedCallable()
Retrieves the policies of the specified kind that are attached to a resource.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
updatePolicyAsync(com.google.iam.v2beta.UpdatePolicyRequest request)
Updates the specified policy.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.UpdatePolicyRequest,com.google.longrunning.Operation> |
updatePolicyCallable()
Updates the specified policy.
|
com.google.api.gax.rpc.OperationCallable<com.google.iam.v2beta.UpdatePolicyRequest,com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> |
updatePolicyOperationCallable()
Updates the specified policy.
|
protected PoliciesClient(PoliciesSettings settings) throws IOException
IOExceptionprotected PoliciesClient(PoliciesStub stub)
public static final PoliciesClient create() throws IOException
IOExceptionpublic static final PoliciesClient create(PoliciesSettings settings) throws IOException
IOExceptionpublic static final PoliciesClient create(PoliciesStub stub)
public final PoliciesSettings getSettings()
public PoliciesStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final PoliciesClient.ListPoliciesPagedResponse listPolicies(String parent)
The response lists only policy metadata. In particular, policy rules are omitted.
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
String parent = "parent-995424086";
for (Policy element : policiesClient.listPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The resource that the policy is attached to, along with the kind of
policy to list. Format: `policies/{attachment_point}/denypolicies`
The attachment point is identified by its URL-encoded full resource name, which means that the forward-slash character, `/`, must be written as `%2F`. For example, `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final PoliciesClient.ListPoliciesPagedResponse listPolicies(com.google.iam.v2beta.ListPoliciesRequest request)
The response lists only policy metadata. In particular, policy rules are omitted.
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
ListPoliciesRequest request =
ListPoliciesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Policy element : policiesClient.listPolicies(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.v2beta.ListPoliciesRequest,PoliciesClient.ListPoliciesPagedResponse> listPoliciesPagedCallable()
The response lists only policy metadata. In particular, policy rules are omitted.
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
ListPoliciesRequest request =
ListPoliciesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Policy> future = policiesClient.listPoliciesPagedCallable().futureCall(request);
// Do something.
for (Policy element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.ListPoliciesRequest,com.google.iam.v2beta.ListPoliciesResponse> listPoliciesCallable()
The response lists only policy metadata. In particular, policy rules are omitted.
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
ListPoliciesRequest request =
ListPoliciesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListPoliciesResponse response = policiesClient.listPoliciesCallable().call(request);
for (Policy element : response.getPoliciesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.iam.v2beta.Policy getPolicy(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 (PoliciesClient policiesClient = PoliciesClient.create()) {
String name = "name3373707";
Policy response = policiesClient.getPolicy(name);
}
name - Required. The resource name of the policy to retrieve. Format:
`policies/{attachment_point}/denypolicies/{policy_id}`
Use the URL-encoded full resource name, which means that the forward-slash character, `/`, must be written as `%2F`. For example, `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.iam.v2beta.Policy getPolicy(com.google.iam.v2beta.GetPolicyRequest 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build();
Policy response = policiesClient.getPolicy(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.v2beta.GetPolicyRequest,com.google.iam.v2beta.Policy> getPolicyCallable()
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build();
ApiFuture<Policy> future = policiesClient.getPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> createPolicyAsync(String parent, com.google.iam.v2beta.Policy policy, String policyId)
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
String parent = "parent-995424086";
Policy policy = Policy.newBuilder().build();
String policyId = "policyId546908653";
Policy response = policiesClient.createPolicyAsync(parent, policy, policyId).get();
}
parent - Required. The resource that the policy is attached to, along with the kind of
policy to create. Format: `policies/{attachment_point}/denypolicies`
The attachment point is identified by its URL-encoded full resource name, which means that the forward-slash character, `/`, must be written as `%2F`. For example, `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
policy - Required. The policy to create.policyId - The ID to use for this policy, which will become the final component of the
policy's resource name. The ID must contain 3 to 63 characters. It can contain lowercase
letters and numbers, as well as dashes (`-`) and periods (`.`). The first character must be
a lowercase letter.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> createPolicyAsync(com.google.iam.v2beta.CreatePolicyRequest 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
CreatePolicyRequest request =
CreatePolicyRequest.newBuilder()
.setParent("parent-995424086")
.setPolicy(Policy.newBuilder().build())
.setPolicyId("policyId546908653")
.build();
Policy response = policiesClient.createPolicyAsync(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.v2beta.CreatePolicyRequest,com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> createPolicyOperationCallable()
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
CreatePolicyRequest request =
CreatePolicyRequest.newBuilder()
.setParent("parent-995424086")
.setPolicy(Policy.newBuilder().build())
.setPolicyId("policyId546908653")
.build();
OperationFuture<Policy, PolicyOperationMetadata> future =
policiesClient.createPolicyOperationCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.CreatePolicyRequest,com.google.longrunning.Operation> createPolicyCallable()
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
CreatePolicyRequest request =
CreatePolicyRequest.newBuilder()
.setParent("parent-995424086")
.setPolicy(Policy.newBuilder().build())
.setPolicyId("policyId546908653")
.build();
ApiFuture<Operation> future = policiesClient.createPolicyCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> updatePolicyAsync(com.google.iam.v2beta.UpdatePolicyRequest request)
You can update only the rules and the display name for the policy.
To update a policy, you should use a read-modify-write loop:
1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy.
This pattern helps prevent conflicts between concurrent updates.
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
UpdatePolicyRequest request =
UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
Policy response = policiesClient.updatePolicyAsync(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.v2beta.UpdatePolicyRequest,com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> updatePolicyOperationCallable()
You can update only the rules and the display name for the policy.
To update a policy, you should use a read-modify-write loop:
1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy.
This pattern helps prevent conflicts between concurrent updates.
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
UpdatePolicyRequest request =
UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
OperationFuture<Policy, PolicyOperationMetadata> future =
policiesClient.updatePolicyOperationCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.UpdatePolicyRequest,com.google.longrunning.Operation> updatePolicyCallable()
You can update only the rules and the display name for the policy.
To update a policy, you should use a read-modify-write loop:
1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy.
This pattern helps prevent conflicts between concurrent updates.
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
UpdatePolicyRequest request =
UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
ApiFuture<Operation> future = policiesClient.updatePolicyCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> deletePolicyAsync(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 (PoliciesClient policiesClient = PoliciesClient.create()) {
String name = "name3373707";
Policy response = policiesClient.deletePolicyAsync(name).get();
}
name - Required. The resource name of the policy to delete. Format:
`policies/{attachment_point}/denypolicies/{policy_id}`
Use the URL-encoded full resource name, which means that the forward-slash character, `/`, must be written as `%2F`. For example, `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
For organizations and folders, use the numeric ID in the full resource name. For projects, you can use the alphanumeric or the numeric ID.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> deletePolicyAsync(com.google.iam.v2beta.DeletePolicyRequest 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
DeletePolicyRequest request =
DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
Policy response = policiesClient.deletePolicyAsync(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.v2beta.DeletePolicyRequest,com.google.iam.v2beta.Policy,com.google.iam.v2beta.PolicyOperationMetadata> deletePolicyOperationCallable()
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
DeletePolicyRequest request =
DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
OperationFuture<Policy, PolicyOperationMetadata> future =
policiesClient.deletePolicyOperationCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v2beta.DeletePolicyRequest,com.google.longrunning.Operation> deletePolicyCallable()
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 (PoliciesClient policiesClient = PoliciesClient.create()) {
DeletePolicyRequest request =
DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
ApiFuture<Operation> future = policiesClient.deletePolicyCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
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.