Class AccountLabelsServiceClient (0.17.0)

GitHub RepositoryProduct Reference

Service Description: Manages Merchant Center and CSS accounts labels.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   AccountName parent = AccountName.of("[ACCOUNT]");
   AccountLabel accountLabel = AccountLabel.newBuilder().build();
   AccountLabel response = accountLabelsServiceClient.createAccountLabel(parent, accountLabel);
 }
 

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

ListAccountLabels

Lists the labels assigned to an account.

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

  • listAccountLabels(ListAccountLabelsRequest request)

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

  • listAccountLabels(AccountName parent)

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

  • listAccountLabelsPagedCallable()

  • listAccountLabelsCallable()

CreateAccountLabel

Creates a new label, not assigned to any account.

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

  • createAccountLabel(CreateAccountLabelRequest request)

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

  • createAccountLabel(AccountName parent, AccountLabel accountLabel)

  • createAccountLabel(String parent, AccountLabel accountLabel)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createAccountLabelCallable()

UpdateAccountLabel

Updates a label.

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

  • updateAccountLabel(UpdateAccountLabelRequest request)

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

  • updateAccountLabel(AccountLabel accountLabel)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateAccountLabelCallable()

DeleteAccountLabel

Deletes a label and removes it from all accounts to which it was assigned.

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

  • deleteAccountLabel(DeleteAccountLabelRequest request)

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

  • deleteAccountLabel(AccountLabelName name)

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

  • deleteAccountLabelCallable()

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 AccountLabelsServiceSettings 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
 AccountLabelsServiceSettings accountLabelsServiceSettings =
     AccountLabelsServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create(accountLabelsServiceSettings);
 

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
 AccountLabelsServiceSettings accountLabelsServiceSettings =
     AccountLabelsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create(accountLabelsServiceSettings);
 

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
 AccountLabelsServiceSettings accountLabelsServiceSettings =
     AccountLabelsServiceSettings.newHttpJsonBuilder().build();
 AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create(accountLabelsServiceSettings);
 

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

Inheritance

java.lang.Object > AccountLabelsServiceClient

Static Methods

create()

public static final AccountLabelsServiceClient create()

Constructs an instance of AccountLabelsServiceClient with default settings.

Returns
Type Description
AccountLabelsServiceClient
Exceptions
Type Description
IOException

create(AccountLabelsServiceSettings settings)

public static final AccountLabelsServiceClient create(AccountLabelsServiceSettings settings)

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

create(AccountLabelsServiceStub stub)

public static final AccountLabelsServiceClient create(AccountLabelsServiceStub stub)

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

Parameter
Name Description
stub AccountLabelsServiceStub
Returns
Type Description
AccountLabelsServiceClient

Constructors

AccountLabelsServiceClient(AccountLabelsServiceSettings settings)

protected AccountLabelsServiceClient(AccountLabelsServiceSettings settings)

Constructs an instance of AccountLabelsServiceClient, 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 AccountLabelsServiceSettings

AccountLabelsServiceClient(AccountLabelsServiceStub stub)

protected AccountLabelsServiceClient(AccountLabelsServiceStub stub)
Parameter
Name Description
stub AccountLabelsServiceStub

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

createAccountLabel(AccountName parent, AccountLabel accountLabel)

public final AccountLabel createAccountLabel(AccountName parent, AccountLabel accountLabel)

Creates a new label, not assigned to any account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   AccountName parent = AccountName.of("[ACCOUNT]");
   AccountLabel accountLabel = AccountLabel.newBuilder().build();
   AccountLabel response = accountLabelsServiceClient.createAccountLabel(parent, accountLabel);
 }
 
Parameters
Name Description
parent AccountName

Required. The parent account. Format: accounts/{account}

accountLabel AccountLabel

Required. The label to create.

Returns
Type Description
AccountLabel

createAccountLabel(CreateAccountLabelRequest request)

public final AccountLabel createAccountLabel(CreateAccountLabelRequest request)

