Class TagHoldsClient (1.39.0)

GitHub RepositoryProduct Reference

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().

Methods
MethodDescriptionMethod Variants

CreateTagHold

Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same resource and origin exists under the same TagValue.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createTagHoldAsync(CreateTagHoldRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • createTagHoldAsync(TagValueName parent, TagHold tagHold)

  • createTagHoldAsync(String parent, TagHold tagHold)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createTagHoldOperationCallable()

  • createTagHoldCallable()

DeleteTagHold

Deletes a TagHold.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteTagHoldAsync(DeleteTagHoldRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deleteTagHoldAsync(TagHoldName name)

  • deleteTagHoldAsync(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteTagHoldOperationCallable()

  • deleteTagHoldCallable()

ListTagHolds

Lists TagHolds under a TagValue.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listTagHolds(ListTagHoldsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listTagHolds(TagValueName parent)

  • listTagHolds(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listTagHoldsPagedCallable()

  • listTagHoldsCallable()

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.

Inheritance

java.lang.Object > TagHoldsClient

Static Methods

create()

public static final TagHoldsClient create()

Constructs an instance of TagHoldsClient with default settings.

Returns
TypeDescription
TagHoldsClient
Exceptions
TypeDescription
IOException

create(TagHoldsSettings settings)

public static final TagHoldsClient create(TagHoldsSettings settings)

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.

Parameter
NameDescription
settingsTagHoldsSettings
Returns
TypeDescription
TagHoldsClient
Exceptions
TypeDescription
IOException

create(TagHoldsStub stub)

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).

Parameter
NameDescription
stubTagHoldsStub
Returns
TypeDescription
TagHoldsClient

Constructors

TagHoldsClient(TagHoldsSettings settings)

protected TagHoldsClient(TagHoldsSettings settings)

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.

Parameter
NameDescription
settingsTagHoldsSettings

TagHoldsClient(TagHoldsStub stub)

protected TagHoldsClient(TagHoldsStub stub)
Parameter
NameDescription
stubTagHoldsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createTagHoldAsync(CreateTagHoldRequest request)

public final 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();
 }
 
Parameter
NameDescription
requestCreateTagHoldRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<TagHold,CreateTagHoldMetadata>

createTagHoldAsync(TagValueName parent, TagHold tagHold)

public final 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
NameDescription
parentTagValueName

Required. The resource name of the TagHold's parent TagValue. Must be of the form: tagValues/{tag-value-id}.

tagHoldTagHold

Required. The TagHold to be created.

Returns
TypeDescription
OperationFuture<TagHold,CreateTagHoldMetadata>

createTagHoldAsync(String parent, TagHold tagHold)

public final 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
NameDescription
parentString

Required. The resource name of the TagHold's parent TagValue. Must be of the form: tagValues/{tag-value-id}.

tagHoldTagHold

Required. The TagHold to be created.

Returns
TypeDescription
OperationFuture<TagHold,CreateTagHoldMetadata>

createTagHoldCallable()

public final UnaryCallable<CreateTagHoldRequest,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();
 }
 
Returns
TypeDescription
UnaryCallable<CreateTagHoldRequest,Operation>

createTagHoldOperationCallable()

public final 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();
 }
 
Returns
TypeDescription
OperationCallable<CreateTagHoldRequest,TagHold,CreateTagHoldMetadata>

deleteTagHoldAsync(DeleteTagHoldRequest request)

public final OperationFuture<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();
 }
 
Parameter
NameDescription
requestDeleteTagHoldRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Empty,DeleteTagHoldMetadata>

deleteTagHoldAsync(TagHoldName name)

public final OperationFuture<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();
 }
 
Parameter
NameDescription
nameTagHoldName

Required. The resource name of the TagHold to delete. Must be of the form: tagValues/{tag-value-id}/tagHolds/{tag-hold-id}.

Returns
TypeDescription
OperationFuture<Empty,DeleteTagHoldMetadata>

deleteTagHoldAsync(String name)

public final OperationFuture<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();
 }
 
Parameter
NameDescription
nameString

Required. The resource name of the TagHold to delete. Must be of the form: tagValues/{tag-value-id}/tagHolds/{tag-hold-id}.

Returns
TypeDescription
OperationFuture<Empty,DeleteTagHoldMetadata>

deleteTagHoldCallable()

public final UnaryCallable<DeleteTagHoldRequest,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();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteTagHoldRequest,Operation>

deleteTagHoldOperationCallable()

public final OperationCallable<DeleteTagHoldRequest,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();
 }
 
Returns
TypeDescription
OperationCallable<DeleteTagHoldRequest,Empty,DeleteTagHoldMetadata>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getSettings()

public final TagHoldsSettings getSettings()
Returns
TypeDescription
TagHoldsSettings

getStub()

public TagHoldsStub getStub()
Returns
TypeDescription
TagHoldsStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listTagHolds(ListTagHoldsRequest request)

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);
   }
 }
 
Parameter
NameDescription
requestListTagHoldsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
TagHoldsClient.ListTagHoldsPagedResponse

listTagHolds(TagValueName parent)

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);
   }
 }
 
Parameter
NameDescription
parentTagValueName

Required. The resource name of the parent TagValue. Must be of the form: tagValues/{tag-value-id}.

Returns
TypeDescription
TagHoldsClient.ListTagHoldsPagedResponse

listTagHolds(String parent)

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);
   }
 }
 
Parameter
NameDescription
parentString

Required. The resource name of the parent TagValue. Must be of the form: tagValues/{tag-value-id}.

Returns
TypeDescription
TagHoldsClient.ListTagHoldsPagedResponse

listTagHoldsCallable()

public final 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;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListTagHoldsRequest,ListTagHoldsResponse>

listTagHoldsPagedCallable()

public final 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);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListTagHoldsRequest,ListTagHoldsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()