Class LineItemTemplateServiceClient (0.62.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   LineItemTemplateName name = LineItemTemplateName.of("[NETWORK_CODE]", "[LINE_ITEM_TEMPLATE]");
   LineItemTemplate response = lineItemTemplateServiceClient.getLineItemTemplate(name);
 }
 

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

GetLineItemTemplate

Retrieves a LineItemTemplate object.

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

  • getLineItemTemplate(GetLineItemTemplateRequest request)

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

  • getLineItemTemplate(LineItemTemplateName name)

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

  • getLineItemTemplateCallable()

ListLineItemTemplates

Lists LineItemTemplate objects.

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

  • listLineItemTemplates(ListLineItemTemplatesRequest request)

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

  • listLineItemTemplates(NetworkName parent)

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

  • listLineItemTemplatesPagedCallable()

  • listLineItemTemplatesCallable()

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 LineItemTemplateServiceSettings 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
 LineItemTemplateServiceSettings lineItemTemplateServiceSettings =
     LineItemTemplateServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create(lineItemTemplateServiceSettings);
 

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
 LineItemTemplateServiceSettings lineItemTemplateServiceSettings =
     LineItemTemplateServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create(lineItemTemplateServiceSettings);
 

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

Inheritance

java.lang.Object > LineItemTemplateServiceClient

Static Methods

create()

public static final LineItemTemplateServiceClient create()

Constructs an instance of LineItemTemplateServiceClient with default settings.

Returns
Type Description
LineItemTemplateServiceClient
Exceptions
Type Description
IOException

create(LineItemTemplateServiceSettings settings)

public static final LineItemTemplateServiceClient create(LineItemTemplateServiceSettings settings)

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

create(LineItemTemplateServiceStub stub)

public static final LineItemTemplateServiceClient create(LineItemTemplateServiceStub stub)

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

Parameter
Name Description
stub LineItemTemplateServiceStub
Returns
Type Description
LineItemTemplateServiceClient

Constructors

LineItemTemplateServiceClient(LineItemTemplateServiceSettings settings)

protected LineItemTemplateServiceClient(LineItemTemplateServiceSettings settings)

Constructs an instance of LineItemTemplateServiceClient, 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 LineItemTemplateServiceSettings

LineItemTemplateServiceClient(LineItemTemplateServiceStub stub)

protected LineItemTemplateServiceClient(LineItemTemplateServiceStub stub)
Parameter
Name Description
stub LineItemTemplateServiceStub

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

getLineItemTemplate(@Nullable LineItemTemplateName name)

public final LineItemTemplate getLineItemTemplate(@Nullable LineItemTemplateName name)

Retrieves a LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   LineItemTemplateName name = LineItemTemplateName.of("[NETWORK_CODE]", "[LINE_ITEM_TEMPLATE]");
   LineItemTemplate response = lineItemTemplateServiceClient.getLineItemTemplate(name);
 }
 
Parameter
Name Description
name @org.jspecify.annotations.Nullable com.google.ads.admanager.v1.LineItemTemplateName

Required. The resource name of the LineItemTemplate. Format: networks/{network_code}/lineItemTemplates/{line_item_template_id}

Returns
Type Description
LineItemTemplate

getLineItemTemplate(GetLineItemTemplateRequest request)

public final LineItemTemplate getLineItemTemplate(GetLineItemTemplateRequest request)

Retrieves a LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   GetLineItemTemplateRequest request =
       GetLineItemTemplateRequest.newBuilder()
           .setName(LineItemTemplateName.of("[NETWORK_CODE]", "[LINE_ITEM_TEMPLATE]").toString())
           .build();
   LineItemTemplate response = lineItemTemplateServiceClient.getLineItemTemplate(request);
 }
 
Parameter
Name Description
request GetLineItemTemplateRequest

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

Returns
Type Description
LineItemTemplate

getLineItemTemplate(String name)

public final LineItemTemplate getLineItemTemplate(String name)

