Class CustomTargetingKeyServiceClient (0.14.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   CustomTargetingKeyName name =
       CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]");
   CustomTargetingKey response = customTargetingKeyServiceClient.getCustomTargetingKey(name);
 }
 

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

GetCustomTargetingKey

API to retrieve a CustomTargetingKey object.

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

  • getCustomTargetingKey(GetCustomTargetingKeyRequest request)

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

  • getCustomTargetingKey(CustomTargetingKeyName name)

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

  • getCustomTargetingKeyCallable()

ListCustomTargetingKeys

API to retrieve a list of CustomTargetingKey objects.

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

  • listCustomTargetingKeys(ListCustomTargetingKeysRequest request)

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

  • listCustomTargetingKeys(NetworkName parent)

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

  • listCustomTargetingKeysPagedCallable()

  • listCustomTargetingKeysCallable()

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 CustomTargetingKeyServiceSettings 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
 CustomTargetingKeyServiceSettings customTargetingKeyServiceSettings =
     CustomTargetingKeyServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create(customTargetingKeyServiceSettings);
 

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
 CustomTargetingKeyServiceSettings customTargetingKeyServiceSettings =
     CustomTargetingKeyServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create(customTargetingKeyServiceSettings);
 

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

Inheritance

java.lang.Object > CustomTargetingKeyServiceClient

Static Methods

create()

public static final CustomTargetingKeyServiceClient create()

Constructs an instance of CustomTargetingKeyServiceClient with default settings.

Returns
Type Description
CustomTargetingKeyServiceClient
Exceptions
Type Description
IOException

create(CustomTargetingKeyServiceSettings settings)

public static final CustomTargetingKeyServiceClient create(CustomTargetingKeyServiceSettings settings)

Constructs an instance of CustomTargetingKeyServiceClient, 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 CustomTargetingKeyServiceSettings
Returns
Type Description
CustomTargetingKeyServiceClient
Exceptions
Type Description
IOException

create(CustomTargetingKeyServiceStub stub)

public static final CustomTargetingKeyServiceClient create(CustomTargetingKeyServiceStub stub)

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

Parameter
Name Description
stub CustomTargetingKeyServiceStub
Returns
Type Description
CustomTargetingKeyServiceClient

Constructors

CustomTargetingKeyServiceClient(CustomTargetingKeyServiceSettings settings)

protected CustomTargetingKeyServiceClient(CustomTargetingKeyServiceSettings settings)

Constructs an instance of CustomTargetingKeyServiceClient, 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 CustomTargetingKeyServiceSettings

CustomTargetingKeyServiceClient(CustomTargetingKeyServiceStub stub)

protected CustomTargetingKeyServiceClient(CustomTargetingKeyServiceStub stub)
Parameter
Name Description
stub CustomTargetingKeyServiceStub

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

getCustomTargetingKey(CustomTargetingKeyName name)

public final CustomTargetingKey getCustomTargetingKey(CustomTargetingKeyName name)

API to retrieve a CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   CustomTargetingKeyName name =
       CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]");
   CustomTargetingKey response = customTargetingKeyServiceClient.getCustomTargetingKey(name);
 }
 
Parameter
Name Description
name CustomTargetingKeyName

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

Returns
Type Description
CustomTargetingKey

getCustomTargetingKey(GetCustomTargetingKeyRequest request)

public final CustomTargetingKey getCustomTargetingKey(GetCustomTargetingKeyRequest request)

API to retrieve a CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   GetCustomTargetingKeyRequest request =
       GetCustomTargetingKeyRequest.newBuilder()
           .setName(
               CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]").toString())
           .build();
   CustomTargetingKey response = customTargetingKeyServiceClient.getCustomTargetingKey(request);
 }
 
Parameter
Name Description
request GetCustomTargetingKeyRequest

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

Returns
Type Description
CustomTargetingKey

getCustomTargetingKey(String name)

public final CustomTargetingKey getCustomTargetingKey(String name)

API to retrieve a CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   String name =
       CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]").toString();
   CustomTargetingKey response = customTargetingKeyServiceClient.getCustomTargetingKey(name);
 }
 