Creates a new label, not assigned to any account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   CreateAccountLabelRequest request =
       CreateAccountLabelRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setAccountLabel(AccountLabel.newBuilder().build())
           .build();
   AccountLabel response = accountLabelsServiceClient.createAccountLabel(request);
 }
 
Parameter
Name Description
request CreateAccountLabelRequest

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

Returns
Type Description
AccountLabel

createAccountLabel(String parent, AccountLabel accountLabel)

public final AccountLabel createAccountLabel(String parent, AccountLabel accountLabel)

Creates a new label, not assigned to any account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   String parent = AccountName.of("[ACCOUNT]").toString();
   AccountLabel accountLabel = AccountLabel.newBuilder().build();
   AccountLabel response = accountLabelsServiceClient.createAccountLabel(parent, accountLabel);
 }
 
Parameters
Name Description
parent String

Required. The parent account. Format: accounts/{account}

accountLabel AccountLabel

Required. The label to create.

Returns
Type Description
AccountLabel

createAccountLabelCallable()

public final UnaryCallable<CreateAccountLabelRequest,AccountLabel> createAccountLabelCallable()

Creates a new label, not assigned to any account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   CreateAccountLabelRequest request =
       CreateAccountLabelRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setAccountLabel(AccountLabel.newBuilder().build())
           .build();
   ApiFuture<AccountLabel> future =
       accountLabelsServiceClient.createAccountLabelCallable().futureCall(request);
   // Do something.
   AccountLabel response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateAccountLabelRequest,AccountLabel>

deleteAccountLabel(AccountLabelName name)

public final void deleteAccountLabel(AccountLabelName name)

Deletes a label and removes it from all accounts to which it was assigned.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   AccountLabelName name = AccountLabelName.of("[ACCOUNT]", "[LABEL]");
   accountLabelsServiceClient.deleteAccountLabel(name);
 }
 
Parameter
Name Description
name AccountLabelName

Required. The name of the label to delete. Format: accounts/{account}/labels/{label}

deleteAccountLabel(DeleteAccountLabelRequest request)

public final void deleteAccountLabel(DeleteAccountLabelRequest request)

Deletes a label and removes it from all accounts to which it was assigned.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   DeleteAccountLabelRequest request =
       DeleteAccountLabelRequest.newBuilder()
           .setName(AccountLabelName.of("[ACCOUNT]", "[LABEL]").toString())
           .build();
   accountLabelsServiceClient.deleteAccountLabel(request);
 }
 
Parameter
Name Description
request DeleteAccountLabelRequest

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

deleteAccountLabel(String name)

public final void deleteAccountLabel(String name)

Deletes a label and removes it from all accounts to which it was assigned.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   String name = AccountLabelName.of("[ACCOUNT]", "[LABEL]").toString();
   accountLabelsServiceClient.deleteAccountLabel(name);
 }
 
Parameter
Name Description
name String

Required. The name of the label to delete. Format: accounts/{account}/labels/{label}

deleteAccountLabelCallable()

public final UnaryCallable<DeleteAccountLabelRequest,Empty> deleteAccountLabelCallable()

Deletes a label and removes it from all accounts to which it was assigned.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   DeleteAccountLabelRequest request =
       DeleteAccountLabelRequest.newBuilder()
           .setName(AccountLabelName.of("[ACCOUNT]", "[LABEL]").toString())
           .build();
   ApiFuture<Empty> future =
       accountLabelsServiceClient.deleteAccountLabelCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteAccountLabelRequest,Empty>

getSettings()

public final AccountLabelsServiceSettings getSettings()
Returns
Type Description
AccountLabelsServiceSettings

getStub()

public AccountLabelsServiceStub getStub()
Returns
Type Description
AccountLabelsServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listAccountLabels(AccountName parent)

public final AccountLabelsServiceClient.ListAccountLabelsPagedResponse listAccountLabels(AccountName parent)

