@Generated(value="by gapic-generator-java") public class UserLicenseServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
UserStoreName parent = UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]");
for (UserLicense element : userLicenseServiceClient.listUserLicenses(parent).iterateAll()) {
// doThingsWith(element);
}
}
Note: close() needs to be called on the UserLicenseServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
ListUserLicenses |
Lists the User Licenses. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
BatchUpdateUserLicenses |
Updates the User License. This method is used for batch assign/unassign licenses to users. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 UserLicenseServiceSettings 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
UserLicenseServiceSettings userLicenseServiceSettings =
UserLicenseServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
UserLicenseServiceClient userLicenseServiceClient =
UserLicenseServiceClient.create(userLicenseServiceSettings);
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
UserLicenseServiceSettings userLicenseServiceSettings =
UserLicenseServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
UserLicenseServiceClient userLicenseServiceClient =
UserLicenseServiceClient.create(userLicenseServiceSettings);
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
UserLicenseServiceSettings userLicenseServiceSettings =
UserLicenseServiceSettings.newHttpJsonBuilder().build();
UserLicenseServiceClient userLicenseServiceClient =
UserLicenseServiceClient.create(userLicenseServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
UserLicenseServiceClient.ListUserLicensesFixedSizeCollection |
static class |
UserLicenseServiceClient.ListUserLicensesPage |
static class |
UserLicenseServiceClient.ListUserLicensesPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
UserLicenseServiceClient(UserLicenseServiceSettings settings)
Constructs an instance of UserLicenseServiceClient, using the given settings.
|
protected |
UserLicenseServiceClient(UserLicenseServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
com.google.api.gax.longrunning.OperationFuture<BatchUpdateUserLicensesResponse,BatchUpdateUserLicensesMetadata> |
batchUpdateUserLicensesAsync(BatchUpdateUserLicensesRequest request)
Updates the User License.
|
com.google.api.gax.rpc.UnaryCallable<BatchUpdateUserLicensesRequest,com.google.longrunning.Operation> |
batchUpdateUserLicensesCallable()
Updates the User License.
|
com.google.api.gax.rpc.OperationCallable<BatchUpdateUserLicensesRequest,BatchUpdateUserLicensesResponse,BatchUpdateUserLicensesMetadata> |
batchUpdateUserLicensesOperationCallable()
Updates the User License.
|
void |
close() |
static UserLicenseServiceClient |
create()
Constructs an instance of UserLicenseServiceClient with default settings.
|
static UserLicenseServiceClient |
create(UserLicenseServiceSettings settings)
Constructs an instance of UserLicenseServiceClient, using the given settings.
|
static UserLicenseServiceClient |
create(UserLicenseServiceStub stub)
Constructs an instance of UserLicenseServiceClient, using the given stub for making calls.
|
com.google.api.gax.httpjson.longrunning.OperationsClient |
getHttpJsonOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
UserLicenseServiceSettings |
getSettings() |
UserLicenseServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
UserLicenseServiceClient.ListUserLicensesPagedResponse |
listUserLicenses(ListUserLicensesRequest request)
Lists the User Licenses.
|
UserLicenseServiceClient.ListUserLicensesPagedResponse |
listUserLicenses(String parent)
Lists the User Licenses.
|
UserLicenseServiceClient.ListUserLicensesPagedResponse |
listUserLicenses(UserStoreName parent)
Lists the User Licenses.
|
com.google.api.gax.rpc.UnaryCallable<ListUserLicensesRequest,ListUserLicensesResponse> |
listUserLicensesCallable()
Lists the User Licenses.
|
com.google.api.gax.rpc.UnaryCallable<ListUserLicensesRequest,UserLicenseServiceClient.ListUserLicensesPagedResponse> |
listUserLicensesPagedCallable()
Lists the User Licenses.
|
void |
shutdown() |
void |
shutdownNow() |
protected UserLicenseServiceClient(UserLicenseServiceSettings settings) throws IOException
IOExceptionprotected UserLicenseServiceClient(UserLicenseServiceStub stub)
public static final UserLicenseServiceClient create() throws IOException
IOExceptionpublic static final UserLicenseServiceClient create(UserLicenseServiceSettings settings) throws IOException
IOExceptionpublic static final UserLicenseServiceClient create(UserLicenseServiceStub stub)
public final UserLicenseServiceSettings getSettings()
public UserLicenseServiceStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final UserLicenseServiceClient.ListUserLicensesPagedResponse listUserLicenses(UserStoreName parent)
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
UserStoreName parent = UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]");
for (UserLicense element : userLicenseServiceClient.listUserLicenses(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent [UserStore][] resource name, format:
`projects/{project}/locations/{location}/userStores/{user_store_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final UserLicenseServiceClient.ListUserLicensesPagedResponse listUserLicenses(String parent)
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
String parent = UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]").toString();
for (UserLicense element : userLicenseServiceClient.listUserLicenses(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent [UserStore][] resource name, format:
`projects/{project}/locations/{location}/userStores/{user_store_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final UserLicenseServiceClient.ListUserLicensesPagedResponse listUserLicenses(ListUserLicensesRequest request)
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
ListUserLicensesRequest request =
ListUserLicensesRequest.newBuilder()
.setParent(UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
for (UserLicense element : userLicenseServiceClient.listUserLicenses(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListUserLicensesRequest,UserLicenseServiceClient.ListUserLicensesPagedResponse> listUserLicensesPagedCallable()
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
ListUserLicensesRequest request =
ListUserLicensesRequest.newBuilder()
.setParent(UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
ApiFuture<UserLicense> future =
userLicenseServiceClient.listUserLicensesPagedCallable().futureCall(request);
// Do something.
for (UserLicense element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListUserLicensesRequest,ListUserLicensesResponse> listUserLicensesCallable()
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
ListUserLicensesRequest request =
ListUserLicensesRequest.newBuilder()
.setParent(UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
while (true) {
ListUserLicensesResponse response =
userLicenseServiceClient.listUserLicensesCallable().call(request);
for (UserLicense element : response.getUserLicensesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.api.gax.longrunning.OperationFuture<BatchUpdateUserLicensesResponse,BatchUpdateUserLicensesMetadata> batchUpdateUserLicensesAsync(BatchUpdateUserLicensesRequest request)
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
BatchUpdateUserLicensesRequest request =
BatchUpdateUserLicensesRequest.newBuilder()
.setParent(UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]").toString())
.setDeleteUnassignedUserLicenses(true)
.build();
BatchUpdateUserLicensesResponse response =
userLicenseServiceClient.batchUpdateUserLicensesAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<BatchUpdateUserLicensesRequest,BatchUpdateUserLicensesResponse,BatchUpdateUserLicensesMetadata> batchUpdateUserLicensesOperationCallable()
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
BatchUpdateUserLicensesRequest request =
BatchUpdateUserLicensesRequest.newBuilder()
.setParent(UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]").toString())
.setDeleteUnassignedUserLicenses(true)
.build();
OperationFuture<BatchUpdateUserLicensesResponse, BatchUpdateUserLicensesMetadata> future =
userLicenseServiceClient.batchUpdateUserLicensesOperationCallable().futureCall(request);
// Do something.
BatchUpdateUserLicensesResponse response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<BatchUpdateUserLicensesRequest,com.google.longrunning.Operation> batchUpdateUserLicensesCallable()
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 (UserLicenseServiceClient userLicenseServiceClient = UserLicenseServiceClient.create()) {
BatchUpdateUserLicensesRequest request =
BatchUpdateUserLicensesRequest.newBuilder()
.setParent(UserStoreName.of("[PROJECT]", "[LOCATION]", "[USER_STORE]").toString())
.setDeleteUnassignedUserLicenses(true)
.build();
ApiFuture<Operation> future =
userLicenseServiceClient.batchUpdateUserLicensesCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2026 Google LLC. All rights reserved.