@Generated(value="by gapic-generator") @BetaApi public class AcceleratorTypeClient 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 (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
ProjectZoneAcceleratorTypeName acceleratorType = ProjectZoneAcceleratorTypeName.of("[PROJECT]", "[ZONE]", "[ACCELERATOR_TYPE]");
AcceleratorType response = acceleratorTypeClient.getAcceleratorType(acceleratorType);
}
Note: close() needs to be called on the acceleratorTypeClient 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 AcceleratorTypeSettings to create(). For example:
To customize credentials:
AcceleratorTypeSettings acceleratorTypeSettings =
AcceleratorTypeSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AcceleratorTypeClient acceleratorTypeClient =
AcceleratorTypeClient.create(acceleratorTypeSettings);
To customize the endpoint:
AcceleratorTypeSettings acceleratorTypeSettings =
AcceleratorTypeSettings.newBuilder().setEndpoint(myEndpoint).build();
AcceleratorTypeClient acceleratorTypeClient =
AcceleratorTypeClient.create(acceleratorTypeSettings);
Modifier and Type | Class and Description |
---|---|
static class |
AcceleratorTypeClient.AggregatedListAcceleratorTypesFixedSizeCollection |
static class |
AcceleratorTypeClient.AggregatedListAcceleratorTypesPage |
static class |
AcceleratorTypeClient.AggregatedListAcceleratorTypesPagedResponse |
static class |
AcceleratorTypeClient.ListAcceleratorTypesFixedSizeCollection |
static class |
AcceleratorTypeClient.ListAcceleratorTypesPage |
static class |
AcceleratorTypeClient.ListAcceleratorTypesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
AcceleratorTypeClient(AcceleratorTypeSettings settings)
Constructs an instance of AcceleratorTypeClient, using the given settings.
|
protected |
AcceleratorTypeClient(AcceleratorTypeStub stub) |
protected AcceleratorTypeClient(AcceleratorTypeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected AcceleratorTypeClient(AcceleratorTypeStub stub)
public static final AcceleratorTypeClient create() throws IOException
IOException
public static final AcceleratorTypeClient create(AcceleratorTypeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final AcceleratorTypeClient create(AcceleratorTypeStub stub)
public final AcceleratorTypeSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public AcceleratorTypeStub getStub()
@BetaApi public final AcceleratorTypeClient.AggregatedListAcceleratorTypesPagedResponse aggregatedListAcceleratorTypes(ProjectName project)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (AcceleratorTypesScopedList element : acceleratorTypeClient.aggregatedListAcceleratorTypes(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final AcceleratorTypeClient.AggregatedListAcceleratorTypesPagedResponse aggregatedListAcceleratorTypes(String project)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (AcceleratorTypesScopedList element : acceleratorTypeClient.aggregatedListAcceleratorTypes(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final AcceleratorTypeClient.AggregatedListAcceleratorTypesPagedResponse aggregatedListAcceleratorTypes(AggregatedListAcceleratorTypesHttpRequest request)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAcceleratorTypesHttpRequest request = AggregatedListAcceleratorTypesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (AcceleratorTypesScopedList element : acceleratorTypeClient.aggregatedListAcceleratorTypes(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 fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListAcceleratorTypesHttpRequest,AcceleratorTypeClient.AggregatedListAcceleratorTypesPagedResponse> aggregatedListAcceleratorTypesPagedCallable()
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAcceleratorTypesHttpRequest request = AggregatedListAcceleratorTypesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListAcceleratorTypesPagedResponse> future = acceleratorTypeClient.aggregatedListAcceleratorTypesPagedCallable().futureCall(request);
// Do something
for (AcceleratorTypesScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListAcceleratorTypesHttpRequest,AcceleratorTypeAggregatedList> aggregatedListAcceleratorTypesCallable()
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAcceleratorTypesHttpRequest request = AggregatedListAcceleratorTypesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
AcceleratorTypeAggregatedList response = acceleratorTypeClient.aggregatedListAcceleratorTypesCallable().call(request);
for (AcceleratorTypesScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final AcceleratorType getAcceleratorType(ProjectZoneAcceleratorTypeName acceleratorType)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
ProjectZoneAcceleratorTypeName acceleratorType = ProjectZoneAcceleratorTypeName.of("[PROJECT]", "[ZONE]", "[ACCELERATOR_TYPE]");
AcceleratorType response = acceleratorTypeClient.getAcceleratorType(acceleratorType);
}
acceleratorType
- Name of the accelerator type to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final AcceleratorType getAcceleratorType(String acceleratorType)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
ProjectZoneAcceleratorTypeName acceleratorType = ProjectZoneAcceleratorTypeName.of("[PROJECT]", "[ZONE]", "[ACCELERATOR_TYPE]");
AcceleratorType response = acceleratorTypeClient.getAcceleratorType(acceleratorType.toString());
}
acceleratorType
- Name of the accelerator type to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final AcceleratorType getAcceleratorType(GetAcceleratorTypeHttpRequest request)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedAcceleratorType = ProjectZoneAcceleratorTypeName.format("[PROJECT]", "[ZONE]", "[ACCELERATOR_TYPE]");
GetAcceleratorTypeHttpRequest request = GetAcceleratorTypeHttpRequest.newBuilder()
.setAcceleratorType(formattedAcceleratorType)
.build();
AcceleratorType response = acceleratorTypeClient.getAcceleratorType(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<GetAcceleratorTypeHttpRequest,AcceleratorType> getAcceleratorTypeCallable()
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedAcceleratorType = ProjectZoneAcceleratorTypeName.format("[PROJECT]", "[ZONE]", "[ACCELERATOR_TYPE]");
GetAcceleratorTypeHttpRequest request = GetAcceleratorTypeHttpRequest.newBuilder()
.setAcceleratorType(formattedAcceleratorType)
.build();
ApiFuture<AcceleratorType> future = acceleratorTypeClient.getAcceleratorTypeCallable().futureCall(request);
// Do something
AcceleratorType response = future.get();
}
@BetaApi public final AcceleratorTypeClient.ListAcceleratorTypesPagedResponse listAcceleratorTypes(ProjectZoneName zone)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (AcceleratorType element : acceleratorTypeClient.listAcceleratorTypes(zone).iterateAll()) {
// doThingsWith(element);
}
}
zone
- The name of the zone for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final AcceleratorTypeClient.ListAcceleratorTypesPagedResponse listAcceleratorTypes(String zone)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (AcceleratorType element : acceleratorTypeClient.listAcceleratorTypes(zone.toString()).iterateAll()) {
// doThingsWith(element);
}
}
zone
- The name of the zone for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final AcceleratorTypeClient.ListAcceleratorTypesPagedResponse listAcceleratorTypes(ListAcceleratorTypesHttpRequest request)
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListAcceleratorTypesHttpRequest request = ListAcceleratorTypesHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
for (AcceleratorType element : acceleratorTypeClient.listAcceleratorTypes(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 fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListAcceleratorTypesHttpRequest,AcceleratorTypeClient.ListAcceleratorTypesPagedResponse> listAcceleratorTypesPagedCallable()
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListAcceleratorTypesHttpRequest request = ListAcceleratorTypesHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
ApiFuture<ListAcceleratorTypesPagedResponse> future = acceleratorTypeClient.listAcceleratorTypesPagedCallable().futureCall(request);
// Do something
for (AcceleratorType element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListAcceleratorTypesHttpRequest,AcceleratorTypeList> listAcceleratorTypesCallable()
Sample code:
try (AcceleratorTypeClient acceleratorTypeClient = AcceleratorTypeClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListAcceleratorTypesHttpRequest request = ListAcceleratorTypesHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
while (true) {
AcceleratorTypeList response = acceleratorTypeClient.listAcceleratorTypesCallable().call(request);
for (AcceleratorType element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
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.