Lists the labels assigned to an account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   AccountName parent = AccountName.of("[ACCOUNT]");
   for (AccountLabel element :
       accountLabelsServiceClient.listAccountLabels(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent AccountName

Required. The parent account. Format: accounts/{account}

Returns
Type Description
AccountLabelsServiceClient.ListAccountLabelsPagedResponse

listAccountLabels(ListAccountLabelsRequest request)

public final AccountLabelsServiceClient.ListAccountLabelsPagedResponse listAccountLabels(ListAccountLabelsRequest request)

Lists the labels assigned to an account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   ListAccountLabelsRequest request =
       ListAccountLabelsRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (AccountLabel element :
       accountLabelsServiceClient.listAccountLabels(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListAccountLabelsRequest

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

Returns
Type Description
AccountLabelsServiceClient.ListAccountLabelsPagedResponse

listAccountLabels(String parent)

public final AccountLabelsServiceClient.ListAccountLabelsPagedResponse listAccountLabels(String parent)

Lists the labels assigned to an account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   String parent = AccountName.of("[ACCOUNT]").toString();
   for (AccountLabel element :
       accountLabelsServiceClient.listAccountLabels(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent account. Format: accounts/{account}

Returns
Type Description
AccountLabelsServiceClient.ListAccountLabelsPagedResponse

listAccountLabelsCallable()

public final UnaryCallable<ListAccountLabelsRequest,ListAccountLabelsResponse> listAccountLabelsCallable()

Lists the labels assigned to an account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   ListAccountLabelsRequest request =
       ListAccountLabelsRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListAccountLabelsResponse response =
         accountLabelsServiceClient.listAccountLabelsCallable().call(request);
     for (AccountLabel element : response.getAccountLabelsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListAccountLabelsRequest,ListAccountLabelsResponse>

listAccountLabelsPagedCallable()

public final UnaryCallable<ListAccountLabelsRequest,AccountLabelsServiceClient.ListAccountLabelsPagedResponse> listAccountLabelsPagedCallable()

Lists the labels assigned to an account.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   ListAccountLabelsRequest request =
       ListAccountLabelsRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<AccountLabel> future =
       accountLabelsServiceClient.listAccountLabelsPagedCallable().futureCall(request);
   // Do something.
   for (AccountLabel element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListAccountLabelsRequest,ListAccountLabelsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateAccountLabel(AccountLabel accountLabel)

public final AccountLabel updateAccountLabel(AccountLabel accountLabel)

Updates a label.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   AccountLabel accountLabel = AccountLabel.newBuilder().build();
   AccountLabel response = accountLabelsServiceClient.updateAccountLabel(accountLabel);
 }
 
Parameter
Name Description
accountLabel AccountLabel

Required. The updated label. All fields must be provided.

Returns
Type Description
AccountLabel

updateAccountLabel(UpdateAccountLabelRequest request)

public final AccountLabel updateAccountLabel(UpdateAccountLabelRequest request)

Updates a label.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   UpdateAccountLabelRequest request =
       UpdateAccountLabelRequest.newBuilder()
           .setAccountLabel(AccountLabel.newBuilder().build())
           .build();
   AccountLabel response = accountLabelsServiceClient.updateAccountLabel(request);
 }
 
Parameter
Name Description
request UpdateAccountLabelRequest

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

Returns
Type Description
AccountLabel

updateAccountLabelCallable()

public final UnaryCallable<UpdateAccountLabelRequest,AccountLabel> updateAccountLabelCallable()

Updates a label.

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 (AccountLabelsServiceClient accountLabelsServiceClient =
     AccountLabelsServiceClient.create()) {
   UpdateAccountLabelRequest request =
       UpdateAccountLabelRequest.newBuilder()
           .setAccountLabel(AccountLabel.newBuilder().build())
           .build();
   ApiFuture<AccountLabel> future =
       accountLabelsServiceClient.updateAccountLabelCallable().futureCall(request);
   // Do something.
   AccountLabel response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateAccountLabelRequest,AccountLabel>