Class ResourcePoliciesClient

  • All Implemented Interfaces:
    com.google.api.gax.core.BackgroundResource, AutoCloseable

    @Generated("by gapic-generator-java")
    public class ResourcePoliciesClient
    extends Object
    implements com.google.api.gax.core.BackgroundResource
    Service Description: The ResourcePolicies API.

    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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
       String project = "project-309310695";
       String region = "region-934795532";
       String resourcePolicy = "resourcePolicy-130903328";
       ResourcePolicy response = resourcePoliciesClient.get(project, region, resourcePolicy);
     }
     

    Note: close() needs to be called on the ResourcePoliciesClient 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:

    1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
    2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
    3. A "callable" method. This type of method takes no parameters and returns 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 ResourcePoliciesSettings 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
     ResourcePoliciesSettings resourcePoliciesSettings =
         ResourcePoliciesSettings.newBuilder()
             .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
             .build();
     ResourcePoliciesClient resourcePoliciesClient =
         ResourcePoliciesClient.create(resourcePoliciesSettings);
     

    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
     ResourcePoliciesSettings resourcePoliciesSettings =
         ResourcePoliciesSettings.newBuilder().setEndpoint(myEndpoint).build();
     ResourcePoliciesClient resourcePoliciesClient =
         ResourcePoliciesClient.create(resourcePoliciesSettings);
     

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

    • Constructor Detail

      • ResourcePoliciesClient

        protected ResourcePoliciesClient​(ResourcePoliciesSettings settings)
                                  throws IOException
        Constructs an instance of ResourcePoliciesClient, 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.
        Throws:
        IOException
    • Method Detail

      • create

        public static final ResourcePoliciesClient create​(ResourcePoliciesStub stub)
        Constructs an instance of ResourcePoliciesClient, using the given stub for making calls. This is for advanced usage - prefer using create(ResourcePoliciesSettings).
      • aggregatedList

        public final ResourcePoliciesClient.AggregatedListPagedResponse aggregatedList​(String project)
        Retrieves an aggregated list of resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           for (Map.Entry<String, ResourcePoliciesScopedList> element :
               resourcePoliciesClient.aggregatedList(project).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        project - Project ID for this request.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • aggregatedList

        public final ResourcePoliciesClient.AggregatedListPagedResponse aggregatedList​(AggregatedListResourcePoliciesRequest request)
        Retrieves an aggregated list of resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           AggregatedListResourcePoliciesRequest request =
               AggregatedListResourcePoliciesRequest.newBuilder()
                   .setFilter("filter-1274492040")
                   .setIncludeAllScopes(true)
                   .setMaxResults(1128457243)
                   .setOrderBy("orderBy-1207110587")
                   .setPageToken("pageToken873572522")
                   .setProject("project-309310695")
                   .setReturnPartialSuccess(true)
                   .build();
           for (Map.Entry<String, ResourcePoliciesScopedList> element :
               resourcePoliciesClient.aggregatedList(request).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • aggregatedListPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<AggregatedListResourcePoliciesRequest,​ResourcePoliciesClient.AggregatedListPagedResponse> aggregatedListPagedCallable()
        Retrieves an aggregated list of resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           AggregatedListResourcePoliciesRequest request =
               AggregatedListResourcePoliciesRequest.newBuilder()
                   .setFilter("filter-1274492040")
                   .setIncludeAllScopes(true)
                   .setMaxResults(1128457243)
                   .setOrderBy("orderBy-1207110587")
                   .setPageToken("pageToken873572522")
                   .setProject("project-309310695")
                   .setReturnPartialSuccess(true)
                   .build();
           ApiFuture<Map.Entry<String, ResourcePoliciesScopedList>> future =
               resourcePoliciesClient.aggregatedListPagedCallable().futureCall(request);
           // Do something.
           for (Map.Entry<String, ResourcePoliciesScopedList> element : future.get().iterateAll()) {
             // doThingsWith(element);
           }
         }
         
      • aggregatedListCallable

        public final com.google.api.gax.rpc.UnaryCallable<AggregatedListResourcePoliciesRequest,​ResourcePolicyAggregatedList> aggregatedListCallable()
        Retrieves an aggregated list of resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           AggregatedListResourcePoliciesRequest request =
               AggregatedListResourcePoliciesRequest.newBuilder()
                   .setFilter("filter-1274492040")
                   .setIncludeAllScopes(true)
                   .setMaxResults(1128457243)
                   .setOrderBy("orderBy-1207110587")
                   .setPageToken("pageToken873572522")
                   .setProject("project-309310695")
                   .setReturnPartialSuccess(true)
                   .build();
           while (true) {
             ResourcePolicyAggregatedList response =
                 resourcePoliciesClient.aggregatedListCallable().call(request);
             for (Map.Entry<String, ResourcePoliciesScopedList> element : response.getItemsList()) {
               // doThingsWith(element);
             }
             String nextPageToken = response.getNextPageToken();
             if (!Strings.isNullOrEmpty(nextPageToken)) {
               request = request.toBuilder().setPageToken(nextPageToken).build();
             } else {
               break;
             }
           }
         }
         
      • deleteAsync

        public final com.google.api.gax.longrunning.OperationFuture<Operation,​Operation> deleteAsync​(String project,
                                                                                                           String region,
                                                                                                           String resourcePolicy)
        Deletes the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           String resourcePolicy = "resourcePolicy-130903328";
           Operation response =
               resourcePoliciesClient.deleteAsync(project, region, resourcePolicy).get();
         }
         
        Parameters:
        project - Project ID for this request.
        region - Name of the region for this request.
        resourcePolicy - Name of the resource policy to delete.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteAsync

        @BetaApi("The surface for long-running operations is not stable yet and may change in the future.")
        public final com.google.api.gax.longrunning.OperationFuture<Operation,​Operation> deleteAsync​(DeleteResourcePolicyRequest request)
        Deletes the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           DeleteResourcePolicyRequest request =
               DeleteResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .build();
           Operation response = resourcePoliciesClient.deleteAsync(request).get();
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteOperationCallable

        public final com.google.api.gax.rpc.OperationCallable<DeleteResourcePolicyRequest,​Operation,​Operation> deleteOperationCallable()
        Deletes the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           DeleteResourcePolicyRequest request =
               DeleteResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .build();
           OperationFuture<Operation, Operation> future =
               resourcePoliciesClient.deleteOperationCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • deleteCallable

        public final com.google.api.gax.rpc.UnaryCallable<DeleteResourcePolicyRequest,​Operation> deleteCallable()
        Deletes the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           DeleteResourcePolicyRequest request =
               DeleteResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .build();
           ApiFuture<Operation> future = resourcePoliciesClient.deleteCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • get

        public final ResourcePolicy get​(String project,
                                        String region,
                                        String resourcePolicy)
        Retrieves all information of the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           String resourcePolicy = "resourcePolicy-130903328";
           ResourcePolicy response = resourcePoliciesClient.get(project, region, resourcePolicy);
         }
         
        Parameters:
        project - Project ID for this request.
        region - Name of the region for this request.
        resourcePolicy - Name of the resource policy to retrieve.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • get

        public final ResourcePolicy get​(GetResourcePolicyRequest request)
        Retrieves all information of the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           GetResourcePolicyRequest request =
               GetResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .build();
           ResourcePolicy response = resourcePoliciesClient.get(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getCallable

        public final com.google.api.gax.rpc.UnaryCallable<GetResourcePolicyRequest,​ResourcePolicy> getCallable()
        Retrieves all information of the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           GetResourcePolicyRequest request =
               GetResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .build();
           ApiFuture<ResourcePolicy> future = resourcePoliciesClient.getCallable().futureCall(request);
           // Do something.
           ResourcePolicy response = future.get();
         }
         
      • getIamPolicy

        public final Policy getIamPolicy​(String project,
                                         String region,
                                         String resource)
        Gets the access control policy for a resource. May be empty if no such policy or resource exists.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           String resource = "resource-341064690";
           Policy response = resourcePoliciesClient.getIamPolicy(project, region, resource);
         }
         
        Parameters:
        project - Project ID for this request.
        region - The name of the region for this request.
        resource - Name or id of the resource for this request.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getIamPolicy

        public final Policy getIamPolicy​(GetIamPolicyResourcePolicyRequest request)
        Gets the access control policy for a resource. May be empty if no such policy or resource exists.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           GetIamPolicyResourcePolicyRequest request =
               GetIamPolicyResourcePolicyRequest.newBuilder()
                   .setOptionsRequestedPolicyVersion(-574521795)
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setResource("resource-341064690")
                   .build();
           Policy response = resourcePoliciesClient.getIamPolicy(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • getIamPolicyCallable

        public final com.google.api.gax.rpc.UnaryCallable<GetIamPolicyResourcePolicyRequest,​Policy> getIamPolicyCallable()
        Gets the access control policy for a resource. May be empty if no such policy or resource exists.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           GetIamPolicyResourcePolicyRequest request =
               GetIamPolicyResourcePolicyRequest.newBuilder()
                   .setOptionsRequestedPolicyVersion(-574521795)
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setResource("resource-341064690")
                   .build();
           ApiFuture<Policy> future = resourcePoliciesClient.getIamPolicyCallable().futureCall(request);
           // Do something.
           Policy response = future.get();
         }
         
      • insertAsync

        public final com.google.api.gax.longrunning.OperationFuture<Operation,​Operation> insertAsync​(String project,
                                                                                                           String region,
                                                                                                           ResourcePolicy resourcePolicyResource)
        Creates a new resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           ResourcePolicy resourcePolicyResource = ResourcePolicy.newBuilder().build();
           Operation response =
               resourcePoliciesClient.insertAsync(project, region, resourcePolicyResource).get();
         }
         
        Parameters:
        project - Project ID for this request.
        region - Name of the region for this request.
        resourcePolicyResource - The body resource for this request
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • insertAsync

        @BetaApi("The surface for long-running operations is not stable yet and may change in the future.")
        public final com.google.api.gax.longrunning.OperationFuture<Operation,​Operation> insertAsync​(InsertResourcePolicyRequest request)
        Creates a new resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           InsertResourcePolicyRequest request =
               InsertResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicyResource(ResourcePolicy.newBuilder().build())
                   .build();
           Operation response = resourcePoliciesClient.insertAsync(request).get();
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • insertOperationCallable

        public final com.google.api.gax.rpc.OperationCallable<InsertResourcePolicyRequest,​Operation,​Operation> insertOperationCallable()
        Creates a new resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           InsertResourcePolicyRequest request =
               InsertResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicyResource(ResourcePolicy.newBuilder().build())
                   .build();
           OperationFuture<Operation, Operation> future =
               resourcePoliciesClient.insertOperationCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • insertCallable

        public final com.google.api.gax.rpc.UnaryCallable<InsertResourcePolicyRequest,​Operation> insertCallable()
        Creates a new resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           InsertResourcePolicyRequest request =
               InsertResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicyResource(ResourcePolicy.newBuilder().build())
                   .build();
           ApiFuture<Operation> future = resourcePoliciesClient.insertCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • list

        public final ResourcePoliciesClient.ListPagedResponse list​(String project,
                                                                   String region)
        A list all the resource policies that have been configured for the specified project in specified region.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           for (ResourcePolicy element : resourcePoliciesClient.list(project, region).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        project - Project ID for this request.
        region - Name of the region for this request.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • list

        public final ResourcePoliciesClient.ListPagedResponse list​(ListResourcePoliciesRequest request)
        A list all the resource policies that have been configured for the specified project in specified region.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           ListResourcePoliciesRequest request =
               ListResourcePoliciesRequest.newBuilder()
                   .setFilter("filter-1274492040")
                   .setMaxResults(1128457243)
                   .setOrderBy("orderBy-1207110587")
                   .setPageToken("pageToken873572522")
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setReturnPartialSuccess(true)
                   .build();
           for (ResourcePolicy element : resourcePoliciesClient.list(request).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListResourcePoliciesRequest,​ResourcePoliciesClient.ListPagedResponse> listPagedCallable()
        A list all the resource policies that have been configured for the specified project in specified region.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           ListResourcePoliciesRequest request =
               ListResourcePoliciesRequest.newBuilder()
                   .setFilter("filter-1274492040")
                   .setMaxResults(1128457243)
                   .setOrderBy("orderBy-1207110587")
                   .setPageToken("pageToken873572522")
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setReturnPartialSuccess(true)
                   .build();
           ApiFuture<ResourcePolicy> future =
               resourcePoliciesClient.listPagedCallable().futureCall(request);
           // Do something.
           for (ResourcePolicy element : future.get().iterateAll()) {
             // doThingsWith(element);
           }
         }
         
      • listCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListResourcePoliciesRequest,​ResourcePolicyList> listCallable()
        A list all the resource policies that have been configured for the specified project in specified region.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           ListResourcePoliciesRequest request =
               ListResourcePoliciesRequest.newBuilder()
                   .setFilter("filter-1274492040")
                   .setMaxResults(1128457243)
                   .setOrderBy("orderBy-1207110587")
                   .setPageToken("pageToken873572522")
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setReturnPartialSuccess(true)
                   .build();
           while (true) {
             ResourcePolicyList response = resourcePoliciesClient.listCallable().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;
             }
           }
         }
         
      • patchAsync

        public final com.google.api.gax.longrunning.OperationFuture<Operation,​Operation> patchAsync​(String project,
                                                                                                          String region,
                                                                                                          String resourcePolicy,
                                                                                                          ResourcePolicy resourcePolicyResource)
        Modify the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           String resourcePolicy = "resourcePolicy-130903328";
           ResourcePolicy resourcePolicyResource = ResourcePolicy.newBuilder().build();
           Operation response =
               resourcePoliciesClient
                   .patchAsync(project, region, resourcePolicy, resourcePolicyResource)
                   .get();
         }
         
        Parameters:
        project - Project ID for this request.
        region - Name of the region for this request.
        resourcePolicy - Id of the resource policy to patch.
        resourcePolicyResource - The body resource for this request
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • patchAsync

        @BetaApi("The surface for long-running operations is not stable yet and may change in the future.")
        public final com.google.api.gax.longrunning.OperationFuture<Operation,​Operation> patchAsync​(PatchResourcePolicyRequest request)
        Modify the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           PatchResourcePolicyRequest request =
               PatchResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .setResourcePolicyResource(ResourcePolicy.newBuilder().build())
                   .setUpdateMask("updateMask-296147115")
                   .build();
           Operation response = resourcePoliciesClient.patchAsync(request).get();
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • patchOperationCallable

        public final com.google.api.gax.rpc.OperationCallable<PatchResourcePolicyRequest,​Operation,​Operation> patchOperationCallable()
        Modify the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           PatchResourcePolicyRequest request =
               PatchResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .setResourcePolicyResource(ResourcePolicy.newBuilder().build())
                   .setUpdateMask("updateMask-296147115")
                   .build();
           OperationFuture<Operation, Operation> future =
               resourcePoliciesClient.patchOperationCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • patchCallable

        public final com.google.api.gax.rpc.UnaryCallable<PatchResourcePolicyRequest,​Operation> patchCallable()
        Modify the specified resource 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           PatchResourcePolicyRequest request =
               PatchResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRequestId("requestId693933066")
                   .setResourcePolicy("resourcePolicy-130903328")
                   .setResourcePolicyResource(ResourcePolicy.newBuilder().build())
                   .setUpdateMask("updateMask-296147115")
                   .build();
           ApiFuture<Operation> future = resourcePoliciesClient.patchCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • setIamPolicy

        public final Policy setIamPolicy​(String project,
                                         String region,
                                         String resource,
                                         RegionSetPolicyRequest regionSetPolicyRequestResource)
        Sets the access control policy on the specified resource. Replaces any existing 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           String resource = "resource-341064690";
           RegionSetPolicyRequest regionSetPolicyRequestResource =
               RegionSetPolicyRequest.newBuilder().build();
           Policy response =
               resourcePoliciesClient.setIamPolicy(
                   project, region, resource, regionSetPolicyRequestResource);
         }
         
        Parameters:
        project - Project ID for this request.
        region - The name of the region for this request.
        resource - Name or id of the resource for this request.
        regionSetPolicyRequestResource - The body resource for this request
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • setIamPolicy

        public final Policy setIamPolicy​(SetIamPolicyResourcePolicyRequest request)
        Sets the access control policy on the specified resource. Replaces any existing 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           SetIamPolicyResourcePolicyRequest request =
               SetIamPolicyResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
                   .setResource("resource-341064690")
                   .build();
           Policy response = resourcePoliciesClient.setIamPolicy(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • setIamPolicyCallable

        public final com.google.api.gax.rpc.UnaryCallable<SetIamPolicyResourcePolicyRequest,​Policy> setIamPolicyCallable()
        Sets the access control policy on the specified resource. Replaces any existing 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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           SetIamPolicyResourcePolicyRequest request =
               SetIamPolicyResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
                   .setResource("resource-341064690")
                   .build();
           ApiFuture<Policy> future = resourcePoliciesClient.setIamPolicyCallable().futureCall(request);
           // Do something.
           Policy response = future.get();
         }
         
      • testIamPermissions

        public final TestPermissionsResponse testIamPermissions​(String project,
                                                                String region,
                                                                String resource,
                                                                TestPermissionsRequest testPermissionsRequestResource)
        Returns permissions that a caller has on the specified resource.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           String project = "project-309310695";
           String region = "region-934795532";
           String resource = "resource-341064690";
           TestPermissionsRequest testPermissionsRequestResource =
               TestPermissionsRequest.newBuilder().build();
           TestPermissionsResponse response =
               resourcePoliciesClient.testIamPermissions(
                   project, region, resource, testPermissionsRequestResource);
         }
         
        Parameters:
        project - Project ID for this request.
        region - The name of the region for this request.
        resource - Name or id of the resource for this request.
        testPermissionsRequestResource - The body resource for this request
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • testIamPermissions

        public final TestPermissionsResponse testIamPermissions​(TestIamPermissionsResourcePolicyRequest request)
        Returns permissions that a caller has on the specified resource.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           TestIamPermissionsResourcePolicyRequest request =
               TestIamPermissionsResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setResource("resource-341064690")
                   .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
                   .build();
           TestPermissionsResponse response = resourcePoliciesClient.testIamPermissions(request);
         }
         
        Parameters:
        request - The request object containing all of the parameters for the API call.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • testIamPermissionsCallable

        public final com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsResourcePolicyRequest,​TestPermissionsResponse> testIamPermissionsCallable()
        Returns permissions that a caller has on the specified resource.

        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 (ResourcePoliciesClient resourcePoliciesClient = ResourcePoliciesClient.create()) {
           TestIamPermissionsResourcePolicyRequest request =
               TestIamPermissionsResourcePolicyRequest.newBuilder()
                   .setProject("project-309310695")
                   .setRegion("region-934795532")
                   .setResource("resource-341064690")
                   .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
                   .build();
           ApiFuture<TestPermissionsResponse> future =
               resourcePoliciesClient.testIamPermissionsCallable().futureCall(request);
           // Do something.
           TestPermissionsResponse response = future.get();
         }
         
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface com.google.api.gax.core.BackgroundResource
      • isShutdown

        public boolean isShutdown()
        Specified by:
        isShutdown in interface com.google.api.gax.core.BackgroundResource
      • isTerminated

        public boolean isTerminated()
        Specified by:
        isTerminated in interface com.google.api.gax.core.BackgroundResource
      • shutdownNow

        public void shutdownNow()
        Specified by:
        shutdownNow in interface com.google.api.gax.core.BackgroundResource