Class AccountLabelsServiceClient (0.1.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().

MethodDescriptionMethod 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
TypeDescription
AccountLabelsServiceClient
Exceptions
TypeDescription
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
NameDescription
settingsAccountLabelsServiceSettings
Returns
TypeDescription
AccountLabelsServiceClient
Exceptions
TypeDescription
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
NameDescription
stubAccountLabelsServiceStub
Returns
TypeDescription
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
NameDescription
settingsAccountLabelsServiceSettings

AccountLabelsServiceClient(AccountLabelsServiceStub stub)

protected AccountLabelsServiceClient(AccountLabelsServiceStub stub)
Parameter
NameDescription
stubAccountLabelsServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
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
NameDescription
parentAccountName

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

accountLabelAccountLabel

Required. The label to create.

Returns
TypeDescription
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
NameDescription
requestCreateAccountLabelRequest

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

Returns
TypeDescription
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
NameDescription
parentString

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

accountLabelAccountLabel

Required. The label to create.

Returns
TypeDescription
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
TypeDescription
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
NameDescription
nameAccountLabelName

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
NameDescription
requestDeleteAccountLabelRequest

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
NameDescription
nameString

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
TypeDescription
UnaryCallable<DeleteAccountLabelRequest,Empty>

getSettings()

public final AccountLabelsServiceSettings getSettings()
Returns
TypeDescription
AccountLabelsServiceSettings

getStub()

public AccountLabelsServiceStub getStub()
Returns
TypeDescription
AccountLabelsServiceStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
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
NameDescription
parentAccountName

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

Returns
TypeDescription
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
NameDescription
requestListAccountLabelsRequest

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

Returns
TypeDescription
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
NameDescription
parentString

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

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
NameDescription
accountLabelAccountLabel

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

Returns
TypeDescription
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
NameDescription
requestUpdateAccountLabelRequest

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

Returns
TypeDescription
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
TypeDescription
UnaryCallable<UpdateAccountLabelRequest,AccountLabel>