| GitHub Repository | Product Reference |
Service Description: Manages Identity and Access Management (IAM) access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
AccessPolicyName name =
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]");
AccessPolicy response = accessPoliciesClient.getAccessPolicy(name);
}
Note: close() needs to be called on the AccessPoliciesClient 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 |
|---|---|---|
CreateAccessPolicy |
Creates an access policy, and returns a long running operation. |
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
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetAccessPolicy |
Gets an access 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.
|
UpdateAccessPolicy |
Updates an access policy. |
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.
|
DeleteAccessPolicy |
Deletes an access 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
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListAccessPolicies |
Lists access policies. |
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.
|
SearchAccessPolicyBindings |
Returns all policy bindings that bind a specific policy if a user has searchPolicyBindings permission on that 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.
|
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 AccessPoliciesSettings 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
AccessPoliciesSettings accessPoliciesSettings =
AccessPoliciesSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create(accessPoliciesSettings);
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
AccessPoliciesSettings accessPoliciesSettings =
AccessPoliciesSettings.newBuilder().setEndpoint(myEndpoint).build();
AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create(accessPoliciesSettings);
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
AccessPoliciesSettings accessPoliciesSettings =
AccessPoliciesSettings.newHttpJsonBuilder().build();
AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create(accessPoliciesSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final AccessPoliciesClient create()Constructs an instance of AccessPoliciesClient with default settings.
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(AccessPoliciesSettings settings)
public static final AccessPoliciesClient create(AccessPoliciesSettings settings)Constructs an instance of AccessPoliciesClient, 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 |
AccessPoliciesSettings |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(AccessPoliciesStub stub)
public static final AccessPoliciesClient create(AccessPoliciesStub stub)Constructs an instance of AccessPoliciesClient, using the given stub for making calls. This is for advanced usage - prefer using create(AccessPoliciesSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
AccessPoliciesStub |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient |
|
Constructors
AccessPoliciesClient(AccessPoliciesSettings settings)
protected AccessPoliciesClient(AccessPoliciesSettings settings)Constructs an instance of AccessPoliciesClient, 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 |
AccessPoliciesSettings |
AccessPoliciesClient(AccessPoliciesStub stub)
protected AccessPoliciesClient(AccessPoliciesStub stub)| Parameter | |
|---|---|
| Name | Description |
stub |
AccessPoliciesStub |
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()createAccessPolicyAsync(CreateAccessPolicyRequest request)
public final OperationFuture<AccessPolicy,OperationMetadata> createAccessPolicyAsync(CreateAccessPolicyRequest request)Creates an access policy, and returns a long running operation.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
CreateAccessPolicyRequest request =
CreateAccessPolicyRequest.newBuilder()
.setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
.setAccessPolicyId("accessPolicyId97623921")
.setAccessPolicy(AccessPolicy.newBuilder().build())
.setValidateOnly(true)
.build();
AccessPolicy response = accessPoliciesClient.createAccessPolicyAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
CreateAccessPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<AccessPolicy,OperationMetadata> |
|
createAccessPolicyAsync(FolderLocationName parent, AccessPolicy accessPolicy, String accessPolicyId)
public final OperationFuture<AccessPolicy,OperationMetadata> createAccessPolicyAsync(FolderLocationName parent, AccessPolicy accessPolicy, String accessPolicyId)Creates an access policy, and returns a long running operation.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
AccessPolicy accessPolicy = AccessPolicy.newBuilder().build();
String accessPolicyId = "accessPolicyId97623921";
AccessPolicy response =
accessPoliciesClient.createAccessPolicyAsync(parent, accessPolicy, accessPolicyId).get();
}
| Parameters | |
|---|---|
| Name | Description |
parent |
FolderLocationNameRequired. The parent resource where this access policy will be created. Format: |
accessPolicy |
AccessPolicyRequired. The access policy to create. |
accessPolicyId |
StringRequired. The ID to use for the access policy, which will become the final component of the access policy'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}/. This value must be unique among all access policies with the same parent. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<AccessPolicy,OperationMetadata> |
|
createAccessPolicyAsync(LocationName parent, AccessPolicy accessPolicy, String accessPolicyId)
public final OperationFuture<AccessPolicy,OperationMetadata> createAccessPolicyAsync(LocationName parent, AccessPolicy accessPolicy, String accessPolicyId)Creates an access policy, and returns a long running operation.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
AccessPolicy accessPolicy = AccessPolicy.newBuilder().build();
String accessPolicyId = "accessPolicyId97623921";
AccessPolicy response =
accessPoliciesClient.createAccessPolicyAsync(parent, accessPolicy, accessPolicyId).get();
}
| Parameters | |
|---|---|
| Name | Description |
parent |
LocationNameRequired. The parent resource where this access policy will be created. Format: |
accessPolicy |
AccessPolicyRequired. The access policy to create. |
accessPolicyId |
StringRequired. The ID to use for the access policy, which will become the final component of the access policy'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}/. This value must be unique among all access policies with the same parent. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<AccessPolicy,OperationMetadata> |
|
createAccessPolicyAsync(OrganizationLocationName parent, AccessPolicy accessPolicy, String accessPolicyId)
public final OperationFuture<AccessPolicy,OperationMetadata> createAccessPolicyAsync(OrganizationLocationName parent, AccessPolicy accessPolicy, String accessPolicyId)Creates an access policy, and returns a long running operation.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
AccessPolicy accessPolicy = AccessPolicy.newBuilder().build();
String accessPolicyId = "accessPolicyId97623921";
AccessPolicy response =
accessPoliciesClient.createAccessPolicyAsync(parent, accessPolicy, accessPolicyId).get();
}
| Parameters | |
|---|---|
| Name | Description |
parent |
OrganizationLocationNameRequired. The parent resource where this access policy will be created. Format: |
accessPolicy |
AccessPolicyRequired. The access policy to create. |
accessPolicyId |
StringRequired. The ID to use for the access policy, which will become the final component of the access policy'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}/. This value must be unique among all access policies with the same parent. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<AccessPolicy,OperationMetadata> |
|
createAccessPolicyAsync(String parent, AccessPolicy accessPolicy, String accessPolicyId)
public final OperationFuture<AccessPolicy,OperationMetadata> createAccessPolicyAsync(String parent, AccessPolicy accessPolicy, String accessPolicyId)Creates an access policy, and returns a long running operation.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
String parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
AccessPolicy accessPolicy = AccessPolicy.newBuilder().build();
String accessPolicyId = "accessPolicyId97623921";
AccessPolicy response =
accessPoliciesClient.createAccessPolicyAsync(parent, accessPolicy, accessPolicyId).get();
}
| Parameters | |
|---|---|
| Name | Description |
parent |
StringRequired. The parent resource where this access policy will be created. Format: |
accessPolicy |
AccessPolicyRequired. The access policy to create. |
accessPolicyId |
StringRequired. The ID to use for the access policy, which will become the final component of the access policy'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}/. This value must be unique among all access policies with the same parent. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<AccessPolicy,OperationMetadata> |
|
createAccessPolicyCallable()
public final UnaryCallable<CreateAccessPolicyRequest,Operation> createAccessPolicyCallable()Creates an access policy, and returns a long running operation.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
CreateAccessPolicyRequest request =
CreateAccessPolicyRequest.newBuilder()
.setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
.setAccessPolicyId("accessPolicyId97623921")
.setAccessPolicy(AccessPolicy.newBuilder().build())
.setValidateOnly(true)
.build();
ApiFuture<Operation> future =
accessPoliciesClient.createAccessPolicyCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<CreateAccessPolicyRequest,Operation> |
|
createAccessPolicyOperationCallable()
public final OperationCallable<CreateAccessPolicyRequest,AccessPolicy,OperationMetadata> createAccessPolicyOperationCallable()Creates an access policy, and returns a long running operation.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
CreateAccessPolicyRequest request =
CreateAccessPolicyRequest.newBuilder()
.setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
.setAccessPolicyId("accessPolicyId97623921")
.setAccessPolicy(AccessPolicy.newBuilder().build())
.setValidateOnly(true)
.build();
OperationFuture<AccessPolicy, OperationMetadata> future =
accessPoliciesClient.createAccessPolicyOperationCallable().futureCall(request);
// Do something.
AccessPolicy response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<CreateAccessPolicyRequest,AccessPolicy,OperationMetadata> |
|
deleteAccessPolicyAsync(AccessPolicyName name)
public final OperationFuture<Empty,OperationMetadata> deleteAccessPolicyAsync(AccessPolicyName name)Deletes an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
AccessPolicyName name =
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]");
accessPoliciesClient.deleteAccessPolicyAsync(name).get();
}
| Parameter | |
|---|---|
| Name | Description |
name |
AccessPolicyNameRequired. The name of the access policy to delete. Format: |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Empty,OperationMetadata> |
|
deleteAccessPolicyAsync(DeleteAccessPolicyRequest request)
public final OperationFuture<Empty,OperationMetadata> deleteAccessPolicyAsync(DeleteAccessPolicyRequest request)Deletes an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
DeleteAccessPolicyRequest request =
DeleteAccessPolicyRequest.newBuilder()
.setName(
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.setEtag("etag3123477")
.setValidateOnly(true)
.setForce(true)
.build();
accessPoliciesClient.deleteAccessPolicyAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
DeleteAccessPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Empty,OperationMetadata> |
|
deleteAccessPolicyAsync(String name)
public final OperationFuture<Empty,OperationMetadata> deleteAccessPolicyAsync(String name)Deletes an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
String name =
AccessPolicyName.ofOrganizationLocationAccessPolicyName(
"[ORGANIZATION]", "[LOCATION]", "[ACCESS_POLICY]")
.toString();
accessPoliciesClient.deleteAccessPolicyAsync(name).get();
}
| Parameter | |
|---|---|
| Name | Description |
name |
StringRequired. The name of the access policy to delete. Format: |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Empty,OperationMetadata> |
|
deleteAccessPolicyCallable()
public final UnaryCallable<DeleteAccessPolicyRequest,Operation> deleteAccessPolicyCallable()Deletes an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
DeleteAccessPolicyRequest request =
DeleteAccessPolicyRequest.newBuilder()
.setName(
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.setEtag("etag3123477")
.setValidateOnly(true)
.setForce(true)
.build();
ApiFuture<Operation> future =
accessPoliciesClient.deleteAccessPolicyCallable().futureCall(request);
// Do something.
future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<DeleteAccessPolicyRequest,Operation> |
|
deleteAccessPolicyOperationCallable()
public final OperationCallable<DeleteAccessPolicyRequest,Empty,OperationMetadata> deleteAccessPolicyOperationCallable()Deletes an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
DeleteAccessPolicyRequest request =
DeleteAccessPolicyRequest.newBuilder()
.setName(
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.setEtag("etag3123477")
.setValidateOnly(true)
.setForce(true)
.build();
OperationFuture<Empty, OperationMetadata> future =
accessPoliciesClient.deleteAccessPolicyOperationCallable().futureCall(request);
// Do something.
future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<DeleteAccessPolicyRequest,Empty,OperationMetadata> |
|
getAccessPolicy(AccessPolicyName name)
public final AccessPolicy getAccessPolicy(AccessPolicyName name)Gets an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
AccessPolicyName name =
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]");
AccessPolicy response = accessPoliciesClient.getAccessPolicy(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
AccessPolicyNameRequired. The name of the access policy to retrieve. Format: |
| Returns | |
|---|---|
| Type | Description |
AccessPolicy |
|
getAccessPolicy(GetAccessPolicyRequest request)
public final AccessPolicy getAccessPolicy(GetAccessPolicyRequest request)Gets an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
GetAccessPolicyRequest request =
GetAccessPolicyRequest.newBuilder()
.setName(
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.build();
AccessPolicy response = accessPoliciesClient.getAccessPolicy(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetAccessPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
AccessPolicy |
|
getAccessPolicy(String name)
public final AccessPolicy getAccessPolicy(String name)Gets an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
String name =
AccessPolicyName.ofOrganizationLocationAccessPolicyName(
"[ORGANIZATION]", "[LOCATION]", "[ACCESS_POLICY]")
.toString();
AccessPolicy response = accessPoliciesClient.getAccessPolicy(name);
}
| Parameter | |
|---|---|
| Name | Description |
name |
StringRequired. The name of the access policy to retrieve. Format: |
| Returns | |
|---|---|
| Type | Description |
AccessPolicy |
|
getAccessPolicyCallable()
public final UnaryCallable<GetAccessPolicyRequest,AccessPolicy> getAccessPolicyCallable()Gets an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
GetAccessPolicyRequest request =
GetAccessPolicyRequest.newBuilder()
.setName(
AccessPolicyName.ofProjectLocationAccessPolicyName(
"[PROJECT]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.build();
ApiFuture<AccessPolicy> future =
accessPoliciesClient.getAccessPolicyCallable().futureCall(request);
// Do something.
AccessPolicy response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetAccessPolicyRequest,AccessPolicy> |
|
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 |
|
getSettings()
public final AccessPoliciesSettings getSettings()| Returns | |
|---|---|
| Type | Description |
AccessPoliciesSettings |
|
getStub()
public AccessPoliciesStub getStub()| Returns | |
|---|---|
| Type | Description |
AccessPoliciesStub |
|
isShutdown()
public boolean isShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
public boolean isTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
listAccessPolicies(FolderLocationName parent)
public final AccessPoliciesClient.ListAccessPoliciesPagedResponse listAccessPolicies(FolderLocationName parent)Lists access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
for (AccessPolicy element : accessPoliciesClient.listAccessPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
FolderLocationNameRequired. The parent resource, which owns the collection of access policy resources. Format: |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.ListAccessPoliciesPagedResponse |
|
listAccessPolicies(ListAccessPoliciesRequest request)
public final AccessPoliciesClient.ListAccessPoliciesPagedResponse listAccessPolicies(ListAccessPoliciesRequest request)Lists access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
ListAccessPoliciesRequest request =
ListAccessPoliciesRequest.newBuilder()
.setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (AccessPolicy element : accessPoliciesClient.listAccessPolicies(request).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListAccessPoliciesRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.ListAccessPoliciesPagedResponse |
|
listAccessPolicies(LocationName parent)
public final AccessPoliciesClient.ListAccessPoliciesPagedResponse listAccessPolicies(LocationName parent)Lists access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (AccessPolicy element : accessPoliciesClient.listAccessPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
LocationNameRequired. The parent resource, which owns the collection of access policy resources. Format: |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.ListAccessPoliciesPagedResponse |
|
listAccessPolicies(OrganizationLocationName parent)
public final AccessPoliciesClient.ListAccessPoliciesPagedResponse listAccessPolicies(OrganizationLocationName parent)Lists access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
for (AccessPolicy element : accessPoliciesClient.listAccessPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
OrganizationLocationNameRequired. The parent resource, which owns the collection of access policy resources. Format: |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.ListAccessPoliciesPagedResponse |
|
listAccessPolicies(String parent)
public final AccessPoliciesClient.ListAccessPoliciesPagedResponse listAccessPolicies(String parent)Lists access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
String parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
for (AccessPolicy element : accessPoliciesClient.listAccessPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
parent |
StringRequired. The parent resource, which owns the collection of access policy resources. Format: |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.ListAccessPoliciesPagedResponse |
|
listAccessPoliciesCallable()
public final UnaryCallable<ListAccessPoliciesRequest,ListAccessPoliciesResponse> listAccessPoliciesCallable()Lists access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
ListAccessPoliciesRequest request =
ListAccessPoliciesRequest.newBuilder()
.setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListAccessPoliciesResponse response =
accessPoliciesClient.listAccessPoliciesCallable().call(request);
for (AccessPolicy element : response.getAccessPoliciesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListAccessPoliciesRequest,ListAccessPoliciesResponse> |
|
listAccessPoliciesPagedCallable()
public final UnaryCallable<ListAccessPoliciesRequest,AccessPoliciesClient.ListAccessPoliciesPagedResponse> listAccessPoliciesPagedCallable()Lists access policies.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
ListAccessPoliciesRequest request =
ListAccessPoliciesRequest.newBuilder()
.setParent(OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<AccessPolicy> future =
accessPoliciesClient.listAccessPoliciesPagedCallable().futureCall(request);
// Do something.
for (AccessPolicy element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListAccessPoliciesRequest,ListAccessPoliciesPagedResponse> |
|
searchAccessPolicyBindings(AccessPolicyName name)
public final AccessPoliciesClient.SearchAccessPolicyBindingsPagedResponse searchAccessPolicyBindings(AccessPolicyName name)Returns all policy bindings that bind a specific policy if a user has searchPolicyBindings permission on that policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
AccessPolicyName name =
AccessPolicyName.ofOrganizationLocationAccessPolicyName(
"[ORGANIZATION]", "[LOCATION]", "[ACCESS_POLICY]");
for (PolicyBinding element :
accessPoliciesClient.searchAccessPolicyBindings(name).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
name |
AccessPolicyNameRequired. The name of the access policy. Format:
|
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.SearchAccessPolicyBindingsPagedResponse |
|
searchAccessPolicyBindings(SearchAccessPolicyBindingsRequest request)
public final AccessPoliciesClient.SearchAccessPolicyBindingsPagedResponse searchAccessPolicyBindings(SearchAccessPolicyBindingsRequest request)Returns all policy bindings that bind a specific policy if a user has searchPolicyBindings permission on that policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
SearchAccessPolicyBindingsRequest request =
SearchAccessPolicyBindingsRequest.newBuilder()
.setName(
AccessPolicyName.ofOrganizationLocationAccessPolicyName(
"[ORGANIZATION]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (PolicyBinding element :
accessPoliciesClient.searchAccessPolicyBindings(request).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
SearchAccessPolicyBindingsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.SearchAccessPolicyBindingsPagedResponse |
|
searchAccessPolicyBindings(String name)
public final AccessPoliciesClient.SearchAccessPolicyBindingsPagedResponse searchAccessPolicyBindings(String name)Returns all policy bindings that bind a specific policy if a user has searchPolicyBindings permission on that policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
String name =
AccessPolicyName.ofOrganizationLocationAccessPolicyName(
"[ORGANIZATION]", "[LOCATION]", "[ACCESS_POLICY]")
.toString();
for (PolicyBinding element :
accessPoliciesClient.searchAccessPolicyBindings(name).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
name |
StringRequired. The name of the access policy. Format:
|
| Returns | |
|---|---|
| Type | Description |
AccessPoliciesClient.SearchAccessPolicyBindingsPagedResponse |
|
searchAccessPolicyBindingsCallable()
public final UnaryCallable<SearchAccessPolicyBindingsRequest,SearchAccessPolicyBindingsResponse> searchAccessPolicyBindingsCallable()Returns all policy bindings that bind a specific policy if a user has searchPolicyBindings permission on that policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
SearchAccessPolicyBindingsRequest request =
SearchAccessPolicyBindingsRequest.newBuilder()
.setName(
AccessPolicyName.ofOrganizationLocationAccessPolicyName(
"[ORGANIZATION]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
SearchAccessPolicyBindingsResponse response =
accessPoliciesClient.searchAccessPolicyBindingsCallable().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<SearchAccessPolicyBindingsRequest,SearchAccessPolicyBindingsResponse> |
|
searchAccessPolicyBindingsPagedCallable()
public final UnaryCallable<SearchAccessPolicyBindingsRequest,AccessPoliciesClient.SearchAccessPolicyBindingsPagedResponse> searchAccessPolicyBindingsPagedCallable()Returns all policy bindings that bind a specific policy if a user has searchPolicyBindings permission on that policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
SearchAccessPolicyBindingsRequest request =
SearchAccessPolicyBindingsRequest.newBuilder()
.setName(
AccessPolicyName.ofOrganizationLocationAccessPolicyName(
"[ORGANIZATION]", "[LOCATION]", "[ACCESS_POLICY]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<PolicyBinding> future =
accessPoliciesClient.searchAccessPolicyBindingsPagedCallable().futureCall(request);
// Do something.
for (PolicyBinding element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SearchAccessPolicyBindingsRequest,SearchAccessPolicyBindingsPagedResponse> |
|
shutdown()
public void shutdown()shutdownNow()
public void shutdownNow()updateAccessPolicyAsync(UpdateAccessPolicyRequest request)
public final OperationFuture<AccessPolicy,OperationMetadata> updateAccessPolicyAsync(UpdateAccessPolicyRequest request)Updates an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
UpdateAccessPolicyRequest request =
UpdateAccessPolicyRequest.newBuilder()
.setAccessPolicy(AccessPolicy.newBuilder().build())
.setValidateOnly(true)
.build();
AccessPolicy response = accessPoliciesClient.updateAccessPolicyAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
UpdateAccessPolicyRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<AccessPolicy,OperationMetadata> |
|
updateAccessPolicyCallable()
public final UnaryCallable<UpdateAccessPolicyRequest,Operation> updateAccessPolicyCallable()Updates an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
UpdateAccessPolicyRequest request =
UpdateAccessPolicyRequest.newBuilder()
.setAccessPolicy(AccessPolicy.newBuilder().build())
.setValidateOnly(true)
.build();
ApiFuture<Operation> future =
accessPoliciesClient.updateAccessPolicyCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<UpdateAccessPolicyRequest,Operation> |
|
updateAccessPolicyOperationCallable()
public final OperationCallable<UpdateAccessPolicyRequest,AccessPolicy,OperationMetadata> updateAccessPolicyOperationCallable()Updates an access policy.
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 (AccessPoliciesClient accessPoliciesClient = AccessPoliciesClient.create()) {
UpdateAccessPolicyRequest request =
UpdateAccessPolicyRequest.newBuilder()
.setAccessPolicy(AccessPolicy.newBuilder().build())
.setValidateOnly(true)
.build();
OperationFuture<AccessPolicy, OperationMetadata> future =
accessPoliciesClient.updateAccessPolicyOperationCallable().futureCall(request);
// Do something.
AccessPolicy response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<UpdateAccessPolicyRequest,AccessPolicy,OperationMetadata> |
|