@Generated(value="by gapic-generator") @BetaApi public class RegionDiskTypeClient 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 (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
ProjectRegionDiskTypeName diskType = ProjectRegionDiskTypeName.of("[PROJECT]", "[REGION]", "[DISK_TYPE]");
DiskType response = regionDiskTypeClient.getRegionDiskType(diskType);
}
Note: close() needs to be called on the regionDiskTypeClient 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 RegionDiskTypeSettings to create(). For example:
To customize credentials:
RegionDiskTypeSettings regionDiskTypeSettings =
RegionDiskTypeSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
RegionDiskTypeClient regionDiskTypeClient =
RegionDiskTypeClient.create(regionDiskTypeSettings);
To customize the endpoint:
RegionDiskTypeSettings regionDiskTypeSettings =
RegionDiskTypeSettings.newBuilder().setEndpoint(myEndpoint).build();
RegionDiskTypeClient regionDiskTypeClient =
RegionDiskTypeClient.create(regionDiskTypeSettings);
Modifier and Type | Class and Description |
---|---|
static class |
RegionDiskTypeClient.ListRegionDiskTypesFixedSizeCollection |
static class |
RegionDiskTypeClient.ListRegionDiskTypesPage |
static class |
RegionDiskTypeClient.ListRegionDiskTypesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
RegionDiskTypeClient(RegionDiskTypeSettings settings)
Constructs an instance of RegionDiskTypeClient, using the given settings.
|
protected |
RegionDiskTypeClient(RegionDiskTypeStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static RegionDiskTypeClient |
create()
Constructs an instance of RegionDiskTypeClient with default settings.
|
static RegionDiskTypeClient |
create(RegionDiskTypeSettings settings)
Constructs an instance of RegionDiskTypeClient, using the given settings.
|
static RegionDiskTypeClient |
create(RegionDiskTypeStub stub)
Constructs an instance of RegionDiskTypeClient, using the given stub for making calls.
|
DiskType |
getRegionDiskType(GetRegionDiskTypeHttpRequest request)
Returns the specified regional disk type.
|
DiskType |
getRegionDiskType(ProjectRegionDiskTypeName diskType)
Returns the specified regional disk type.
|
DiskType |
getRegionDiskType(String diskType)
Returns the specified regional disk type.
|
com.google.api.gax.rpc.UnaryCallable<GetRegionDiskTypeHttpRequest,DiskType> |
getRegionDiskTypeCallable()
Returns the specified regional disk type.
|
RegionDiskTypeSettings |
getSettings() |
RegionDiskTypeStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
RegionDiskTypeClient.ListRegionDiskTypesPagedResponse |
listRegionDiskTypes(ListRegionDiskTypesHttpRequest request)
Retrieves a list of regional disk types available to the specified project.
|
RegionDiskTypeClient.ListRegionDiskTypesPagedResponse |
listRegionDiskTypes(ProjectRegionName region)
Retrieves a list of regional disk types available to the specified project.
|
RegionDiskTypeClient.ListRegionDiskTypesPagedResponse |
listRegionDiskTypes(String region)
Retrieves a list of regional disk types available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListRegionDiskTypesHttpRequest,RegionDiskTypeList> |
listRegionDiskTypesCallable()
Retrieves a list of regional disk types available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListRegionDiskTypesHttpRequest,RegionDiskTypeClient.ListRegionDiskTypesPagedResponse> |
listRegionDiskTypesPagedCallable()
Retrieves a list of regional disk types available to the specified project.
|
void |
shutdown() |
void |
shutdownNow() |
protected RegionDiskTypeClient(RegionDiskTypeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected RegionDiskTypeClient(RegionDiskTypeStub stub)
public static final RegionDiskTypeClient create() throws IOException
IOException
public static final RegionDiskTypeClient create(RegionDiskTypeSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final RegionDiskTypeClient create(RegionDiskTypeStub stub)
public final RegionDiskTypeSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public RegionDiskTypeStub getStub()
@BetaApi public final DiskType getRegionDiskType(ProjectRegionDiskTypeName diskType)
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
ProjectRegionDiskTypeName diskType = ProjectRegionDiskTypeName.of("[PROJECT]", "[REGION]", "[DISK_TYPE]");
DiskType response = regionDiskTypeClient.getRegionDiskType(diskType);
}
diskType
- Name of the disk type to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final DiskType getRegionDiskType(String diskType)
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
ProjectRegionDiskTypeName diskType = ProjectRegionDiskTypeName.of("[PROJECT]", "[REGION]", "[DISK_TYPE]");
DiskType response = regionDiskTypeClient.getRegionDiskType(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 getRegionDiskType(GetRegionDiskTypeHttpRequest request)
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
String formattedDiskType = ProjectRegionDiskTypeName.format("[PROJECT]", "[REGION]", "[DISK_TYPE]");
GetRegionDiskTypeHttpRequest request = GetRegionDiskTypeHttpRequest.newBuilder()
.setDiskType(formattedDiskType)
.build();
DiskType response = regionDiskTypeClient.getRegionDiskType(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<GetRegionDiskTypeHttpRequest,DiskType> getRegionDiskTypeCallable()
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
String formattedDiskType = ProjectRegionDiskTypeName.format("[PROJECT]", "[REGION]", "[DISK_TYPE]");
GetRegionDiskTypeHttpRequest request = GetRegionDiskTypeHttpRequest.newBuilder()
.setDiskType(formattedDiskType)
.build();
ApiFuture<DiskType> future = regionDiskTypeClient.getRegionDiskTypeCallable().futureCall(request);
// Do something
DiskType response = future.get();
}
@BetaApi public final RegionDiskTypeClient.ListRegionDiskTypesPagedResponse listRegionDiskTypes(ProjectRegionName region)
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (DiskType element : regionDiskTypeClient.listRegionDiskTypes(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- The name of the region for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final RegionDiskTypeClient.ListRegionDiskTypesPagedResponse listRegionDiskTypes(String region)
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (DiskType element : regionDiskTypeClient.listRegionDiskTypes(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- The name of the region for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final RegionDiskTypeClient.ListRegionDiskTypesPagedResponse listRegionDiskTypes(ListRegionDiskTypesHttpRequest request)
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRegionDiskTypesHttpRequest request = ListRegionDiskTypesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (DiskType element : regionDiskTypeClient.listRegionDiskTypes(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<ListRegionDiskTypesHttpRequest,RegionDiskTypeClient.ListRegionDiskTypesPagedResponse> listRegionDiskTypesPagedCallable()
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRegionDiskTypesHttpRequest request = ListRegionDiskTypesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListRegionDiskTypesPagedResponse> future = regionDiskTypeClient.listRegionDiskTypesPagedCallable().futureCall(request);
// Do something
for (DiskType element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListRegionDiskTypesHttpRequest,RegionDiskTypeList> listRegionDiskTypesCallable()
Sample code:
try (RegionDiskTypeClient regionDiskTypeClient = RegionDiskTypeClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRegionDiskTypesHttpRequest request = ListRegionDiskTypesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
RegionDiskTypeList response = regionDiskTypeClient.listRegionDiskTypesCallable().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.