@Generated(value="by gapic-generator") @BetaApi public class LicenseCodeClient 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:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
ProjectGlobalLicenseCodeName licenseCode = ProjectGlobalLicenseCodeName.of("[PROJECT]", "[LICENSE_CODE]");
LicenseCode response = licenseCodeClient.getLicenseCode(licenseCode);
}
Note: close() needs to be called on the licenseCodeClient 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 LicenseCodeSettings to create(). For example:
To customize credentials:
LicenseCodeSettings licenseCodeSettings =
LicenseCodeSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
LicenseCodeClient licenseCodeClient =
LicenseCodeClient.create(licenseCodeSettings);
To customize the endpoint:
LicenseCodeSettings licenseCodeSettings =
LicenseCodeSettings.newBuilder().setEndpoint(myEndpoint).build();
LicenseCodeClient licenseCodeClient =
LicenseCodeClient.create(licenseCodeSettings);
Modifier | Constructor and Description |
---|---|
protected |
LicenseCodeClient(LicenseCodeSettings settings)
Constructs an instance of LicenseCodeClient, using the given settings.
|
protected |
LicenseCodeClient(LicenseCodeStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static LicenseCodeClient |
create()
Constructs an instance of LicenseCodeClient with default settings.
|
static LicenseCodeClient |
create(LicenseCodeSettings settings)
Constructs an instance of LicenseCodeClient, using the given settings.
|
static LicenseCodeClient |
create(LicenseCodeStub stub)
Constructs an instance of LicenseCodeClient, using the given stub for making calls.
|
LicenseCode |
getLicenseCode(GetLicenseCodeHttpRequest request)
Return a specified license code.
|
LicenseCode |
getLicenseCode(ProjectGlobalLicenseCodeName licenseCode)
Return a specified license code.
|
LicenseCode |
getLicenseCode(String licenseCode)
Return a specified license code.
|
com.google.api.gax.rpc.UnaryCallable<GetLicenseCodeHttpRequest,LicenseCode> |
getLicenseCodeCallable()
Return a specified license code.
|
LicenseCodeSettings |
getSettings() |
LicenseCodeStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
void |
shutdownNow() |
TestPermissionsResponse |
testIamPermissionsLicenseCode(ProjectGlobalLicenseCodeResourceName resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsLicenseCode(String resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsLicenseCode(TestIamPermissionsLicenseCodeHttpRequest request)
Returns permissions that a caller has on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsLicenseCodeHttpRequest,TestPermissionsResponse> |
testIamPermissionsLicenseCodeCallable()
Returns permissions that a caller has on the specified resource.
|
protected LicenseCodeClient(LicenseCodeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected LicenseCodeClient(LicenseCodeStub stub)
public static final LicenseCodeClient create() throws IOException
IOException
public static final LicenseCodeClient create(LicenseCodeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final LicenseCodeClient create(LicenseCodeStub stub)
public final LicenseCodeSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public LicenseCodeStub getStub()
@BetaApi public final LicenseCode getLicenseCode(ProjectGlobalLicenseCodeName licenseCode)
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
ProjectGlobalLicenseCodeName licenseCode = ProjectGlobalLicenseCodeName.of("[PROJECT]", "[LICENSE_CODE]");
LicenseCode response = licenseCodeClient.getLicenseCode(licenseCode);
}
licenseCode
- Number corresponding to the License code resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final LicenseCode getLicenseCode(String licenseCode)
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
ProjectGlobalLicenseCodeName licenseCode = ProjectGlobalLicenseCodeName.of("[PROJECT]", "[LICENSE_CODE]");
LicenseCode response = licenseCodeClient.getLicenseCode(licenseCode.toString());
}
licenseCode
- Number corresponding to the License code resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final LicenseCode getLicenseCode(GetLicenseCodeHttpRequest request)
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
String formattedLicenseCode = ProjectGlobalLicenseCodeName.format("[PROJECT]", "[LICENSE_CODE]");
GetLicenseCodeHttpRequest request = GetLicenseCodeHttpRequest.newBuilder()
.setLicenseCode(formattedLicenseCode)
.build();
LicenseCode response = licenseCodeClient.getLicenseCode(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<GetLicenseCodeHttpRequest,LicenseCode> getLicenseCodeCallable()
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
String formattedLicenseCode = ProjectGlobalLicenseCodeName.format("[PROJECT]", "[LICENSE_CODE]");
GetLicenseCodeHttpRequest request = GetLicenseCodeHttpRequest.newBuilder()
.setLicenseCode(formattedLicenseCode)
.build();
ApiFuture<LicenseCode> future = licenseCodeClient.getLicenseCodeCallable().futureCall(request);
// Do something
LicenseCode response = future.get();
}
@BetaApi public final TestPermissionsResponse testIamPermissionsLicenseCode(ProjectGlobalLicenseCodeResourceName resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
ProjectGlobalLicenseCodeResourceName resource = ProjectGlobalLicenseCodeResourceName.of("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = licenseCodeClient.testIamPermissionsLicenseCode(resource, testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsLicenseCode(String resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
ProjectGlobalLicenseCodeResourceName resource = ProjectGlobalLicenseCodeResourceName.of("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = licenseCodeClient.testIamPermissionsLicenseCode(resource.toString(), testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsLicenseCode(TestIamPermissionsLicenseCodeHttpRequest request)
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
String formattedResource = ProjectGlobalLicenseCodeResourceName.format("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsLicenseCodeHttpRequest request = TestIamPermissionsLicenseCodeHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
TestPermissionsResponse response = licenseCodeClient.testIamPermissionsLicenseCode(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsLicenseCodeHttpRequest,TestPermissionsResponse> testIamPermissionsLicenseCodeCallable()
Sample code:
try (LicenseCodeClient licenseCodeClient = LicenseCodeClient.create()) {
String formattedResource = ProjectGlobalLicenseCodeResourceName.format("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsLicenseCodeHttpRequest request = TestIamPermissionsLicenseCodeHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
ApiFuture<TestPermissionsResponse> future = licenseCodeClient.testIamPermissionsLicenseCodeCallable().futureCall(request);
// Do something
TestPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.