@Generated(value="by gapic-generator") @BetaApi public class LicenseClient extends Object implements 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:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseName license = ProjectGlobalLicenseName.of("[PROJECT]", "[LICENSE]");
Operation response = licenseClient.deleteLicense(license);
}
Note: close() needs to be called on the licenseClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
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 LicenseSettings to create(). For example:
To customize credentials:
LicenseSettings licenseSettings =
LicenseSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
LicenseClient licenseClient =
LicenseClient.create(licenseSettings);
To customize the endpoint:
LicenseSettings licenseSettings =
LicenseSettings.newBuilder().setEndpoint(myEndpoint).build();
LicenseClient licenseClient =
LicenseClient.create(licenseSettings);
Modifier and Type | Class and Description |
---|---|
static class |
LicenseClient.ListLicensesFixedSizeCollection |
static class |
LicenseClient.ListLicensesPage |
static class |
LicenseClient.ListLicensesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
LicenseClient(LicenseSettings settings)
Constructs an instance of LicenseClient, using the given settings.
|
protected |
LicenseClient(LicenseStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static LicenseClient |
create()
Constructs an instance of LicenseClient with default settings.
|
static LicenseClient |
create(LicenseSettings settings)
Constructs an instance of LicenseClient, using the given settings.
|
static LicenseClient |
create(LicenseStub stub)
Constructs an instance of LicenseClient, using the given stub for making calls.
|
Operation |
deleteLicense(DeleteLicenseHttpRequest request)
Deletes the specified license.
|
Operation |
deleteLicense(ProjectGlobalLicenseName license)
Deletes the specified license.
|
Operation |
deleteLicense(String license)
Deletes the specified license.
|
UnaryCallable<DeleteLicenseHttpRequest,Operation> |
deleteLicenseCallable()
Deletes the specified license.
|
Policy |
getIamPolicyLicense(GetIamPolicyLicenseHttpRequest request)
Gets the access control policy for a resource.
|
Policy |
getIamPolicyLicense(ProjectGlobalLicenseResourceName resource)
Gets the access control policy for a resource.
|
Policy |
getIamPolicyLicense(String resource)
Gets the access control policy for a resource.
|
UnaryCallable<GetIamPolicyLicenseHttpRequest,Policy> |
getIamPolicyLicenseCallable()
Gets the access control policy for a resource.
|
License |
getLicense(GetLicenseHttpRequest request)
Returns the specified License resource.
|
License |
getLicense(ProjectGlobalLicenseName license)
Returns the specified License resource.
|
License |
getLicense(String license)
Returns the specified License resource.
|
UnaryCallable<GetLicenseHttpRequest,License> |
getLicenseCallable()
Returns the specified License resource.
|
LicenseSettings |
getSettings() |
LicenseStub |
getStub() |
Operation |
insertLicense(InsertLicenseHttpRequest request)
Create a License resource in the specified project.
|
Operation |
insertLicense(ProjectName project,
License licenseResource)
Create a License resource in the specified project.
|
Operation |
insertLicense(String project,
License licenseResource)
Create a License resource in the specified project.
|
UnaryCallable<InsertLicenseHttpRequest,Operation> |
insertLicenseCallable()
Create a License resource in the specified project.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
LicenseClient.ListLicensesPagedResponse |
listLicenses(ListLicensesHttpRequest request)
Retrieves the list of licenses available in the specified project.
|
LicenseClient.ListLicensesPagedResponse |
listLicenses(ProjectName project)
Retrieves the list of licenses available in the specified project.
|
LicenseClient.ListLicensesPagedResponse |
listLicenses(String project)
Retrieves the list of licenses available in the specified project.
|
UnaryCallable<ListLicensesHttpRequest,LicensesListResponse> |
listLicensesCallable()
Retrieves the list of licenses available in the specified project.
|
UnaryCallable<ListLicensesHttpRequest,LicenseClient.ListLicensesPagedResponse> |
listLicensesPagedCallable()
Retrieves the list of licenses available in the specified project.
|
Policy |
setIamPolicyLicense(ProjectGlobalLicenseResourceName resource,
GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicyLicense(SetIamPolicyLicenseHttpRequest request)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicyLicense(String resource,
GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
UnaryCallable<SetIamPolicyLicenseHttpRequest,Policy> |
setIamPolicyLicenseCallable()
Sets the access control policy on the specified resource.
|
void |
shutdown() |
void |
shutdownNow() |
TestPermissionsResponse |
testIamPermissionsLicense(ProjectGlobalLicenseResourceName resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsLicense(String resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsLicense(TestIamPermissionsLicenseHttpRequest request)
Returns permissions that a caller has on the specified resource.
|
UnaryCallable<TestIamPermissionsLicenseHttpRequest,TestPermissionsResponse> |
testIamPermissionsLicenseCallable()
Returns permissions that a caller has on the specified resource.
|
protected LicenseClient(LicenseSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected LicenseClient(LicenseStub stub)
public static final LicenseClient create() throws IOException
IOException
public static final LicenseClient create(LicenseSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final LicenseClient create(LicenseStub stub)
public final LicenseSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public LicenseStub getStub()
@BetaApi public final Operation deleteLicense(ProjectGlobalLicenseName license)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseName license = ProjectGlobalLicenseName.of("[PROJECT]", "[LICENSE]");
Operation response = licenseClient.deleteLicense(license);
}
license
- Name of the license resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteLicense(String license)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseName license = ProjectGlobalLicenseName.of("[PROJECT]", "[LICENSE]");
Operation response = licenseClient.deleteLicense(license.toString());
}
license
- Name of the license resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteLicense(DeleteLicenseHttpRequest request)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedLicense = ProjectGlobalLicenseName.format("[PROJECT]", "[LICENSE]");
DeleteLicenseHttpRequest request = DeleteLicenseHttpRequest.newBuilder()
.setLicense(formattedLicense)
.build();
Operation response = licenseClient.deleteLicense(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteLicenseHttpRequest,Operation> deleteLicenseCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedLicense = ProjectGlobalLicenseName.format("[PROJECT]", "[LICENSE]");
DeleteLicenseHttpRequest request = DeleteLicenseHttpRequest.newBuilder()
.setLicense(formattedLicense)
.build();
ApiFuture<Operation> future = licenseClient.deleteLicenseCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final License getLicense(ProjectGlobalLicenseName license)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseName license = ProjectGlobalLicenseName.of("[PROJECT]", "[LICENSE]");
License response = licenseClient.getLicense(license);
}
license
- Name of the License resource to return.ApiException
- if the remote call fails@BetaApi public final License getLicense(String license)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseName license = ProjectGlobalLicenseName.of("[PROJECT]", "[LICENSE]");
License response = licenseClient.getLicense(license.toString());
}
license
- Name of the License resource to return.ApiException
- if the remote call fails@BetaApi public final License getLicense(GetLicenseHttpRequest request)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedLicense = ProjectGlobalLicenseName.format("[PROJECT]", "[LICENSE]");
GetLicenseHttpRequest request = GetLicenseHttpRequest.newBuilder()
.setLicense(formattedLicense)
.build();
License response = licenseClient.getLicense(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetLicenseHttpRequest,License> getLicenseCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedLicense = ProjectGlobalLicenseName.format("[PROJECT]", "[LICENSE]");
GetLicenseHttpRequest request = GetLicenseHttpRequest.newBuilder()
.setLicense(formattedLicense)
.build();
ApiFuture<License> future = licenseClient.getLicenseCallable().futureCall(request);
// Do something
License response = future.get();
}
@BetaApi public final Policy getIamPolicyLicense(ProjectGlobalLicenseResourceName resource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseResourceName resource = ProjectGlobalLicenseResourceName.of("[PROJECT]", "[RESOURCE]");
Policy response = licenseClient.getIamPolicyLicense(resource);
}
resource
- Name or id of the resource for this request.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicyLicense(String resource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseResourceName resource = ProjectGlobalLicenseResourceName.of("[PROJECT]", "[RESOURCE]");
Policy response = licenseClient.getIamPolicyLicense(resource.toString());
}
resource
- Name or id of the resource for this request.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicyLicense(GetIamPolicyLicenseHttpRequest request)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedResource = ProjectGlobalLicenseResourceName.format("[PROJECT]", "[RESOURCE]");
GetIamPolicyLicenseHttpRequest request = GetIamPolicyLicenseHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
Policy response = licenseClient.getIamPolicyLicense(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetIamPolicyLicenseHttpRequest,Policy> getIamPolicyLicenseCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedResource = ProjectGlobalLicenseResourceName.format("[PROJECT]", "[RESOURCE]");
GetIamPolicyLicenseHttpRequest request = GetIamPolicyLicenseHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
ApiFuture<Policy> future = licenseClient.getIamPolicyLicenseCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final Operation insertLicense(ProjectName project, License licenseResource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
License licenseResource = License.newBuilder().build();
Operation response = licenseClient.insertLicense(project, licenseResource);
}
project
- Project ID for this request.licenseResource
- A license resource.ApiException
- if the remote call fails@BetaApi public final Operation insertLicense(String project, License licenseResource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
License licenseResource = License.newBuilder().build();
Operation response = licenseClient.insertLicense(project.toString(), licenseResource);
}
project
- Project ID for this request.licenseResource
- A license resource.ApiException
- if the remote call fails@BetaApi public final Operation insertLicense(InsertLicenseHttpRequest request)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
License licenseResource = License.newBuilder().build();
InsertLicenseHttpRequest request = InsertLicenseHttpRequest.newBuilder()
.setProject(formattedProject)
.setLicenseResource(licenseResource)
.build();
Operation response = licenseClient.insertLicense(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertLicenseHttpRequest,Operation> insertLicenseCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
License licenseResource = License.newBuilder().build();
InsertLicenseHttpRequest request = InsertLicenseHttpRequest.newBuilder()
.setProject(formattedProject)
.setLicenseResource(licenseResource)
.build();
ApiFuture<Operation> future = licenseClient.insertLicenseCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final LicenseClient.ListLicensesPagedResponse listLicenses(ProjectName project)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (License element : licenseClient.listLicenses(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final LicenseClient.ListLicensesPagedResponse listLicenses(String project)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (License element : licenseClient.listLicenses(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final LicenseClient.ListLicensesPagedResponse listLicenses(ListLicensesHttpRequest request)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListLicensesHttpRequest request = ListLicensesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (License element : licenseClient.listLicenses(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<ListLicensesHttpRequest,LicenseClient.ListLicensesPagedResponse> listLicensesPagedCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListLicensesHttpRequest request = ListLicensesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListLicensesPagedResponse> future = licenseClient.listLicensesPagedCallable().futureCall(request);
// Do something
for (License element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListLicensesHttpRequest,LicensesListResponse> listLicensesCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListLicensesHttpRequest request = ListLicensesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
LicensesListResponse response = licenseClient.listLicensesCallable().call(request);
for (License element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Policy setIamPolicyLicense(ProjectGlobalLicenseResourceName resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseResourceName resource = ProjectGlobalLicenseResourceName.of("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
Policy response = licenseClient.setIamPolicyLicense(resource, globalSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.globalSetPolicyRequestResource
- ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicyLicense(String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseResourceName resource = ProjectGlobalLicenseResourceName.of("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
Policy response = licenseClient.setIamPolicyLicense(resource.toString(), globalSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.globalSetPolicyRequestResource
- ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicyLicense(SetIamPolicyLicenseHttpRequest request)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedResource = ProjectGlobalLicenseResourceName.format("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
SetIamPolicyLicenseHttpRequest request = SetIamPolicyLicenseHttpRequest.newBuilder()
.setResource(formattedResource)
.setGlobalSetPolicyRequestResource(globalSetPolicyRequestResource)
.build();
Policy response = licenseClient.setIamPolicyLicense(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<SetIamPolicyLicenseHttpRequest,Policy> setIamPolicyLicenseCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedResource = ProjectGlobalLicenseResourceName.format("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
SetIamPolicyLicenseHttpRequest request = SetIamPolicyLicenseHttpRequest.newBuilder()
.setResource(formattedResource)
.setGlobalSetPolicyRequestResource(globalSetPolicyRequestResource)
.build();
ApiFuture<Policy> future = licenseClient.setIamPolicyLicenseCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final TestPermissionsResponse testIamPermissionsLicense(ProjectGlobalLicenseResourceName resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseResourceName resource = ProjectGlobalLicenseResourceName.of("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = licenseClient.testIamPermissionsLicense(resource, testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsLicense(String resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
ProjectGlobalLicenseResourceName resource = ProjectGlobalLicenseResourceName.of("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = licenseClient.testIamPermissionsLicense(resource.toString(), testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsLicense(TestIamPermissionsLicenseHttpRequest request)
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedResource = ProjectGlobalLicenseResourceName.format("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsLicenseHttpRequest request = TestIamPermissionsLicenseHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
TestPermissionsResponse response = licenseClient.testIamPermissionsLicense(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<TestIamPermissionsLicenseHttpRequest,TestPermissionsResponse> testIamPermissionsLicenseCallable()
Sample code:
try (LicenseClient licenseClient = LicenseClient.create()) {
String formattedResource = ProjectGlobalLicenseResourceName.format("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsLicenseHttpRequest request = TestIamPermissionsLicenseHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
ApiFuture<TestPermissionsResponse> future = licenseClient.testIamPermissionsLicenseCallable().futureCall(request);
// Do something
TestPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.