Class AdPartnerServiceClient (0.3.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling AdPartner 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 (AdPartnerServiceClient adPartnerServiceClient = AdPartnerServiceClient.create()) {
   AdPartnerName name = AdPartnerName.of("[NETWORK_CODE]", "[AD_PARTNER]");
   AdPartner response = adPartnerServiceClient.getAdPartner(name);
 }
 

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

GetAdPartner

API to retrieve a AdPartner object.

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

  • getAdPartner(GetAdPartnerRequest request)

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

  • getAdPartner(AdPartnerName name)

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

  • getAdPartnerCallable()

ListAdPartners

API to retrieve a list of AdPartner objects.

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

  • listAdPartners(ListAdPartnersRequest request)

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

  • listAdPartners(NetworkName parent)

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

  • listAdPartnersPagedCallable()

  • listAdPartnersCallable()

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 AdPartnerServiceSettings 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
 AdPartnerServiceSettings adPartnerServiceSettings =
     AdPartnerServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 AdPartnerServiceClient adPartnerServiceClient =
     AdPartnerServiceClient.create(adPartnerServiceSettings);
 

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
 AdPartnerServiceSettings adPartnerServiceSettings =
     AdPartnerServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 AdPartnerServiceClient adPartnerServiceClient =
     AdPartnerServiceClient.create(adPartnerServiceSettings);
 

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

Inheritance

java.lang.Object > AdPartnerServiceClient

Static Methods

create()

public static final AdPartnerServiceClient create()

Constructs an instance of AdPartnerServiceClient with default settings.

Returns
Type Description
AdPartnerServiceClient
Exceptions
Type Description
IOException

create(AdPartnerServiceSettings settings)

public static final AdPartnerServiceClient create(AdPartnerServiceSettings settings)

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

create(AdPartnerServiceStub stub)

public static final AdPartnerServiceClient create(AdPartnerServiceStub stub)

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

Parameter
Name Description
stub AdPartnerServiceStub
Returns
Type Description
AdPartnerServiceClient

Constructors

AdPartnerServiceClient(AdPartnerServiceSettings settings)

protected AdPartnerServiceClient(AdPartnerServiceSettings settings)

Constructs an instance of AdPartnerServiceClient, 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 AdPartnerServiceSettings

AdPartnerServiceClient(AdPartnerServiceStub stub)

protected AdPartnerServiceClient(AdPartnerServiceStub stub)
Parameter
Name Description
stub AdPartnerServiceStub

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

getAdPartner(AdPartnerName name)

public final AdPartner getAdPartner(AdPartnerName name)

API to retrieve a AdPartner 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 (AdPartnerServiceClient adPartnerServiceClient = AdPartnerServiceClient.create()) {
   AdPartnerName name = AdPartnerName.of("[NETWORK_CODE]", "[AD_PARTNER]");
   AdPartner response = adPartnerServiceClient.getAdPartner(name);
 }
 
Parameter
Name Description
name AdPartnerName

Required. The resource name of the AdPartner. Format: networks/{network_code}/adPartners/{ad_partner_id}

Returns
Type Description
AdPartner

getAdPartner(GetAdPartnerRequest request)

public final AdPartner getAdPartner(GetAdPartnerRequest request)

API to retrieve a AdPartner 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 (AdPartnerServiceClient adPartnerServiceClient = AdPartnerServiceClient.create()) {
   GetAdPartnerRequest request =
       GetAdPartnerRequest.newBuilder()
           .setName(AdPartnerName.of("[NETWORK_CODE]", "[AD_PARTNER]").toString())
           .build();
   AdPartner response = adPartnerServiceClient.getAdPartner(request);
 }
 
Parameter
Name Description
request GetAdPartnerRequest

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

Returns
Type Description
AdPartner

getAdPartner(String name)

public final AdPartner getAdPartner(String name)

API to retrieve a AdPartner 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 (AdPartnerServiceClient adPartnerServiceClient = AdPartnerServiceClient.create()) {
   String name = AdPartnerName.of("[NETWORK_CODE]", "[AD_PARTNER]").toString();
   AdPartner response = adPartnerServiceClient.getAdPartner(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the AdPartner. Format: networks/{network_code}/adPartners/{ad_partner_id}

Returns
Type Description
AdPartner

getAdPartnerCallable()

public final UnaryCallable<GetAdPartnerRequest,AdPartner> getAdPartnerCallable()

API to retrieve a AdPartner 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 (AdPartnerServiceClient adPartnerServiceClient = AdPartnerServiceClient.create()) {
   GetAdPartnerRequest request =
       GetAdPartnerRequest.newBuilder()
           .setName(AdPartnerName.of("[NETWORK_CODE]", "[AD_PARTNER]").toString())
           .build();
   ApiFuture<AdPartner> future =
       adPartnerServiceClient.getAdPartnerCallable().futureCall(request);
   // Do something.
   AdPartner response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetAdPartnerRequest,AdPartner>

getSettings()

public final AdPartnerServiceSettings getSettings()
Returns
Type Description
AdPartnerServiceSettings

getStub()

public AdPartnerServiceStub getStub()
Returns
Type Description
AdPartnerServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listAdPartners(ListAdPartnersRequest request)

public final AdPartnerServiceClient.ListAdPartnersPagedResponse listAdPartners(ListAdPartnersRequest request)

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

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

Returns
Type Description
AdPartnerServiceClient.ListAdPartnersPagedResponse

listAdPartners(NetworkName parent)

public final AdPartnerServiceClient.ListAdPartnersPagedResponse listAdPartners(NetworkName parent)

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

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

Returns
Type Description
AdPartnerServiceClient.ListAdPartnersPagedResponse

listAdPartners(String parent)

public final AdPartnerServiceClient.ListAdPartnersPagedResponse listAdPartners(String parent)

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

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

Returns
Type Description
AdPartnerServiceClient.ListAdPartnersPagedResponse

listAdPartnersCallable()

public final UnaryCallable<ListAdPartnersRequest,ListAdPartnersResponse> listAdPartnersCallable()

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

listAdPartnersPagedCallable()

public final UnaryCallable<ListAdPartnersRequest,AdPartnerServiceClient.ListAdPartnersPagedResponse> listAdPartnersPagedCallable()

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

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()