Class LicenseManagementServiceClient (0.51.0)

GitHub RepositoryProduct Reference

Service Description: Service for managing licenses.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   String name = "name3373707";
   LicensePool response = licenseManagementServiceClient.getLicensePool(name);
 }
 

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

GetLicensePool

Gets the license pool.

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

  • getLicensePool(GetLicensePoolRequest request)

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

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

  • getLicensePoolCallable()

UpdateLicensePool

Updates the license pool if one exists for this Order.

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

  • updateLicensePool(UpdateLicensePoolRequest request)

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

  • updateLicensePool(LicensePool licensePool, FieldMask updateMask)

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

  • updateLicensePoolCallable()

Assign

Assigns a license to a user.

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

  • assign(AssignRequest request)

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

  • assign(String parent, List<String> usernames)

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

  • assignCallable()

Unassign

Unassigns a license from a user.

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

  • unassign(UnassignRequest request)

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

  • unassign(String parent, List<String> usernames)

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

  • unassignCallable()

EnumerateLicensedUsers

Enumerates all users assigned a license.

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

  • enumerateLicensedUsers(EnumerateLicensedUsersRequest request)

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

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

  • enumerateLicensedUsersPagedCallable()

  • enumerateLicensedUsersCallable()

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 LicenseManagementServiceSettings 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
 LicenseManagementServiceSettings licenseManagementServiceSettings =
     LicenseManagementServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create(licenseManagementServiceSettings);
 

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
 LicenseManagementServiceSettings licenseManagementServiceSettings =
     LicenseManagementServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create(licenseManagementServiceSettings);
 

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
 LicenseManagementServiceSettings licenseManagementServiceSettings =
     LicenseManagementServiceSettings.newHttpJsonBuilder().build();
 LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create(licenseManagementServiceSettings);
 

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

Inheritance

java.lang.Object > LicenseManagementServiceClient

Static Methods

create()

public static final LicenseManagementServiceClient create()

Constructs an instance of LicenseManagementServiceClient with default settings.

Returns
Type Description
LicenseManagementServiceClient
Exceptions
Type Description
IOException

create(LicenseManagementServiceSettings settings)

public static final LicenseManagementServiceClient create(LicenseManagementServiceSettings settings)

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

create(LicenseManagementServiceStub stub)

public static final LicenseManagementServiceClient create(LicenseManagementServiceStub stub)

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

Parameter
Name Description
stub LicenseManagementServiceStub
Returns
Type Description
LicenseManagementServiceClient

Constructors

LicenseManagementServiceClient(LicenseManagementServiceSettings settings)

protected LicenseManagementServiceClient(LicenseManagementServiceSettings settings)

Constructs an instance of LicenseManagementServiceClient, 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 LicenseManagementServiceSettings

LicenseManagementServiceClient(LicenseManagementServiceStub stub)

protected LicenseManagementServiceClient(LicenseManagementServiceStub stub)
Parameter
Name Description
stub LicenseManagementServiceStub

Methods

assign(AssignRequest request)

public final AssignResponse assign(AssignRequest request)

Assigns a license to a user.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   AssignRequest request =
       AssignRequest.newBuilder()
           .setParent("parent-995424086")
           .addAllUsernames(new ArrayList<String>())
           .build();
   AssignResponse response = licenseManagementServiceClient.assign(request);
 }
 
Parameter
Name Description
request AssignRequest

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

Returns
Type Description
AssignResponse

assign(String parent, List<String> usernames)

public final AssignResponse assign(String parent, List<String> usernames)

Assigns a license to a user.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   String parent = "parent-995424086";
   List<String> usernames = new ArrayList<>();
   AssignResponse response = licenseManagementServiceClient.assign(parent, usernames);
 }
 
Parameters
Name Description
parent String

Required. License pool name.

usernames List<String>

Required. Username. Format: name@domain.com.

Returns
Type Description
AssignResponse

assignCallable()

public final UnaryCallable<AssignRequest,AssignResponse> assignCallable()

Assigns a license to a user.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   AssignRequest request =
       AssignRequest.newBuilder()
           .setParent("parent-995424086")
           .addAllUsernames(new ArrayList<String>())
           .build();
   ApiFuture<AssignResponse> future =
       licenseManagementServiceClient.assignCallable().futureCall(request);
   // Do something.
   AssignResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<AssignRequest,AssignResponse>

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

enumerateLicensedUsers(EnumerateLicensedUsersRequest request)

public final LicenseManagementServiceClient.EnumerateLicensedUsersPagedResponse enumerateLicensedUsers(EnumerateLicensedUsersRequest request)