Retrieves a LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   String name = LineItemTemplateName.of("[NETWORK_CODE]", "[LINE_ITEM_TEMPLATE]").toString();
   LineItemTemplate response = lineItemTemplateServiceClient.getLineItemTemplate(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the LineItemTemplate. Format: networks/{network_code}/lineItemTemplates/{line_item_template_id}

Returns
Type Description
LineItemTemplate

getLineItemTemplateCallable()

public final UnaryCallable<GetLineItemTemplateRequest,LineItemTemplate> getLineItemTemplateCallable()

Retrieves a LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   GetLineItemTemplateRequest request =
       GetLineItemTemplateRequest.newBuilder()
           .setName(LineItemTemplateName.of("[NETWORK_CODE]", "[LINE_ITEM_TEMPLATE]").toString())
           .build();
   ApiFuture<LineItemTemplate> future =
       lineItemTemplateServiceClient.getLineItemTemplateCallable().futureCall(request);
   // Do something.
   LineItemTemplate response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetLineItemTemplateRequest,LineItemTemplate>

getSettings()

public final @Nullable LineItemTemplateServiceSettings getSettings()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.ads.admanager.v1.LineItemTemplateServiceSettings

getStub()

public LineItemTemplateServiceStub getStub()
Returns
Type Description
LineItemTemplateServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listLineItemTemplates(@Nullable NetworkName parent)

public final LineItemTemplateServiceClient.ListLineItemTemplatesPagedResponse listLineItemTemplates(@Nullable NetworkName parent)

Lists LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   for (LineItemTemplate element :
       lineItemTemplateServiceClient.listLineItemTemplates(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent @org.jspecify.annotations.Nullable com.google.ads.admanager.v1.NetworkName

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

Returns
Type Description
LineItemTemplateServiceClient.ListLineItemTemplatesPagedResponse

listLineItemTemplates(ListLineItemTemplatesRequest request)

public final LineItemTemplateServiceClient.ListLineItemTemplatesPagedResponse listLineItemTemplates(ListLineItemTemplatesRequest request)

Lists LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   ListLineItemTemplatesRequest request =
       ListLineItemTemplatesRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   for (LineItemTemplate element :
       lineItemTemplateServiceClient.listLineItemTemplates(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListLineItemTemplatesRequest

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

Returns
Type Description
LineItemTemplateServiceClient.ListLineItemTemplatesPagedResponse

listLineItemTemplates(String parent)

public final LineItemTemplateServiceClient.ListLineItemTemplatesPagedResponse listLineItemTemplates(String parent)

Lists LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   for (LineItemTemplate element :
       lineItemTemplateServiceClient.listLineItemTemplates(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

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

Returns
Type Description
LineItemTemplateServiceClient.ListLineItemTemplatesPagedResponse

listLineItemTemplatesCallable()

public final UnaryCallable<ListLineItemTemplatesRequest,ListLineItemTemplatesResponse> listLineItemTemplatesCallable()

Lists LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   ListLineItemTemplatesRequest request =
       ListLineItemTemplatesRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   while (true) {
     ListLineItemTemplatesResponse response =
         lineItemTemplateServiceClient.listLineItemTemplatesCallable().call(request);
     for (LineItemTemplate element : response.getLineItemTemplatesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListLineItemTemplatesRequest,ListLineItemTemplatesResponse>

listLineItemTemplatesPagedCallable()

public final UnaryCallable<ListLineItemTemplatesRequest,LineItemTemplateServiceClient.ListLineItemTemplatesPagedResponse> listLineItemTemplatesPagedCallable()

Lists LineItemTemplate 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 (LineItemTemplateServiceClient lineItemTemplateServiceClient =
     LineItemTemplateServiceClient.create()) {
   ListLineItemTemplatesRequest request =
       ListLineItemTemplatesRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   ApiFuture<LineItemTemplate> future =
       lineItemTemplateServiceClient.listLineItemTemplatesPagedCallable().futureCall(request);
   // Do something.
   for (LineItemTemplate element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListLineItemTemplatesRequest,ListLineItemTemplatesPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()