Class AccountsServiceClient (0.10.0)

GitHub RepositoryProduct Reference

Service Description: Service for managing CSS/MC account information.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   AccountName name = AccountName.of("[ACCOUNT]");
   Account response = accountsServiceClient.getAccount(name);
 }
 

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

ListChildAccounts

Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and account name.

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

  • listChildAccounts(ListChildAccountsRequest request)

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

  • listChildAccounts(AccountName parent)

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

  • listChildAccountsPagedCallable()

  • listChildAccountsCallable()

GetAccount

Retrieves a single CSS/MC account by ID.

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

  • getAccount(GetAccountRequest request)

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

  • getAccount(AccountName name)

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

  • getAccountCallable()

UpdateLabels

Updates labels assigned to CSS/MC accounts by a CSS domain.

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

  • updateLabels(UpdateAccountLabelsRequest request)

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

  • updateLabels(AccountName name)

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

  • updateLabelsCallable()

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 AccountsServiceSettings 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
 AccountsServiceSettings accountsServiceSettings =
     AccountsServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 AccountsServiceClient accountsServiceClient =
     AccountsServiceClient.create(accountsServiceSettings);
 

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
 AccountsServiceSettings accountsServiceSettings =
     AccountsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 AccountsServiceClient accountsServiceClient =
     AccountsServiceClient.create(accountsServiceSettings);
 

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
 AccountsServiceSettings accountsServiceSettings =
     AccountsServiceSettings.newHttpJsonBuilder().build();
 AccountsServiceClient accountsServiceClient =
     AccountsServiceClient.create(accountsServiceSettings);
 

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

Inheritance

java.lang.Object > AccountsServiceClient

Static Methods

create()

public static final AccountsServiceClient create()

Constructs an instance of AccountsServiceClient with default settings.

Returns
Type Description
AccountsServiceClient
Exceptions
Type Description
IOException

create(AccountsServiceSettings settings)

public static final AccountsServiceClient create(AccountsServiceSettings settings)

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

create(AccountsServiceStub stub)

public static final AccountsServiceClient create(AccountsServiceStub stub)

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

Parameter
Name Description
stub AccountsServiceStub
Returns
Type Description
AccountsServiceClient

Constructors

AccountsServiceClient(AccountsServiceSettings settings)

protected AccountsServiceClient(AccountsServiceSettings settings)

Constructs an instance of AccountsServiceClient, 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 AccountsServiceSettings

AccountsServiceClient(AccountsServiceStub stub)

protected AccountsServiceClient(AccountsServiceStub stub)
Parameter
Name Description
stub AccountsServiceStub

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

getAccount(AccountName name)

public final Account getAccount(AccountName name)

Retrieves a single CSS/MC account by ID.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   AccountName name = AccountName.of("[ACCOUNT]");
   Account response = accountsServiceClient.getAccount(name);
 }
 
Parameter
Name Description
name AccountName

Required. The name of the managed CSS/MC account. Format: accounts/{account}

Returns
Type Description
Account

getAccount(GetAccountRequest request)

public final Account getAccount(GetAccountRequest request)

Retrieves a single CSS/MC account by ID.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   GetAccountRequest request =
       GetAccountRequest.newBuilder()
           .setName(AccountName.of("[ACCOUNT]").toString())
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .build();
   Account response = accountsServiceClient.getAccount(request);
 }
 
Parameter
Name Description
request GetAccountRequest

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

Returns
Type Description
Account

getAccount(String name)

public final Account getAccount(String name)

Retrieves a single CSS/MC account by ID.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   String name = AccountName.of("[ACCOUNT]").toString();
   Account response = accountsServiceClient.getAccount(name);
 }
 
Parameter
Name Description
name String

Required. The name of the managed CSS/MC account. Format: accounts/{account}

Returns
Type Description
Account

getAccountCallable()

public final UnaryCallable<GetAccountRequest,Account> getAccountCallable()

Retrieves a single CSS/MC account by ID.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   GetAccountRequest request =
       GetAccountRequest.newBuilder()
           .setName(AccountName.of("[ACCOUNT]").toString())
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .build();
   ApiFuture<Account> future = accountsServiceClient.getAccountCallable().futureCall(request);
   // Do something.
   Account response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetAccountRequest,Account>

getSettings()

public final AccountsServiceSettings getSettings()
Returns
Type Description
AccountsServiceSettings

getStub()