Parameter
Name Description
name String

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

Returns
Type Description
CustomTargetingKey

getCustomTargetingKeyCallable()

public final UnaryCallable<GetCustomTargetingKeyRequest,CustomTargetingKey> getCustomTargetingKeyCallable()

API to retrieve a CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   GetCustomTargetingKeyRequest request =
       GetCustomTargetingKeyRequest.newBuilder()
           .setName(
               CustomTargetingKeyName.of("[NETWORK_CODE]", "[CUSTOM_TARGETING_KEY]").toString())
           .build();
   ApiFuture<CustomTargetingKey> future =
       customTargetingKeyServiceClient.getCustomTargetingKeyCallable().futureCall(request);
   // Do something.
   CustomTargetingKey response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetCustomTargetingKeyRequest,CustomTargetingKey>

getSettings()

public final CustomTargetingKeyServiceSettings getSettings()
Returns
Type Description
CustomTargetingKeyServiceSettings

getStub()

public CustomTargetingKeyServiceStub getStub()
Returns
Type Description
CustomTargetingKeyServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listCustomTargetingKeys(ListCustomTargetingKeysRequest request)

public final CustomTargetingKeyServiceClient.ListCustomTargetingKeysPagedResponse listCustomTargetingKeys(ListCustomTargetingKeysRequest request)

API to retrieve a list of CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   ListCustomTargetingKeysRequest request =
       ListCustomTargetingKeysRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   for (CustomTargetingKey element :
       customTargetingKeyServiceClient.listCustomTargetingKeys(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListCustomTargetingKeysRequest

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

Returns
Type Description
CustomTargetingKeyServiceClient.ListCustomTargetingKeysPagedResponse

listCustomTargetingKeys(NetworkName parent)

public final CustomTargetingKeyServiceClient.ListCustomTargetingKeysPagedResponse listCustomTargetingKeys(NetworkName parent)

API to retrieve a list of CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   for (CustomTargetingKey element :
       customTargetingKeyServiceClient.listCustomTargetingKeys(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent NetworkName

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

Returns
Type Description
CustomTargetingKeyServiceClient.ListCustomTargetingKeysPagedResponse

listCustomTargetingKeys(String parent)

public final CustomTargetingKeyServiceClient.ListCustomTargetingKeysPagedResponse listCustomTargetingKeys(String parent)

API to retrieve a list of CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   for (CustomTargetingKey element :
       customTargetingKeyServiceClient.listCustomTargetingKeys(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

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

Returns
Type Description
CustomTargetingKeyServiceClient.ListCustomTargetingKeysPagedResponse

listCustomTargetingKeysCallable()

public final UnaryCallable<ListCustomTargetingKeysRequest,ListCustomTargetingKeysResponse> listCustomTargetingKeysCallable()

API to retrieve a list of CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   ListCustomTargetingKeysRequest request =
       ListCustomTargetingKeysRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   while (true) {
     ListCustomTargetingKeysResponse response =
         customTargetingKeyServiceClient.listCustomTargetingKeysCallable().call(request);
     for (CustomTargetingKey element : response.getCustomTargetingKeysList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListCustomTargetingKeysRequest,ListCustomTargetingKeysResponse>

listCustomTargetingKeysPagedCallable()

public final UnaryCallable<ListCustomTargetingKeysRequest,CustomTargetingKeyServiceClient.ListCustomTargetingKeysPagedResponse> listCustomTargetingKeysPagedCallable()

API to retrieve a list of CustomTargetingKey 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 (CustomTargetingKeyServiceClient customTargetingKeyServiceClient =
     CustomTargetingKeyServiceClient.create()) {
   ListCustomTargetingKeysRequest request =
       ListCustomTargetingKeysRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   ApiFuture<CustomTargetingKey> future =
       customTargetingKeyServiceClient
           .listCustomTargetingKeysPagedCallable()
           .futureCall(request);
   // Do something.
   for (CustomTargetingKey element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListCustomTargetingKeysRequest,ListCustomTargetingKeysPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()