@Generated(value="by gapic-generator") @BetaApi public class DiskTypeClient 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 (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
ProjectZoneDiskTypeName diskType = ProjectZoneDiskTypeName.of("[PROJECT]", "[ZONE]", "[DISK_TYPE]");
DiskType response = diskTypeClient.getDiskType(diskType);
}
Note: close() needs to be called on the diskTypeClient 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 DiskTypeSettings to create(). For example:
To customize credentials:
DiskTypeSettings diskTypeSettings =
DiskTypeSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DiskTypeClient diskTypeClient =
DiskTypeClient.create(diskTypeSettings);
To customize the endpoint:
DiskTypeSettings diskTypeSettings =
DiskTypeSettings.newBuilder().setEndpoint(myEndpoint).build();
DiskTypeClient diskTypeClient =
DiskTypeClient.create(diskTypeSettings);
Modifier and Type | Class and Description |
---|---|
static class |
DiskTypeClient.AggregatedListDiskTypesFixedSizeCollection |
static class |
DiskTypeClient.AggregatedListDiskTypesPage |
static class |
DiskTypeClient.AggregatedListDiskTypesPagedResponse |
static class |
DiskTypeClient.ListDiskTypesFixedSizeCollection |
static class |
DiskTypeClient.ListDiskTypesPage |
static class |
DiskTypeClient.ListDiskTypesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
DiskTypeClient(DiskTypeSettings settings)
Constructs an instance of DiskTypeClient, using the given settings.
|
protected |
DiskTypeClient(DiskTypeStub stub) |
Modifier and Type | Method and Description |
---|---|
DiskTypeClient.AggregatedListDiskTypesPagedResponse |
aggregatedListDiskTypes(AggregatedListDiskTypesHttpRequest request)
Retrieves an aggregated list of disk types.
|
DiskTypeClient.AggregatedListDiskTypesPagedResponse |
aggregatedListDiskTypes(ProjectName project)
Retrieves an aggregated list of disk types.
|
DiskTypeClient.AggregatedListDiskTypesPagedResponse |
aggregatedListDiskTypes(String project)
Retrieves an aggregated list of disk types.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListDiskTypesHttpRequest,DiskTypeAggregatedList> |
aggregatedListDiskTypesCallable()
Retrieves an aggregated list of disk types.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListDiskTypesHttpRequest,DiskTypeClient.AggregatedListDiskTypesPagedResponse> |
aggregatedListDiskTypesPagedCallable()
Retrieves an aggregated list of disk types.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static DiskTypeClient |
create()
Constructs an instance of DiskTypeClient with default settings.
|
static DiskTypeClient |
create(DiskTypeSettings settings)
Constructs an instance of DiskTypeClient, using the given settings.
|
static DiskTypeClient |
create(DiskTypeStub stub)
Constructs an instance of DiskTypeClient, using the given stub for making calls.
|
DiskType |
getDiskType(GetDiskTypeHttpRequest request)
Returns the specified disk type.
|
DiskType |
getDiskType(ProjectZoneDiskTypeName diskType)
Returns the specified disk type.
|
DiskType |
getDiskType(String diskType)
Returns the specified disk type.
|
com.google.api.gax.rpc.UnaryCallable<GetDiskTypeHttpRequest,DiskType> |
getDiskTypeCallable()
Returns the specified disk type.
|
DiskTypeSettings |
getSettings() |
DiskTypeStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
DiskTypeClient.ListDiskTypesPagedResponse |
listDiskTypes(ListDiskTypesHttpRequest request)
Retrieves a list of disk types available to the specified project.
|
DiskTypeClient.ListDiskTypesPagedResponse |
listDiskTypes(ProjectZoneName zone)
Retrieves a list of disk types available to the specified project.
|
DiskTypeClient.ListDiskTypesPagedResponse |
listDiskTypes(String zone)
Retrieves a list of disk types available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListDiskTypesHttpRequest,DiskTypeList> |
listDiskTypesCallable()
Retrieves a list of disk types available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListDiskTypesHttpRequest,DiskTypeClient.ListDiskTypesPagedResponse> |
listDiskTypesPagedCallable()
Retrieves a list of disk types available to the specified project.
|
void |
shutdown() |
void |
shutdownNow() |
protected DiskTypeClient(DiskTypeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected DiskTypeClient(DiskTypeStub stub)
public static final DiskTypeClient create() throws IOException
IOException
public static final DiskTypeClient create(DiskTypeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final DiskTypeClient create(DiskTypeStub stub)
public final DiskTypeSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public DiskTypeStub getStub()
@BetaApi public final DiskTypeClient.AggregatedListDiskTypesPagedResponse aggregatedListDiskTypes(ProjectName project)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (DiskTypesScopedList element : diskTypeClient.aggregatedListDiskTypes(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final DiskTypeClient.AggregatedListDiskTypesPagedResponse aggregatedListDiskTypes(String project)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (DiskTypesScopedList element : diskTypeClient.aggregatedListDiskTypes(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 DiskTypeClient.AggregatedListDiskTypesPagedResponse aggregatedListDiskTypes(AggregatedListDiskTypesHttpRequest request)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListDiskTypesHttpRequest request = AggregatedListDiskTypesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (DiskTypesScopedList element : diskTypeClient.aggregatedListDiskTypes(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<AggregatedListDiskTypesHttpRequest,DiskTypeClient.AggregatedListDiskTypesPagedResponse> aggregatedListDiskTypesPagedCallable()
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListDiskTypesHttpRequest request = AggregatedListDiskTypesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListDiskTypesPagedResponse> future = diskTypeClient.aggregatedListDiskTypesPagedCallable().futureCall(request);
// Do something
for (DiskTypesScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListDiskTypesHttpRequest,DiskTypeAggregatedList> aggregatedListDiskTypesCallable()
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListDiskTypesHttpRequest request = AggregatedListDiskTypesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
DiskTypeAggregatedList response = diskTypeClient.aggregatedListDiskTypesCallable().call(request);
for (DiskTypesScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final DiskType getDiskType(ProjectZoneDiskTypeName diskType)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
ProjectZoneDiskTypeName diskType = ProjectZoneDiskTypeName.of("[PROJECT]", "[ZONE]", "[DISK_TYPE]");
DiskType response = diskTypeClient.getDiskType(diskType);
}
diskType
- Name of the disk type to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final DiskType getDiskType(String diskType)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
ProjectZoneDiskTypeName diskType = ProjectZoneDiskTypeName.of("[PROJECT]", "[ZONE]", "[DISK_TYPE]");
DiskType response = diskTypeClient.getDiskType(diskType.toString());
}
diskType
- Name of the disk type to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final DiskType getDiskType(GetDiskTypeHttpRequest request)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedDiskType = ProjectZoneDiskTypeName.format("[PROJECT]", "[ZONE]", "[DISK_TYPE]");
GetDiskTypeHttpRequest request = GetDiskTypeHttpRequest.newBuilder()
.setDiskType(formattedDiskType)
.build();
DiskType response = diskTypeClient.getDiskType(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<GetDiskTypeHttpRequest,DiskType> getDiskTypeCallable()
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedDiskType = ProjectZoneDiskTypeName.format("[PROJECT]", "[ZONE]", "[DISK_TYPE]");
GetDiskTypeHttpRequest request = GetDiskTypeHttpRequest.newBuilder()
.setDiskType(formattedDiskType)
.build();
ApiFuture<DiskType> future = diskTypeClient.getDiskTypeCallable().futureCall(request);
// Do something
DiskType response = future.get();
}
@BetaApi public final DiskTypeClient.ListDiskTypesPagedResponse listDiskTypes(ProjectZoneName zone)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (DiskType element : diskTypeClient.listDiskTypes(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 DiskTypeClient.ListDiskTypesPagedResponse listDiskTypes(String zone)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (DiskType element : diskTypeClient.listDiskTypes(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 DiskTypeClient.ListDiskTypesPagedResponse listDiskTypes(ListDiskTypesHttpRequest request)
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListDiskTypesHttpRequest request = ListDiskTypesHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
for (DiskType element : diskTypeClient.listDiskTypes(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<ListDiskTypesHttpRequest,DiskTypeClient.ListDiskTypesPagedResponse> listDiskTypesPagedCallable()
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListDiskTypesHttpRequest request = ListDiskTypesHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
ApiFuture<ListDiskTypesPagedResponse> future = diskTypeClient.listDiskTypesPagedCallable().futureCall(request);
// Do something
for (DiskType element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListDiskTypesHttpRequest,DiskTypeList> listDiskTypesCallable()
Sample code:
try (DiskTypeClient diskTypeClient = DiskTypeClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListDiskTypesHttpRequest request = ListDiskTypesHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
while (true) {
DiskTypeList response = diskTypeClient.listDiskTypesCallable().call(request);
for (DiskType 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.