Class RegionZonesClient (1.49.0)

GitHub RepositoryProduct Reference

Service Description: The RegionZones API.

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 (RegionZonesClient regionZonesClient = RegionZonesClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   for (Zone element : regionZonesClient.list(project, region).iterateAll()) {
     // doThingsWith(element);
   }
 }
 

Note: close() needs to be called on the RegionZonesClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
MethodDescriptionMethod Variants

List

Retrieves the list of Zone resources under the specific region available to the specified project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • list(ListRegionZonesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • list(String project, String region)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listPagedCallable()

  • listCallable()

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 RegionZonesSettings 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
 RegionZonesSettings regionZonesSettings =
     RegionZonesSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 RegionZonesClient regionZonesClient = RegionZonesClient.create(regionZonesSettings);
 

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
 RegionZonesSettings regionZonesSettings =
     RegionZonesSettings.newBuilder().setEndpoint(myEndpoint).build();
 RegionZonesClient regionZonesClient = RegionZonesClient.create(regionZonesSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > RegionZonesClient

Static Methods

create()

public static final RegionZonesClient create()

Constructs an instance of RegionZonesClient with default settings.

Returns
TypeDescription
RegionZonesClient
Exceptions
TypeDescription
IOException

create(RegionZonesSettings settings)

public static final RegionZonesClient create(RegionZonesSettings settings)

Constructs an instance of RegionZonesClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsRegionZonesSettings
Returns
TypeDescription
RegionZonesClient
Exceptions
TypeDescription
IOException

create(RegionZonesStub stub)

public static final RegionZonesClient create(RegionZonesStub stub)

Constructs an instance of RegionZonesClient, using the given stub for making calls. This is for advanced usage - prefer using create(RegionZonesSettings).

Parameter
NameDescription
stubRegionZonesStub
Returns
TypeDescription
RegionZonesClient

Constructors

RegionZonesClient(RegionZonesSettings settings)

protected RegionZonesClient(RegionZonesSettings settings)

Constructs an instance of RegionZonesClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsRegionZonesSettings

RegionZonesClient(RegionZonesStub stub)

protected RegionZonesClient(RegionZonesStub stub)
Parameter
NameDescription
stubRegionZonesStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

getSettings()

public final RegionZonesSettings getSettings()
Returns
TypeDescription
RegionZonesSettings

getStub()

public RegionZonesStub getStub()
Returns
TypeDescription
RegionZonesStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

list(ListRegionZonesRequest request)

public final RegionZonesClient.ListPagedResponse list(ListRegionZonesRequest request)

Retrieves the list of Zone resources under the specific region available to the specified 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 (RegionZonesClient regionZonesClient = RegionZonesClient.create()) {
   ListRegionZonesRequest request =
       ListRegionZonesRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setReturnPartialSuccess(true)
           .build();
   for (Zone element : regionZonesClient.list(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListRegionZonesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
RegionZonesClient.ListPagedResponse

list(String project, String region)

public final RegionZonesClient.ListPagedResponse list(String project, String region)

Retrieves the list of Zone resources under the specific region available to the specified 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 (RegionZonesClient regionZonesClient = RegionZonesClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   for (Zone element : regionZonesClient.list(project, region).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Region for this request.

Returns
TypeDescription
RegionZonesClient.ListPagedResponse

listCallable()

public final UnaryCallable<ListRegionZonesRequest,ZoneList> listCallable()

Retrieves the list of Zone resources under the specific region available to the specified 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 (RegionZonesClient regionZonesClient = RegionZonesClient.create()) {
   ListRegionZonesRequest request =
       ListRegionZonesRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setReturnPartialSuccess(true)
           .build();
   while (true) {
     ZoneList response = regionZonesClient.listCallable().call(request);
     for (Zone element : response.getItemsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListRegionZonesRequest,ZoneList>

listPagedCallable()

public final UnaryCallable<ListRegionZonesRequest,RegionZonesClient.ListPagedResponse> listPagedCallable()

Retrieves the list of Zone resources under the specific region available to the specified 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 (RegionZonesClient regionZonesClient = RegionZonesClient.create()) {
   ListRegionZonesRequest request =
       ListRegionZonesRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setReturnPartialSuccess(true)
           .build();
   ApiFuture<Zone> future = regionZonesClient.listPagedCallable().futureCall(request);
   // Do something.
   for (Zone element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListRegionZonesRequest,ListPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()