@Generated(value="by gapic-generator") @BetaApi public class ResourcePolicyClient 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:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyName resourcePolicy = ProjectRegionResourcePolicyName.of("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
Operation response = resourcePolicyClient.deleteResourcePolicy(resourcePolicy);
}
Note: close() needs to be called on the resourcePolicyClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
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 ResourcePolicySettings to create(). For example:
To customize credentials:
ResourcePolicySettings resourcePolicySettings =
ResourcePolicySettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ResourcePolicyClient resourcePolicyClient =
ResourcePolicyClient.create(resourcePolicySettings);
To customize the endpoint:
ResourcePolicySettings resourcePolicySettings =
ResourcePolicySettings.newBuilder().setEndpoint(myEndpoint).build();
ResourcePolicyClient resourcePolicyClient =
ResourcePolicyClient.create(resourcePolicySettings);
Modifier and Type | Class and Description |
---|---|
static class |
ResourcePolicyClient.AggregatedListResourcePoliciesFixedSizeCollection |
static class |
ResourcePolicyClient.AggregatedListResourcePoliciesPage |
static class |
ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse |
static class |
ResourcePolicyClient.ListResourcePoliciesFixedSizeCollection |
static class |
ResourcePolicyClient.ListResourcePoliciesPage |
static class |
ResourcePolicyClient.ListResourcePoliciesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ResourcePolicyClient(ResourcePolicySettings settings)
Constructs an instance of ResourcePolicyClient, using the given settings.
|
protected |
ResourcePolicyClient(ResourcePolicyStub stub) |
Modifier and Type | Method and Description |
---|---|
ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse |
aggregatedListResourcePolicies(AggregatedListResourcePoliciesHttpRequest request)
Retrieves an aggregated list of resource policies.
|
ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse |
aggregatedListResourcePolicies(ProjectName project)
Retrieves an aggregated list of resource policies.
|
ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse |
aggregatedListResourcePolicies(String project)
Retrieves an aggregated list of resource policies.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListResourcePoliciesHttpRequest,ResourcePolicyAggregatedList> |
aggregatedListResourcePoliciesCallable()
Retrieves an aggregated list of resource policies.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListResourcePoliciesHttpRequest,ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse> |
aggregatedListResourcePoliciesPagedCallable()
Retrieves an aggregated list of resource policies.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ResourcePolicyClient |
create()
Constructs an instance of ResourcePolicyClient with default settings.
|
static ResourcePolicyClient |
create(ResourcePolicySettings settings)
Constructs an instance of ResourcePolicyClient, using the given settings.
|
static ResourcePolicyClient |
create(ResourcePolicyStub stub)
Constructs an instance of ResourcePolicyClient, using the given stub for making calls.
|
Operation |
deleteResourcePolicy(DeleteResourcePolicyHttpRequest request)
Deletes the specified resource policy.
|
Operation |
deleteResourcePolicy(ProjectRegionResourcePolicyName resourcePolicy)
Deletes the specified resource policy.
|
Operation |
deleteResourcePolicy(String resourcePolicy)
Deletes the specified resource policy.
|
com.google.api.gax.rpc.UnaryCallable<DeleteResourcePolicyHttpRequest,Operation> |
deleteResourcePolicyCallable()
Deletes the specified resource policy.
|
Policy |
getIamPolicyResourcePolicy(GetIamPolicyResourcePolicyHttpRequest request)
Gets the access control policy for a resource.
|
Policy |
getIamPolicyResourcePolicy(ProjectRegionResourcePolicyResourceName resource)
Gets the access control policy for a resource.
|
Policy |
getIamPolicyResourcePolicy(String resource)
Gets the access control policy for a resource.
|
com.google.api.gax.rpc.UnaryCallable<GetIamPolicyResourcePolicyHttpRequest,Policy> |
getIamPolicyResourcePolicyCallable()
Gets the access control policy for a resource.
|
ResourcePolicy |
getResourcePolicy(GetResourcePolicyHttpRequest request)
Retrieves all information of the specified resource policy.
|
ResourcePolicy |
getResourcePolicy(ProjectRegionResourcePolicyName resourcePolicy)
Retrieves all information of the specified resource policy.
|
ResourcePolicy |
getResourcePolicy(String resourcePolicy)
Retrieves all information of the specified resource policy.
|
com.google.api.gax.rpc.UnaryCallable<GetResourcePolicyHttpRequest,ResourcePolicy> |
getResourcePolicyCallable()
Retrieves all information of the specified resource policy.
|
ResourcePolicySettings |
getSettings() |
ResourcePolicyStub |
getStub() |
Operation |
insertResourcePolicy(InsertResourcePolicyHttpRequest request)
Creates a new resource policy.
|
Operation |
insertResourcePolicy(ProjectRegionName region,
ResourcePolicy resourcePolicyResource)
Creates a new resource policy.
|
Operation |
insertResourcePolicy(String region,
ResourcePolicy resourcePolicyResource)
Creates a new resource policy.
|
com.google.api.gax.rpc.UnaryCallable<InsertResourcePolicyHttpRequest,Operation> |
insertResourcePolicyCallable()
Creates a new resource policy.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
ResourcePolicyClient.ListResourcePoliciesPagedResponse |
listResourcePolicies(ListResourcePoliciesHttpRequest request)
A list all the resource policies that have been configured for the specified project in
specified region.
|
ResourcePolicyClient.ListResourcePoliciesPagedResponse |
listResourcePolicies(ProjectRegionName region)
A list all the resource policies that have been configured for the specified project in
specified region.
|
ResourcePolicyClient.ListResourcePoliciesPagedResponse |
listResourcePolicies(String region)
A list all the resource policies that have been configured for the specified project in
specified region.
|
com.google.api.gax.rpc.UnaryCallable<ListResourcePoliciesHttpRequest,ResourcePolicyList> |
listResourcePoliciesCallable()
A list all the resource policies that have been configured for the specified project in
specified region.
|
com.google.api.gax.rpc.UnaryCallable<ListResourcePoliciesHttpRequest,ResourcePolicyClient.ListResourcePoliciesPagedResponse> |
listResourcePoliciesPagedCallable()
A list all the resource policies that have been configured for the specified project in
specified region.
|
Policy |
setIamPolicyResourcePolicy(ProjectRegionResourcePolicyResourceName resource,
RegionSetPolicyRequest regionSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicyResourcePolicy(SetIamPolicyResourcePolicyHttpRequest request)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicyResourcePolicy(String resource,
RegionSetPolicyRequest regionSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<SetIamPolicyResourcePolicyHttpRequest,Policy> |
setIamPolicyResourcePolicyCallable()
Sets the access control policy on the specified resource.
|
void |
shutdown() |
void |
shutdownNow() |
TestPermissionsResponse |
testIamPermissionsResourcePolicy(ProjectRegionResourcePolicyResourceName resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsResourcePolicy(String resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsResourcePolicy(TestIamPermissionsResourcePolicyHttpRequest request)
Returns permissions that a caller has on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsResourcePolicyHttpRequest,TestPermissionsResponse> |
testIamPermissionsResourcePolicyCallable()
Returns permissions that a caller has on the specified resource.
|
protected ResourcePolicyClient(ResourcePolicySettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ResourcePolicyClient(ResourcePolicyStub stub)
public static final ResourcePolicyClient create() throws IOException
IOException
public static final ResourcePolicyClient create(ResourcePolicySettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ResourcePolicyClient create(ResourcePolicyStub stub)
public final ResourcePolicySettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ResourcePolicyStub getStub()
@BetaApi public final ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse aggregatedListResourcePolicies(ProjectName project)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (ResourcePoliciesScopedList element : resourcePolicyClient.aggregatedListResourcePolicies(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse aggregatedListResourcePolicies(String project)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (ResourcePoliciesScopedList element : resourcePolicyClient.aggregatedListResourcePolicies(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse aggregatedListResourcePolicies(AggregatedListResourcePoliciesHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListResourcePoliciesHttpRequest request = AggregatedListResourcePoliciesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (ResourcePoliciesScopedList element : resourcePolicyClient.aggregatedListResourcePolicies(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 fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListResourcePoliciesHttpRequest,ResourcePolicyClient.AggregatedListResourcePoliciesPagedResponse> aggregatedListResourcePoliciesPagedCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListResourcePoliciesHttpRequest request = AggregatedListResourcePoliciesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListResourcePoliciesPagedResponse> future = resourcePolicyClient.aggregatedListResourcePoliciesPagedCallable().futureCall(request);
// Do something
for (ResourcePoliciesScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListResourcePoliciesHttpRequest,ResourcePolicyAggregatedList> aggregatedListResourcePoliciesCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListResourcePoliciesHttpRequest request = AggregatedListResourcePoliciesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
ResourcePolicyAggregatedList response = resourcePolicyClient.aggregatedListResourcePoliciesCallable().call(request);
for (ResourcePoliciesScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation deleteResourcePolicy(ProjectRegionResourcePolicyName resourcePolicy)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyName resourcePolicy = ProjectRegionResourcePolicyName.of("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
Operation response = resourcePolicyClient.deleteResourcePolicy(resourcePolicy);
}
resourcePolicy
- Name of the resource policy to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteResourcePolicy(String resourcePolicy)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyName resourcePolicy = ProjectRegionResourcePolicyName.of("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
Operation response = resourcePolicyClient.deleteResourcePolicy(resourcePolicy.toString());
}
resourcePolicy
- Name of the resource policy to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteResourcePolicy(DeleteResourcePolicyHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResourcePolicy = ProjectRegionResourcePolicyName.format("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
DeleteResourcePolicyHttpRequest request = DeleteResourcePolicyHttpRequest.newBuilder()
.setResourcePolicy(formattedResourcePolicy)
.build();
Operation response = resourcePolicyClient.deleteResourcePolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<DeleteResourcePolicyHttpRequest,Operation> deleteResourcePolicyCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResourcePolicy = ProjectRegionResourcePolicyName.format("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
DeleteResourcePolicyHttpRequest request = DeleteResourcePolicyHttpRequest.newBuilder()
.setResourcePolicy(formattedResourcePolicy)
.build();
ApiFuture<Operation> future = resourcePolicyClient.deleteResourcePolicyCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final ResourcePolicy getResourcePolicy(ProjectRegionResourcePolicyName resourcePolicy)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyName resourcePolicy = ProjectRegionResourcePolicyName.of("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
ResourcePolicy response = resourcePolicyClient.getResourcePolicy(resourcePolicy);
}
resourcePolicy
- Name of the resource policy to retrieve.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ResourcePolicy getResourcePolicy(String resourcePolicy)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyName resourcePolicy = ProjectRegionResourcePolicyName.of("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
ResourcePolicy response = resourcePolicyClient.getResourcePolicy(resourcePolicy.toString());
}
resourcePolicy
- Name of the resource policy to retrieve.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ResourcePolicy getResourcePolicy(GetResourcePolicyHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResourcePolicy = ProjectRegionResourcePolicyName.format("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
GetResourcePolicyHttpRequest request = GetResourcePolicyHttpRequest.newBuilder()
.setResourcePolicy(formattedResourcePolicy)
.build();
ResourcePolicy response = resourcePolicyClient.getResourcePolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<GetResourcePolicyHttpRequest,ResourcePolicy> getResourcePolicyCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResourcePolicy = ProjectRegionResourcePolicyName.format("[PROJECT]", "[REGION]", "[RESOURCE_POLICY]");
GetResourcePolicyHttpRequest request = GetResourcePolicyHttpRequest.newBuilder()
.setResourcePolicy(formattedResourcePolicy)
.build();
ApiFuture<ResourcePolicy> future = resourcePolicyClient.getResourcePolicyCallable().futureCall(request);
// Do something
ResourcePolicy response = future.get();
}
@BetaApi public final Policy getIamPolicyResourcePolicy(ProjectRegionResourcePolicyResourceName resource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyResourceName resource = ProjectRegionResourcePolicyResourceName.of("[PROJECT]", "[REGION]", "[RESOURCE]");
Policy response = resourcePolicyClient.getIamPolicyResourcePolicy(resource);
}
resource
- Name or id of the resource for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicyResourcePolicy(String resource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyResourceName resource = ProjectRegionResourcePolicyResourceName.of("[PROJECT]", "[REGION]", "[RESOURCE]");
Policy response = resourcePolicyClient.getIamPolicyResourcePolicy(resource.toString());
}
resource
- Name or id of the resource for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicyResourcePolicy(GetIamPolicyResourcePolicyHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResource = ProjectRegionResourcePolicyResourceName.format("[PROJECT]", "[REGION]", "[RESOURCE]");
GetIamPolicyResourcePolicyHttpRequest request = GetIamPolicyResourcePolicyHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
Policy response = resourcePolicyClient.getIamPolicyResourcePolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<GetIamPolicyResourcePolicyHttpRequest,Policy> getIamPolicyResourcePolicyCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResource = ProjectRegionResourcePolicyResourceName.format("[PROJECT]", "[REGION]", "[RESOURCE]");
GetIamPolicyResourcePolicyHttpRequest request = GetIamPolicyResourcePolicyHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
ApiFuture<Policy> future = resourcePolicyClient.getIamPolicyResourcePolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final Operation insertResourcePolicy(ProjectRegionName region, ResourcePolicy resourcePolicyResource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
ResourcePolicy resourcePolicyResource = ResourcePolicy.newBuilder().build();
Operation response = resourcePolicyClient.insertResourcePolicy(region, resourcePolicyResource);
}
region
- Name of the region for this request.resourcePolicyResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertResourcePolicy(String region, ResourcePolicy resourcePolicyResource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
ResourcePolicy resourcePolicyResource = ResourcePolicy.newBuilder().build();
Operation response = resourcePolicyClient.insertResourcePolicy(region.toString(), resourcePolicyResource);
}
region
- Name of the region for this request.resourcePolicyResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertResourcePolicy(InsertResourcePolicyHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ResourcePolicy resourcePolicyResource = ResourcePolicy.newBuilder().build();
InsertResourcePolicyHttpRequest request = InsertResourcePolicyHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setResourcePolicyResource(resourcePolicyResource)
.build();
Operation response = resourcePolicyClient.insertResourcePolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<InsertResourcePolicyHttpRequest,Operation> insertResourcePolicyCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ResourcePolicy resourcePolicyResource = ResourcePolicy.newBuilder().build();
InsertResourcePolicyHttpRequest request = InsertResourcePolicyHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setResourcePolicyResource(resourcePolicyResource)
.build();
ApiFuture<Operation> future = resourcePolicyClient.insertResourcePolicyCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final ResourcePolicyClient.ListResourcePoliciesPagedResponse listResourcePolicies(ProjectRegionName region)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (ResourcePolicy element : resourcePolicyClient.listResourcePolicies(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ResourcePolicyClient.ListResourcePoliciesPagedResponse listResourcePolicies(String region)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (ResourcePolicy element : resourcePolicyClient.listResourcePolicies(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ResourcePolicyClient.ListResourcePoliciesPagedResponse listResourcePolicies(ListResourcePoliciesHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListResourcePoliciesHttpRequest request = ListResourcePoliciesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (ResourcePolicy element : resourcePolicyClient.listResourcePolicies(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 fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListResourcePoliciesHttpRequest,ResourcePolicyClient.ListResourcePoliciesPagedResponse> listResourcePoliciesPagedCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListResourcePoliciesHttpRequest request = ListResourcePoliciesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListResourcePoliciesPagedResponse> future = resourcePolicyClient.listResourcePoliciesPagedCallable().futureCall(request);
// Do something
for (ResourcePolicy element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListResourcePoliciesHttpRequest,ResourcePolicyList> listResourcePoliciesCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListResourcePoliciesHttpRequest request = ListResourcePoliciesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
ResourcePolicyList response = resourcePolicyClient.listResourcePoliciesCallable().call(request);
for (ResourcePolicy element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Policy setIamPolicyResourcePolicy(ProjectRegionResourcePolicyResourceName resource, RegionSetPolicyRequest regionSetPolicyRequestResource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyResourceName resource = ProjectRegionResourcePolicyResourceName.of("[PROJECT]", "[REGION]", "[RESOURCE]");
RegionSetPolicyRequest regionSetPolicyRequestResource = RegionSetPolicyRequest.newBuilder().build();
Policy response = resourcePolicyClient.setIamPolicyResourcePolicy(resource, regionSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.regionSetPolicyRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicyResourcePolicy(String resource, RegionSetPolicyRequest regionSetPolicyRequestResource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyResourceName resource = ProjectRegionResourcePolicyResourceName.of("[PROJECT]", "[REGION]", "[RESOURCE]");
RegionSetPolicyRequest regionSetPolicyRequestResource = RegionSetPolicyRequest.newBuilder().build();
Policy response = resourcePolicyClient.setIamPolicyResourcePolicy(resource.toString(), regionSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.regionSetPolicyRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicyResourcePolicy(SetIamPolicyResourcePolicyHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResource = ProjectRegionResourcePolicyResourceName.format("[PROJECT]", "[REGION]", "[RESOURCE]");
RegionSetPolicyRequest regionSetPolicyRequestResource = RegionSetPolicyRequest.newBuilder().build();
SetIamPolicyResourcePolicyHttpRequest request = SetIamPolicyResourcePolicyHttpRequest.newBuilder()
.setResource(formattedResource)
.setRegionSetPolicyRequestResource(regionSetPolicyRequestResource)
.build();
Policy response = resourcePolicyClient.setIamPolicyResourcePolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<SetIamPolicyResourcePolicyHttpRequest,Policy> setIamPolicyResourcePolicyCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResource = ProjectRegionResourcePolicyResourceName.format("[PROJECT]", "[REGION]", "[RESOURCE]");
RegionSetPolicyRequest regionSetPolicyRequestResource = RegionSetPolicyRequest.newBuilder().build();
SetIamPolicyResourcePolicyHttpRequest request = SetIamPolicyResourcePolicyHttpRequest.newBuilder()
.setResource(formattedResource)
.setRegionSetPolicyRequestResource(regionSetPolicyRequestResource)
.build();
ApiFuture<Policy> future = resourcePolicyClient.setIamPolicyResourcePolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final TestPermissionsResponse testIamPermissionsResourcePolicy(ProjectRegionResourcePolicyResourceName resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyResourceName resource = ProjectRegionResourcePolicyResourceName.of("[PROJECT]", "[REGION]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = resourcePolicyClient.testIamPermissionsResourcePolicy(resource, testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsResourcePolicy(String resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
ProjectRegionResourcePolicyResourceName resource = ProjectRegionResourcePolicyResourceName.of("[PROJECT]", "[REGION]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = resourcePolicyClient.testIamPermissionsResourcePolicy(resource.toString(), testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsResourcePolicy(TestIamPermissionsResourcePolicyHttpRequest request)
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResource = ProjectRegionResourcePolicyResourceName.format("[PROJECT]", "[REGION]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsResourcePolicyHttpRequest request = TestIamPermissionsResourcePolicyHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
TestPermissionsResponse response = resourcePolicyClient.testIamPermissionsResourcePolicy(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsResourcePolicyHttpRequest,TestPermissionsResponse> testIamPermissionsResourcePolicyCallable()
Sample code:
try (ResourcePolicyClient resourcePolicyClient = ResourcePolicyClient.create()) {
String formattedResource = ProjectRegionResourcePolicyResourceName.format("[PROJECT]", "[REGION]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsResourcePolicyHttpRequest request = TestIamPermissionsResourcePolicyHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
ApiFuture<TestPermissionsResponse> future = resourcePolicyClient.testIamPermissionsResourcePolicyCallable().futureCall(request);
// Do something
TestPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.