@Generated(value="by gapic-generator-java") public class TagHoldsClient extends Object implements com.google.api.gax.core.BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// 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().
| Method | Description | Method 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.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteTagHold |
Deletes a TagHold. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListTagHolds |
Lists TagHolds under a TagValue. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
TagHoldsClient.ListTagHoldsFixedSizeCollection |
static class |
TagHoldsClient.ListTagHoldsPage |
static class |
TagHoldsClient.ListTagHoldsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
TagHoldsClient(TagHoldsSettings settings)
Constructs an instance of TagHoldsClient, using the given settings.
|
protected |
TagHoldsClient(TagHoldsStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static TagHoldsClient |
create()
Constructs an instance of TagHoldsClient with default settings.
|
static TagHoldsClient |
create(TagHoldsSettings settings)
Constructs an instance of TagHoldsClient, using the given settings.
|
static TagHoldsClient |
create(TagHoldsStub stub)
Constructs an instance of TagHoldsClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<TagHold,CreateTagHoldMetadata> |
createTagHoldAsync(CreateTagHoldRequest request)
Creates a TagHold.
|
com.google.api.gax.longrunning.OperationFuture<TagHold,CreateTagHoldMetadata> |
createTagHoldAsync(String parent,
TagHold tagHold)
Creates a TagHold.
|
com.google.api.gax.longrunning.OperationFuture<TagHold,CreateTagHoldMetadata> |
createTagHoldAsync(TagValueName parent,
TagHold tagHold)
Creates a TagHold.
|
com.google.api.gax.rpc.UnaryCallable<CreateTagHoldRequest,com.google.longrunning.Operation> |
createTagHoldCallable()
Creates a TagHold.
|
com.google.api.gax.rpc.OperationCallable<CreateTagHoldRequest,TagHold,CreateTagHoldMetadata> |
createTagHoldOperationCallable()
Creates a TagHold.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteTagHoldMetadata> |
deleteTagHoldAsync(DeleteTagHoldRequest request)
Deletes a TagHold.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteTagHoldMetadata> |
deleteTagHoldAsync(String name)
Deletes a TagHold.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteTagHoldMetadata> |
deleteTagHoldAsync(TagHoldName name)
Deletes a TagHold.
|
com.google.api.gax.rpc.UnaryCallable<DeleteTagHoldRequest,com.google.longrunning.Operation> |
deleteTagHoldCallable()
Deletes a TagHold.
|
com.google.api.gax.rpc.OperationCallable<DeleteTagHoldRequest,com.google.protobuf.Empty,DeleteTagHoldMetadata> |
deleteTagHoldOperationCallable()
Deletes a TagHold.
|
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.
|
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.
|
TagHoldsSettings |
getSettings() |
TagHoldsStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
TagHoldsClient.ListTagHoldsPagedResponse |
listTagHolds(ListTagHoldsRequest request)
Lists TagHolds under a TagValue.
|
TagHoldsClient.ListTagHoldsPagedResponse |
listTagHolds(String parent)
Lists TagHolds under a TagValue.
|
TagHoldsClient.ListTagHoldsPagedResponse |
listTagHolds(TagValueName parent)
Lists TagHolds under a TagValue.
|
com.google.api.gax.rpc.UnaryCallable<ListTagHoldsRequest,ListTagHoldsResponse> |
listTagHoldsCallable()
Lists TagHolds under a TagValue.
|
com.google.api.gax.rpc.UnaryCallable<ListTagHoldsRequest,TagHoldsClient.ListTagHoldsPagedResponse> |
listTagHoldsPagedCallable()
Lists TagHolds under a TagValue.
|
void |
shutdown() |
void |
shutdownNow() |
protected TagHoldsClient(TagHoldsSettings settings) throws IOException
IOExceptionprotected TagHoldsClient(TagHoldsStub stub)
public static final TagHoldsClient create() throws IOException
IOExceptionpublic static final TagHoldsClient create(TagHoldsSettings settings) throws IOException
IOExceptionpublic static final TagHoldsClient create(TagHoldsStub stub)
public final TagHoldsSettings getSettings()
public TagHoldsStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<TagHold,CreateTagHoldMetadata> createTagHoldAsync(TagValueName parent, TagHold 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()) {
TagValueName parent = TagValueName.of("[TAG_VALUE]");
TagHold tagHold = TagHold.newBuilder().build();
TagHold response = tagHoldsClient.createTagHoldAsync(parent, tagHold).get();
}
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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<TagHold,CreateTagHoldMetadata> createTagHoldAsync(String parent, TagHold 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 parent = TagValueName.of("[TAG_VALUE]").toString();
TagHold tagHold = TagHold.newBuilder().build();
TagHold response = tagHoldsClient.createTagHoldAsync(parent, tagHold).get();
}
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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<TagHold,CreateTagHoldMetadata> createTagHoldAsync(CreateTagHoldRequest request)
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();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<CreateTagHoldRequest,TagHold,CreateTagHoldMetadata> createTagHoldOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<CreateTagHoldRequest,com.google.longrunning.Operation> createTagHoldCallable()
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();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteTagHoldMetadata> deleteTagHoldAsync(TagHoldName name)
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();
}
name - Required. The resource name of the TagHold to delete. Must be of the form:
`tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteTagHoldMetadata> deleteTagHoldAsync(String name)
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();
}
name - Required. The resource name of the TagHold to delete. Must be of the form:
`tagValues/{tag-value-id}/tagHolds/{tag-hold-id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteTagHoldMetadata> deleteTagHoldAsync(DeleteTagHoldRequest request)
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();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<DeleteTagHoldRequest,com.google.protobuf.Empty,DeleteTagHoldMetadata> deleteTagHoldOperationCallable()
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();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteTagHoldRequest,com.google.longrunning.Operation> deleteTagHoldCallable()
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();
}
public final TagHoldsClient.ListTagHoldsPagedResponse listTagHolds(TagValueName parent)
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);
}
}
parent - Required. The resource name of the parent TagValue. Must be of the form:
`tagValues/{tag-value-id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final TagHoldsClient.ListTagHoldsPagedResponse listTagHolds(String parent)
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);
}
}
parent - Required. The resource name of the parent TagValue. Must be of the form:
`tagValues/{tag-value-id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final TagHoldsClient.ListTagHoldsPagedResponse listTagHolds(ListTagHoldsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListTagHoldsRequest,TagHoldsClient.ListTagHoldsPagedResponse> listTagHoldsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListTagHoldsRequest,ListTagHoldsResponse> listTagHoldsCallable()
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;
}
}
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.