Enumerates all users assigned a license.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   EnumerateLicensedUsersRequest request =
       EnumerateLicensedUsersRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (LicensedUser element :
       licenseManagementServiceClient.enumerateLicensedUsers(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request EnumerateLicensedUsersRequest

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

Returns
Type Description
LicenseManagementServiceClient.EnumerateLicensedUsersPagedResponse

enumerateLicensedUsers(String parent)

public final LicenseManagementServiceClient.EnumerateLicensedUsersPagedResponse enumerateLicensedUsers(String parent)

Enumerates all users assigned a license.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   String parent = "parent-995424086";
   for (LicensedUser element :
       licenseManagementServiceClient.enumerateLicensedUsers(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. License pool name.

Returns
Type Description
LicenseManagementServiceClient.EnumerateLicensedUsersPagedResponse

enumerateLicensedUsersCallable()

public final UnaryCallable<EnumerateLicensedUsersRequest,EnumerateLicensedUsersResponse> enumerateLicensedUsersCallable()

Enumerates all users assigned a license.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   EnumerateLicensedUsersRequest request =
       EnumerateLicensedUsersRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     EnumerateLicensedUsersResponse response =
         licenseManagementServiceClient.enumerateLicensedUsersCallable().call(request);
     for (LicensedUser element : response.getLicensedUsersList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<EnumerateLicensedUsersRequest,EnumerateLicensedUsersResponse>

enumerateLicensedUsersPagedCallable()

public final UnaryCallable<EnumerateLicensedUsersRequest,LicenseManagementServiceClient.EnumerateLicensedUsersPagedResponse> enumerateLicensedUsersPagedCallable()

Enumerates all users assigned a license.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   EnumerateLicensedUsersRequest request =
       EnumerateLicensedUsersRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<LicensedUser> future =
       licenseManagementServiceClient.enumerateLicensedUsersPagedCallable().futureCall(request);
   // Do something.
   for (LicensedUser element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<EnumerateLicensedUsersRequest,EnumerateLicensedUsersPagedResponse>

getLicensePool(GetLicensePoolRequest request)

public final LicensePool getLicensePool(GetLicensePoolRequest request)

Gets the license pool.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   GetLicensePoolRequest request =
       GetLicensePoolRequest.newBuilder().setName("name3373707").build();
   LicensePool response = licenseManagementServiceClient.getLicensePool(request);
 }
 
Parameter
Name Description
request GetLicensePoolRequest

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

Returns
Type Description
LicensePool

getLicensePool(String name)

public final LicensePool getLicensePool(String name)

Gets the license pool.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   String name = "name3373707";
   LicensePool response = licenseManagementServiceClient.getLicensePool(name);
 }
 
Parameter
Name Description
name String

Required. The name of the license pool to get. Format: billingAccounts/{billing_account}/orders/{order}/licensePool

Returns
Type Description
LicensePool

getLicensePoolCallable()

public final UnaryCallable<GetLicensePoolRequest,LicensePool> getLicensePoolCallable()

Gets the license pool.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   GetLicensePoolRequest request =
       GetLicensePoolRequest.newBuilder().setName("name3373707").build();
   ApiFuture<LicensePool> future =
       licenseManagementServiceClient.getLicensePoolCallable().futureCall(request);
   // Do something.
   LicensePool response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetLicensePoolRequest,LicensePool>

getSettings()

public final LicenseManagementServiceSettings getSettings()
Returns
Type Description
LicenseManagementServiceSettings

getStub()

public LicenseManagementServiceStub getStub()
Returns
Type Description
LicenseManagementServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

unassign(UnassignRequest request)

public final UnassignResponse unassign(UnassignRequest request)

Unassigns a license from a user.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   UnassignRequest request =
       UnassignRequest.newBuilder()
           .setParent("parent-995424086")
           .addAllUsernames(new ArrayList<String>())
           .build();
   UnassignResponse response = licenseManagementServiceClient.unassign(request);
 }
 
Parameter
Name Description
request UnassignRequest

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

Returns
Type Description
UnassignResponse

unassign(String parent, List<String> usernames)

public final UnassignResponse unassign(String parent, List<String> usernames)

Unassigns a license from a user.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   String parent = "parent-995424086";
   List<String> usernames = new ArrayList<>();
   UnassignResponse response = licenseManagementServiceClient.unassign(parent, usernames);
 }
 
Parameters
Name Description
parent String

Required. License pool name.

usernames List<String>

Required. Username. Format: name@domain.com.

Returns
Type Description
UnassignResponse

unassignCallable()

public final UnaryCallable<UnassignRequest,UnassignResponse> unassignCallable()

Unassigns a license from a user.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   UnassignRequest request =
       UnassignRequest.newBuilder()
           .setParent("parent-995424086")
           .addAllUsernames(new ArrayList<String>())
           .build();
   ApiFuture<UnassignResponse> future =
       licenseManagementServiceClient.unassignCallable().futureCall(request);
   // Do something.
   UnassignResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UnassignRequest,UnassignResponse>

updateLicensePool(LicensePool licensePool, FieldMask updateMask)

public final LicensePool updateLicensePool(LicensePool licensePool, FieldMask updateMask)

Updates the license pool if one exists for this Order.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   LicensePool licensePool = LicensePool.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   LicensePool response =
       licenseManagementServiceClient.updateLicensePool(licensePool, updateMask);
 }
 
Parameters
Name Description
licensePool LicensePool

Required. The license pool to update.

The license pool's name field is used to identify the license pool to update. Format: billingAccounts/{billing_account}/orders/{order}/licensePool.

updateMask FieldMask

Required. The list of fields to update.

Returns
Type Description
LicensePool

updateLicensePool(UpdateLicensePoolRequest request)

public final LicensePool updateLicensePool(UpdateLicensePoolRequest request)

Updates the license pool if one exists for this Order.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   UpdateLicensePoolRequest request =
       UpdateLicensePoolRequest.newBuilder()
           .setLicensePool(LicensePool.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   LicensePool response = licenseManagementServiceClient.updateLicensePool(request);
 }
 
Parameter
Name Description
request UpdateLicensePoolRequest

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

Returns
Type Description
LicensePool

updateLicensePoolCallable()

public final UnaryCallable<UpdateLicensePoolRequest,LicensePool> updateLicensePoolCallable()

Updates the license pool if one exists for this Order.

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 (LicenseManagementServiceClient licenseManagementServiceClient =
     LicenseManagementServiceClient.create()) {
   UpdateLicensePoolRequest request =
       UpdateLicensePoolRequest.newBuilder()
           .setLicensePool(LicensePool.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<LicensePool> future =
       licenseManagementServiceClient.updateLicensePoolCallable().futureCall(request);
   // Do something.
   LicensePool response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateLicensePoolRequest,LicensePool>