Class CustomTargetingValueServiceClient (0.11.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling CustomTargetingValue objects.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   CustomTargetingValueName name =
       CustomTargetingValueName.of(
           "[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]", "[CUSTOM_TARGETING_VALUE]");
   CustomTargetingValue response =
       customTargetingValueServiceClient.getCustomTargetingValue(name);
 }
 

Note: close() needs to be called on the CustomTargetingValueServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

GetCustomTargetingValue

API to retrieve a CustomTargetingValue object.

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

  • getCustomTargetingValue(GetCustomTargetingValueRequest request)

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

  • getCustomTargetingValue(CustomTargetingValueName name)

  • getCustomTargetingValue(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.

  • getCustomTargetingValueCallable()

ListCustomTargetingValues

API to retrieve a list of CustomTargetingValue objects.

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

  • listCustomTargetingValues(ListCustomTargetingValuesRequest request)

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

  • listCustomTargetingValues(CustomTargetingKeyName parent)

  • listCustomTargetingValues(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.

  • listCustomTargetingValuesPagedCallable()

  • listCustomTargetingValuesCallable()

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 CustomTargetingValueServiceSettings 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
 CustomTargetingValueServiceSettings customTargetingValueServiceSettings =
     CustomTargetingValueServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create(customTargetingValueServiceSettings);
 

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
 CustomTargetingValueServiceSettings customTargetingValueServiceSettings =
     CustomTargetingValueServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create(customTargetingValueServiceSettings);
 

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

Inheritance

java.lang.Object > CustomTargetingValueServiceClient

Static Methods

create()

public static final CustomTargetingValueServiceClient create()

Constructs an instance of CustomTargetingValueServiceClient with default settings.

Returns
Type Description
CustomTargetingValueServiceClient
Exceptions
Type Description
IOException

create(CustomTargetingValueServiceSettings settings)

public static final CustomTargetingValueServiceClient create(CustomTargetingValueServiceSettings settings)

Constructs an instance of CustomTargetingValueServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings CustomTargetingValueServiceSettings
Returns
Type Description
CustomTargetingValueServiceClient
Exceptions
Type Description
IOException

create(CustomTargetingValueServiceStub stub)

public static final CustomTargetingValueServiceClient create(CustomTargetingValueServiceStub stub)

Constructs an instance of CustomTargetingValueServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(CustomTargetingValueServiceSettings).

Parameter
Name Description
stub CustomTargetingValueServiceStub
Returns
Type Description
CustomTargetingValueServiceClient

Constructors

CustomTargetingValueServiceClient(CustomTargetingValueServiceSettings settings)

protected CustomTargetingValueServiceClient(CustomTargetingValueServiceSettings settings)

Constructs an instance of CustomTargetingValueServiceClient, 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
Name Description
settings CustomTargetingValueServiceSettings

CustomTargetingValueServiceClient(CustomTargetingValueServiceStub stub)

protected CustomTargetingValueServiceClient(CustomTargetingValueServiceStub stub)
Parameter
Name Description
stub CustomTargetingValueServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

getCustomTargetingValue(CustomTargetingValueName name)

public final CustomTargetingValue getCustomTargetingValue(CustomTargetingValueName name)

API to retrieve a CustomTargetingValue object.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   CustomTargetingValueName name =
       CustomTargetingValueName.of(
           "[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]", "[CUSTOM_TARGETING_VALUE]");
   CustomTargetingValue response =
       customTargetingValueServiceClient.getCustomTargetingValue(name);
 }
 
Parameter
Name Description
name CustomTargetingValueName

Required. The resource name of the CustomTargetingValue. Format: networks/{network_code}/customTargetingKeys/{custom_targeting_key_id}/customTargetingValues/{custom_targeting_value_id}

Returns
Type Description
CustomTargetingValue

getCustomTargetingValue(GetCustomTargetingValueRequest request)

public final CustomTargetingValue getCustomTargetingValue(GetCustomTargetingValueRequest request)

API to retrieve a CustomTargetingValue object.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   GetCustomTargetingValueRequest request =
       GetCustomTargetingValueRequest.newBuilder()
           .setName(
               CustomTargetingValueName.of(
                       "[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]", "[CUSTOM_TARGETING_VALUE]")
                   .toString())
           .build();
   CustomTargetingValue response =
       customTargetingValueServiceClient.getCustomTargetingValue(request);
 }
 
Parameter
Name Description
request GetCustomTargetingValueRequest

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

Returns
Type Description
CustomTargetingValue

getCustomTargetingValue(String name)

public final CustomTargetingValue getCustomTargetingValue(String name)

