@Generated(value="by gapic-generator-java") public class DiskTypesClient 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:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
String diskType = "diskType279771767";
DiskType response = diskTypesClient.get(project, zone, diskType);
}
Note: close() needs to be called on the DiskTypesClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
AggregatedList |
Retrieves an aggregated list of disk types. To prevent failure, Google recommends that you set the `returnPartialSuccess` parameter to `true`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
Get |
Returns the specified disk type. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
List |
Retrieves a list of disk types available to the specified project. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 DiskTypesSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DiskTypesSettings diskTypesSettings =
DiskTypesSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DiskTypesClient diskTypesClient = DiskTypesClient.create(diskTypesSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
DiskTypesSettings diskTypesSettings =
DiskTypesSettings.newBuilder().setEndpoint(myEndpoint).build();
DiskTypesClient diskTypesClient = DiskTypesClient.create(diskTypesSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
DiskTypesClient.AggregatedListFixedSizeCollection |
static class |
DiskTypesClient.AggregatedListPage |
static class |
DiskTypesClient.AggregatedListPagedResponse |
static class |
DiskTypesClient.ListFixedSizeCollection |
static class |
DiskTypesClient.ListPage |
static class |
DiskTypesClient.ListPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
DiskTypesClient(DiskTypesSettings settings)
Constructs an instance of DiskTypesClient, using the given settings.
|
protected |
DiskTypesClient(DiskTypesStub stub) |
| Modifier and Type | Method and Description |
|---|---|
DiskTypesClient.AggregatedListPagedResponse |
aggregatedList(AggregatedListDiskTypesRequest request)
Retrieves an aggregated list of disk types.
|
DiskTypesClient.AggregatedListPagedResponse |
aggregatedList(String project)
Retrieves an aggregated list of disk types.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListDiskTypesRequest,DiskTypeAggregatedList> |
aggregatedListCallable()
Retrieves an aggregated list of disk types.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListDiskTypesRequest,DiskTypesClient.AggregatedListPagedResponse> |
aggregatedListPagedCallable()
Retrieves an aggregated list of disk types.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static DiskTypesClient |
create()
Constructs an instance of DiskTypesClient with default settings.
|
static DiskTypesClient |
create(DiskTypesSettings settings)
Constructs an instance of DiskTypesClient, using the given settings.
|
static DiskTypesClient |
create(DiskTypesStub stub)
Constructs an instance of DiskTypesClient, using the given stub for making calls.
|
DiskType |
get(GetDiskTypeRequest request)
Returns the specified disk type.
|
DiskType |
get(String project,
String zone,
String diskType)
Returns the specified disk type.
|
com.google.api.gax.rpc.UnaryCallable<GetDiskTypeRequest,DiskType> |
getCallable()
Returns the specified disk type.
|
DiskTypesSettings |
getSettings() |
DiskTypesStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
DiskTypesClient.ListPagedResponse |
list(ListDiskTypesRequest request)
Retrieves a list of disk types available to the specified project.
|
DiskTypesClient.ListPagedResponse |
list(String project,
String zone)
Retrieves a list of disk types available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListDiskTypesRequest,DiskTypeList> |
listCallable()
Retrieves a list of disk types available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListDiskTypesRequest,DiskTypesClient.ListPagedResponse> |
listPagedCallable()
Retrieves a list of disk types available to the specified project.
|
void |
shutdown() |
void |
shutdownNow() |
protected DiskTypesClient(DiskTypesSettings settings) throws IOException
IOExceptionprotected DiskTypesClient(DiskTypesStub stub)
public static final DiskTypesClient create() throws IOException
IOExceptionpublic static final DiskTypesClient create(DiskTypesSettings settings) throws IOException
IOExceptionpublic static final DiskTypesClient create(DiskTypesStub stub)
public final DiskTypesSettings getSettings()
public DiskTypesStub getStub()
public final DiskTypesClient.AggregatedListPagedResponse aggregatedList(String project)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
String project = "project-309310695";
for (Map.Entry<String, DiskTypesScopedList> element :
diskTypesClient.aggregatedList(project).iterateAll()) {
// doThingsWith(element);
}
}
project - Project ID for this request.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DiskTypesClient.AggregatedListPagedResponse aggregatedList(AggregatedListDiskTypesRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
AggregatedListDiskTypesRequest request =
AggregatedListDiskTypesRequest.newBuilder()
.setFilter("filter-1274492040")
.setIncludeAllScopes(true)
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setReturnPartialSuccess(true)
.setServiceProjectNumber(-1293855239)
.build();
for (Map.Entry<String, DiskTypesScopedList> element :
diskTypesClient.aggregatedList(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 failspublic final com.google.api.gax.rpc.UnaryCallable<AggregatedListDiskTypesRequest,DiskTypesClient.AggregatedListPagedResponse> aggregatedListPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
AggregatedListDiskTypesRequest request =
AggregatedListDiskTypesRequest.newBuilder()
.setFilter("filter-1274492040")
.setIncludeAllScopes(true)
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setReturnPartialSuccess(true)
.setServiceProjectNumber(-1293855239)
.build();
ApiFuture<Map.Entry<String, DiskTypesScopedList>> future =
diskTypesClient.aggregatedListPagedCallable().futureCall(request);
// Do something.
for (Map.Entry<String, DiskTypesScopedList> element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<AggregatedListDiskTypesRequest,DiskTypeAggregatedList> aggregatedListCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
AggregatedListDiskTypesRequest request =
AggregatedListDiskTypesRequest.newBuilder()
.setFilter("filter-1274492040")
.setIncludeAllScopes(true)
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setReturnPartialSuccess(true)
.setServiceProjectNumber(-1293855239)
.build();
while (true) {
DiskTypeAggregatedList response = diskTypesClient.aggregatedListCallable().call(request);
for (Map.Entry<String, DiskTypesScopedList> element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final DiskType get(String project, String zone, String diskType)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
String diskType = "diskType279771767";
DiskType response = diskTypesClient.get(project, zone, diskType);
}
project - Project ID for this request.zone - The name of the zone for this request.diskType - Name of the disk type to return.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DiskType get(GetDiskTypeRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
GetDiskTypeRequest request =
GetDiskTypeRequest.newBuilder()
.setDiskType("diskType279771767")
.setProject("project-309310695")
.setZone("zone3744684")
.build();
DiskType response = diskTypesClient.get(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetDiskTypeRequest,DiskType> getCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
GetDiskTypeRequest request =
GetDiskTypeRequest.newBuilder()
.setDiskType("diskType279771767")
.setProject("project-309310695")
.setZone("zone3744684")
.build();
ApiFuture<DiskType> future = diskTypesClient.getCallable().futureCall(request);
// Do something.
DiskType response = future.get();
}
public final DiskTypesClient.ListPagedResponse list(String project, String zone)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
String project = "project-309310695";
String zone = "zone3744684";
for (DiskType element : diskTypesClient.list(project, zone).iterateAll()) {
// doThingsWith(element);
}
}
project - Project ID for this request.zone - The name of the zone for this request.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DiskTypesClient.ListPagedResponse list(ListDiskTypesRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
ListDiskTypesRequest request =
ListDiskTypesRequest.newBuilder()
.setFilter("filter-1274492040")
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setReturnPartialSuccess(true)
.setZone("zone3744684")
.build();
for (DiskType element : diskTypesClient.list(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 failspublic final com.google.api.gax.rpc.UnaryCallable<ListDiskTypesRequest,DiskTypesClient.ListPagedResponse> listPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
ListDiskTypesRequest request =
ListDiskTypesRequest.newBuilder()
.setFilter("filter-1274492040")
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setReturnPartialSuccess(true)
.setZone("zone3744684")
.build();
ApiFuture<DiskType> future = diskTypesClient.listPagedCallable().futureCall(request);
// Do something.
for (DiskType element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListDiskTypesRequest,DiskTypeList> listCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (DiskTypesClient diskTypesClient = DiskTypesClient.create()) {
ListDiskTypesRequest request =
ListDiskTypesRequest.newBuilder()
.setFilter("filter-1274492040")
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setReturnPartialSuccess(true)
.setZone("zone3744684")
.build();
while (true) {
DiskTypeList response = diskTypesClient.listCallable().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 AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2024 Google LLC. All rights reserved.