public AccountsServiceStub getStub()
Returns
Type Description
AccountsServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listChildAccounts(AccountName parent)

public final AccountsServiceClient.ListChildAccountsPagedResponse listChildAccounts(AccountName parent)

Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and account name.

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

Required. The parent account. Must be a CSS group or domain. Format: accounts/{account}

Returns
Type Description
AccountsServiceClient.ListChildAccountsPagedResponse

listChildAccounts(ListChildAccountsRequest request)

public final AccountsServiceClient.ListChildAccountsPagedResponse listChildAccounts(ListChildAccountsRequest request)

Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and account name.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   ListChildAccountsRequest request =
       ListChildAccountsRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setLabelId(-1959256506)
           .setFullName("fullName1330852282")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Account element : accountsServiceClient.listChildAccounts(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListChildAccountsRequest

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

Returns
Type Description
AccountsServiceClient.ListChildAccountsPagedResponse

listChildAccounts(String parent)

public final AccountsServiceClient.ListChildAccountsPagedResponse listChildAccounts(String parent)

Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and account name.

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

Required. The parent account. Must be a CSS group or domain. Format: accounts/{account}

Returns
Type Description
AccountsServiceClient.ListChildAccountsPagedResponse

listChildAccountsCallable()

public final UnaryCallable<ListChildAccountsRequest,ListChildAccountsResponse> listChildAccountsCallable()

Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and account name.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   ListChildAccountsRequest request =
       ListChildAccountsRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setLabelId(-1959256506)
           .setFullName("fullName1330852282")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListChildAccountsResponse response =
         accountsServiceClient.listChildAccountsCallable().call(request);
     for (Account element : response.getAccountsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListChildAccountsRequest,ListChildAccountsResponse>

listChildAccountsPagedCallable()

public final UnaryCallable<ListChildAccountsRequest,AccountsServiceClient.ListChildAccountsPagedResponse> listChildAccountsPagedCallable()

Lists all the accounts under the specified CSS account ID, and optionally filters by label ID and account name.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   ListChildAccountsRequest request =
       ListChildAccountsRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setLabelId(-1959256506)
           .setFullName("fullName1330852282")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Account> future =
       accountsServiceClient.listChildAccountsPagedCallable().futureCall(request);
   // Do something.
   for (Account element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListChildAccountsRequest,ListChildAccountsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateLabels(AccountName name)

public final Account updateLabels(AccountName name)

Updates labels assigned to CSS/MC accounts by a CSS domain.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   AccountName name = AccountName.of("[ACCOUNT]");
   Account response = accountsServiceClient.updateLabels(name);
 }
 
Parameter
Name Description
name AccountName

Required. The label resource name. Format: accounts/{account}

Returns
Type Description
Account

updateLabels(UpdateAccountLabelsRequest request)

public final Account updateLabels(UpdateAccountLabelsRequest request)

Updates labels assigned to CSS/MC accounts by a CSS domain.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   UpdateAccountLabelsRequest request =
       UpdateAccountLabelsRequest.newBuilder()
           .setName(AccountName.of("[ACCOUNT]").toString())
           .addAllLabelIds(new ArrayList<Long>())
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .build();
   Account response = accountsServiceClient.updateLabels(request);
 }
 
Parameter
Name Description
request UpdateAccountLabelsRequest

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

Returns
Type Description
Account

updateLabels(String name)

public final Account updateLabels(String name)

Updates labels assigned to CSS/MC accounts by a CSS domain.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   String name = AccountName.of("[ACCOUNT]").toString();
   Account response = accountsServiceClient.updateLabels(name);
 }
 
Parameter
Name Description
name String

Required. The label resource name. Format: accounts/{account}

Returns
Type Description
Account

updateLabelsCallable()

public final UnaryCallable<UpdateAccountLabelsRequest,Account> updateLabelsCallable()

Updates labels assigned to CSS/MC accounts by a CSS domain.

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 (AccountsServiceClient accountsServiceClient = AccountsServiceClient.create()) {
   UpdateAccountLabelsRequest request =
       UpdateAccountLabelsRequest.newBuilder()
           .setName(AccountName.of("[ACCOUNT]").toString())
           .addAllLabelIds(new ArrayList<Long>())
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .build();
   ApiFuture<Account> future = accountsServiceClient.updateLabelsCallable().futureCall(request);
   // Do something.
   Account response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateAccountLabelsRequest,Account>