Class TagHoldsClient

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

    @Generated("by gapic-generator-java")
    public class TagHoldsClient
    extends Object
    implements com.google.api.gax.core.BackgroundResource
    Service Description: Allow users to create and manage TagHolds for TagValues. TagHolds represent the use of a Tag Value that is not captured by TagBindings but should still block TagValue deletion (such as a reference in a policy condition). This service provides isolated failure domains by cloud location so that TagHolds can be managed in the same location as their usage.

    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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
       TagValueName parent = TagValueName.of("[TAG_VALUE]");
       TagHold tagHold = TagHold.newBuilder().build();
       TagHold response = tagHoldsClient.createTagHoldAsync(parent, tagHold).get();
     }
     

    Note: close() needs to be called on the TagHoldsClient 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 TagHoldsSettings 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
     TagHoldsSettings tagHoldsSettings =
         TagHoldsSettings.newBuilder()
             .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
             .build();
     TagHoldsClient tagHoldsClient = TagHoldsClient.create(tagHoldsSettings);
     

    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
     TagHoldsSettings tagHoldsSettings =
         TagHoldsSettings.newBuilder().setEndpoint(myEndpoint).build();
     TagHoldsClient tagHoldsClient = TagHoldsClient.create(tagHoldsSettings);
     

    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
     TagHoldsSettings tagHoldsSettings = TagHoldsSettings.newHttpJsonBuilder().build();
     TagHoldsClient tagHoldsClient = TagHoldsClient.create(tagHoldsSettings);
     

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

    • Constructor Detail

      • TagHoldsClient

        protected TagHoldsClient​(TagHoldsSettings settings)
                          throws IOException
        Constructs an instance of TagHoldsClient, 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
      • TagHoldsClient

        protected TagHoldsClient​(TagHoldsStub stub)
    • Method Detail

      • create

        public static final TagHoldsClient create​(TagHoldsSettings settings)
                                           throws IOException
        Constructs an instance of TagHoldsClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
        Throws:
        IOException
      • create

        public static final TagHoldsClient create​(TagHoldsStub stub)
        Constructs an instance of TagHoldsClient, using the given stub for making calls. This is for advanced usage - prefer using create(TagHoldsSettings).
      • getOperationsClient

        public final com.google.longrunning.OperationsClient getOperationsClient()
        Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
      • getHttpJsonOperationsClient

        @BetaApi
        public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
        Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
      • createTagHoldAsync

        public final com.google.api.gax.longrunning.OperationFuture<TagHold,​CreateTagHoldMetadata> createTagHoldAsync​(TagValueName parent,
                                                                                                                            TagHold tagHold)
        Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           TagValueName parent = TagValueName.of("[TAG_VALUE]");
           TagHold tagHold = TagHold.newBuilder().build();
           TagHold response = tagHoldsClient.createTagHoldAsync(parent, tagHold).get();
         }
         
        Parameters:
        parent - Required. The resource name of the TagHold's parent TagValue. Must be of the form: `tagValues/{tag-value-id}`.
        tagHold - Required. The TagHold to be created.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createTagHoldAsync

        public final com.google.api.gax.longrunning.OperationFuture<TagHold,​CreateTagHoldMetadata> createTagHoldAsync​(String parent,
                                                                                                                            TagHold tagHold)
        Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           String parent = TagValueName.of("[TAG_VALUE]").toString();
           TagHold tagHold = TagHold.newBuilder().build();
           TagHold response = tagHoldsClient.createTagHoldAsync(parent, tagHold).get();
         }
         
        Parameters:
        parent - Required. The resource name of the TagHold's parent TagValue. Must be of the form: `tagValues/{tag-value-id}`.
        tagHold - Required. The TagHold to be created.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • createTagHoldAsync

        public final com.google.api.gax.longrunning.OperationFuture<TagHold,​CreateTagHoldMetadata> createTagHoldAsync​(CreateTagHoldRequest request)
        Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           CreateTagHoldRequest request =
               CreateTagHoldRequest.newBuilder()
                   .setParent(TagValueName.of("[TAG_VALUE]").toString())
                   .setTagHold(TagHold.newBuilder().build())
                   .setValidateOnly(true)
                   .build();
           TagHold response = tagHoldsClient.createTagHoldAsync(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
      • createTagHoldOperationCallable

        public final com.google.api.gax.rpc.OperationCallable<CreateTagHoldRequest,​TagHold,​CreateTagHoldMetadata> createTagHoldOperationCallable()
        Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           CreateTagHoldRequest request =
               CreateTagHoldRequest.newBuilder()
                   .setParent(TagValueName.of("[TAG_VALUE]").toString())
                   .setTagHold(TagHold.newBuilder().build())
                   .setValidateOnly(true)
                   .build();
           OperationFuture<TagHold, CreateTagHoldMetadata> future =
               tagHoldsClient.createTagHoldOperationCallable().futureCall(request);
           // Do something.
           TagHold response = future.get();
         }
         
      • createTagHoldCallable

        public final com.google.api.gax.rpc.UnaryCallable<CreateTagHoldRequest,​com.google.longrunning.Operation> createTagHoldCallable()
        Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           CreateTagHoldRequest request =
               CreateTagHoldRequest.newBuilder()
                   .setParent(TagValueName.of("[TAG_VALUE]").toString())
                   .setTagHold(TagHold.newBuilder().build())
                   .setValidateOnly(true)
                   .build();
           ApiFuture<Operation> future = tagHoldsClient.createTagHoldCallable().futureCall(request);
           // Do something.
           Operation response = future.get();
         }
         
      • deleteTagHoldAsync

        public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,​DeleteTagHoldMetadata> deleteTagHoldAsync​(TagHoldName name)
        Deletes a TagHold.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           TagHoldName name = TagHoldName.of("[TAG_VALUE]", "[TAG_HOLD]");
           tagHoldsClient.deleteTagHoldAsync(name).get();
         }
         
        Parameters:
        name - Required. The resource name of the TagHold to delete. Must be of the form: `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteTagHoldAsync

        public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,​DeleteTagHoldMetadata> deleteTagHoldAsync​(String name)
        Deletes a TagHold.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           String name = TagHoldName.of("[TAG_VALUE]", "[TAG_HOLD]").toString();
           tagHoldsClient.deleteTagHoldAsync(name).get();
         }
         
        Parameters:
        name - Required. The resource name of the TagHold to delete. Must be of the form: `tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • deleteTagHoldAsync

        public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,​DeleteTagHoldMetadata> deleteTagHoldAsync​(DeleteTagHoldRequest request)
        Deletes a TagHold.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           DeleteTagHoldRequest request =
               DeleteTagHoldRequest.newBuilder()
                   .setName(TagHoldName.of("[TAG_VALUE]", "[TAG_HOLD]").toString())
                   .setValidateOnly(true)
                   .build();
           tagHoldsClient.deleteTagHoldAsync(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
      • deleteTagHoldOperationCallable

        public final com.google.api.gax.rpc.OperationCallable<DeleteTagHoldRequest,​com.google.protobuf.Empty,​DeleteTagHoldMetadata> deleteTagHoldOperationCallable()
        Deletes a TagHold.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           DeleteTagHoldRequest request =
               DeleteTagHoldRequest.newBuilder()
                   .setName(TagHoldName.of("[TAG_VALUE]", "[TAG_HOLD]").toString())
                   .setValidateOnly(true)
                   .build();
           OperationFuture<Empty, DeleteTagHoldMetadata> future =
               tagHoldsClient.deleteTagHoldOperationCallable().futureCall(request);
           // Do something.
           future.get();
         }
         
      • deleteTagHoldCallable

        public final com.google.api.gax.rpc.UnaryCallable<DeleteTagHoldRequest,​com.google.longrunning.Operation> deleteTagHoldCallable()
        Deletes a TagHold.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           DeleteTagHoldRequest request =
               DeleteTagHoldRequest.newBuilder()
                   .setName(TagHoldName.of("[TAG_VALUE]", "[TAG_HOLD]").toString())
                   .setValidateOnly(true)
                   .build();
           ApiFuture<Operation> future = tagHoldsClient.deleteTagHoldCallable().futureCall(request);
           // Do something.
           future.get();
         }
         
      • listTagHolds

        public final TagHoldsClient.ListTagHoldsPagedResponse listTagHolds​(TagValueName parent)
        Lists TagHolds under a TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           TagValueName parent = TagValueName.of("[TAG_VALUE]");
           for (TagHold element : tagHoldsClient.listTagHolds(parent).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        parent - Required. The resource name of the parent TagValue. Must be of the form: `tagValues/{tag-value-id}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTagHolds

        public final TagHoldsClient.ListTagHoldsPagedResponse listTagHolds​(String parent)
        Lists TagHolds under a TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           String parent = TagValueName.of("[TAG_VALUE]").toString();
           for (TagHold element : tagHoldsClient.listTagHolds(parent).iterateAll()) {
             // doThingsWith(element);
           }
         }
         
        Parameters:
        parent - Required. The resource name of the parent TagValue. Must be of the form: `tagValues/{tag-value-id}`.
        Throws:
        com.google.api.gax.rpc.ApiException - if the remote call fails
      • listTagHolds

        public final TagHoldsClient.ListTagHoldsPagedResponse listTagHolds​(ListTagHoldsRequest request)
        Lists TagHolds under a TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           ListTagHoldsRequest request =
               ListTagHoldsRequest.newBuilder()
                   .setParent(TagValueName.of("[TAG_VALUE]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .setFilter("filter-1274492040")
                   .build();
           for (TagHold element : tagHoldsClient.listTagHolds(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
      • listTagHoldsPagedCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTagHoldsRequest,​TagHoldsClient.ListTagHoldsPagedResponse> listTagHoldsPagedCallable()
        Lists TagHolds under a TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           ListTagHoldsRequest request =
               ListTagHoldsRequest.newBuilder()
                   .setParent(TagValueName.of("[TAG_VALUE]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .setFilter("filter-1274492040")
                   .build();
           ApiFuture<TagHold> future = tagHoldsClient.listTagHoldsPagedCallable().futureCall(request);
           // Do something.
           for (TagHold element : future.get().iterateAll()) {
             // doThingsWith(element);
           }
         }
         
      • listTagHoldsCallable

        public final com.google.api.gax.rpc.UnaryCallable<ListTagHoldsRequest,​ListTagHoldsResponse> listTagHoldsCallable()
        Lists TagHolds under a TagValue.

        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 (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
           ListTagHoldsRequest request =
               ListTagHoldsRequest.newBuilder()
                   .setParent(TagValueName.of("[TAG_VALUE]").toString())
                   .setPageSize(883849137)
                   .setPageToken("pageToken873572522")
                   .setFilter("filter-1274492040")
                   .build();
           while (true) {
             ListTagHoldsResponse response = tagHoldsClient.listTagHoldsCallable().call(request);
             for (TagHold element : response.getTagHoldsList()) {
               // doThingsWith(element);
             }
             String nextPageToken = response.getNextPageToken();
             if (!Strings.isNullOrEmpty(nextPageToken)) {
               request = request.toBuilder().setPageToken(nextPageToken).build();
             } else {
               break;
             }
           }
         }
         
      • 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