API to retrieve a CustomTargetingValue object.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   String name =
       CustomTargetingValueName.of(
               "[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]", "[CUSTOM_TARGETING_VALUE]")
           .toString();
   CustomTargetingValue response =
       customTargetingValueServiceClient.getCustomTargetingValue(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the CustomTargetingValue. Format: networks/{network_code}/customTargetingKeys/{custom_targeting_key_id}/customTargetingValues/{custom_targeting_value_id}

Returns
Type Description
CustomTargetingValue

getCustomTargetingValueCallable()

public final UnaryCallable<GetCustomTargetingValueRequest,CustomTargetingValue> getCustomTargetingValueCallable()

API to retrieve a CustomTargetingValue object.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   GetCustomTargetingValueRequest request =
       GetCustomTargetingValueRequest.newBuilder()
           .setName(
               CustomTargetingValueName.of(
                       "[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]", "[CUSTOM_TARGETING_VALUE]")
                   .toString())
           .build();
   ApiFuture<CustomTargetingValue> future =
       customTargetingValueServiceClient.getCustomTargetingValueCallable().futureCall(request);
   // Do something.
   CustomTargetingValue response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetCustomTargetingValueRequest,CustomTargetingValue>

getSettings()

public final CustomTargetingValueServiceSettings getSettings()
Returns
Type Description
CustomTargetingValueServiceSettings

getStub()

public CustomTargetingValueServiceStub getStub()
Returns
Type Description
CustomTargetingValueServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listCustomTargetingValues(CustomTargetingKeyName parent)

public final CustomTargetingValueServiceClient.ListCustomTargetingValuesPagedResponse listCustomTargetingValues(CustomTargetingKeyName parent)

API to retrieve a list of CustomTargetingValue objects.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   CustomTargetingKeyName parent =
       CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]");
   for (CustomTargetingValue element :
       customTargetingValueServiceClient.listCustomTargetingValues(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent CustomTargetingKeyName

Required. The parent, which owns this collection of CustomTargetingValues. Format: networks/{network_code}/customTargetingKeys/{custom_targeting_key_id}

Returns
Type Description
CustomTargetingValueServiceClient.ListCustomTargetingValuesPagedResponse

listCustomTargetingValues(ListCustomTargetingValuesRequest request)

public final CustomTargetingValueServiceClient.ListCustomTargetingValuesPagedResponse listCustomTargetingValues(ListCustomTargetingValuesRequest request)

API to retrieve a list of CustomTargetingValue objects.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   ListCustomTargetingValuesRequest request =
       ListCustomTargetingValuesRequest.newBuilder()
           .setParent(
               CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   for (CustomTargetingValue element :
       customTargetingValueServiceClient.listCustomTargetingValues(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListCustomTargetingValuesRequest

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

Returns
Type Description
CustomTargetingValueServiceClient.ListCustomTargetingValuesPagedResponse

listCustomTargetingValues(String parent)

public final CustomTargetingValueServiceClient.ListCustomTargetingValuesPagedResponse listCustomTargetingValues(String parent)

API to retrieve a list of CustomTargetingValue objects.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   String parent =
       CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]").toString();
   for (CustomTargetingValue element :
       customTargetingValueServiceClient.listCustomTargetingValues(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent, which owns this collection of CustomTargetingValues. Format: networks/{network_code}/customTargetingKeys/{custom_targeting_key_id}

Returns
Type Description
CustomTargetingValueServiceClient.ListCustomTargetingValuesPagedResponse

listCustomTargetingValuesCallable()

public final UnaryCallable<ListCustomTargetingValuesRequest,ListCustomTargetingValuesResponse> listCustomTargetingValuesCallable()

API to retrieve a list of CustomTargetingValue objects.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   ListCustomTargetingValuesRequest request =
       ListCustomTargetingValuesRequest.newBuilder()
           .setParent(
               CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   while (true) {
     ListCustomTargetingValuesResponse response =
         customTargetingValueServiceClient.listCustomTargetingValuesCallable().call(request);
     for (CustomTargetingValue element : response.getCustomTargetingValuesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListCustomTargetingValuesRequest,ListCustomTargetingValuesResponse>

listCustomTargetingValuesPagedCallable()

public final UnaryCallable<ListCustomTargetingValuesRequest,CustomTargetingValueServiceClient.ListCustomTargetingValuesPagedResponse> listCustomTargetingValuesPagedCallable()

API to retrieve a list of CustomTargetingValue objects.

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 (CustomTargetingValueServiceClient customTargetingValueServiceClient =
     CustomTargetingValueServiceClient.create()) {
   ListCustomTargetingValuesRequest request =
       ListCustomTargetingValuesRequest.newBuilder()
           .setParent(
               CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   ApiFuture<CustomTargetingValue> future =
       customTargetingValueServiceClient
           .listCustomTargetingValuesPagedCallable()
           .futureCall(request);
   // Do something.
   for (CustomTargetingValue element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListCustomTargetingValuesRequest,ListCustomTargetingValuesPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()