@Generated(value="by gapic-generator") @BetaApi public class RegionInstanceGroupClient extends Object implements 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 (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionInstanceGroupName instanceGroup = ProjectRegionInstanceGroupName.of("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
InstanceGroup response = regionInstanceGroupClient.getRegionInstanceGroup(instanceGroup);
}
Note: close() needs to be called on the regionInstanceGroupClient 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 RegionInstanceGroupSettings to create(). For example:
To customize credentials:
RegionInstanceGroupSettings regionInstanceGroupSettings =
RegionInstanceGroupSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
RegionInstanceGroupClient regionInstanceGroupClient =
RegionInstanceGroupClient.create(regionInstanceGroupSettings);
To customize the endpoint:
RegionInstanceGroupSettings regionInstanceGroupSettings =
RegionInstanceGroupSettings.newBuilder().setEndpoint(myEndpoint).build();
RegionInstanceGroupClient regionInstanceGroupClient =
RegionInstanceGroupClient.create(regionInstanceGroupSettings);
Modifier and Type | Class and Description |
---|---|
static class |
RegionInstanceGroupClient.ListInstancesRegionInstanceGroupsFixedSizeCollection |
static class |
RegionInstanceGroupClient.ListInstancesRegionInstanceGroupsPage |
static class |
RegionInstanceGroupClient.ListInstancesRegionInstanceGroupsPagedResponse |
static class |
RegionInstanceGroupClient.ListRegionInstanceGroupsFixedSizeCollection |
static class |
RegionInstanceGroupClient.ListRegionInstanceGroupsPage |
static class |
RegionInstanceGroupClient.ListRegionInstanceGroupsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
RegionInstanceGroupClient(RegionInstanceGroupSettings settings)
Constructs an instance of RegionInstanceGroupClient, using the given settings.
|
protected |
RegionInstanceGroupClient(RegionInstanceGroupStub stub) |
protected RegionInstanceGroupClient(RegionInstanceGroupSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected RegionInstanceGroupClient(RegionInstanceGroupStub stub)
public static final RegionInstanceGroupClient create() throws IOException
IOException
public static final RegionInstanceGroupClient create(RegionInstanceGroupSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final RegionInstanceGroupClient create(RegionInstanceGroupStub stub)
public final RegionInstanceGroupSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public RegionInstanceGroupStub getStub()
@BetaApi public final InstanceGroup getRegionInstanceGroup(ProjectRegionInstanceGroupName instanceGroup)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionInstanceGroupName instanceGroup = ProjectRegionInstanceGroupName.of("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
InstanceGroup response = regionInstanceGroupClient.getRegionInstanceGroup(instanceGroup);
}
instanceGroup
- Name of the instance group resource to return.ApiException
- if the remote call fails@BetaApi public final InstanceGroup getRegionInstanceGroup(String instanceGroup)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionInstanceGroupName instanceGroup = ProjectRegionInstanceGroupName.of("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
InstanceGroup response = regionInstanceGroupClient.getRegionInstanceGroup(instanceGroup.toString());
}
instanceGroup
- Name of the instance group resource to return.ApiException
- if the remote call fails@BetaApi public final InstanceGroup getRegionInstanceGroup(GetRegionInstanceGroupHttpRequest request)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectRegionInstanceGroupName.format("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
GetRegionInstanceGroupHttpRequest request = GetRegionInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.build();
InstanceGroup response = regionInstanceGroupClient.getRegionInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetRegionInstanceGroupHttpRequest,InstanceGroup> getRegionInstanceGroupCallable()
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectRegionInstanceGroupName.format("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
GetRegionInstanceGroupHttpRequest request = GetRegionInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.build();
ApiFuture<InstanceGroup> future = regionInstanceGroupClient.getRegionInstanceGroupCallable().futureCall(request);
// Do something
InstanceGroup response = future.get();
}
@BetaApi public final RegionInstanceGroupClient.ListRegionInstanceGroupsPagedResponse listRegionInstanceGroups(ProjectRegionName region)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (InstanceGroup element : regionInstanceGroupClient.listRegionInstanceGroups(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region scoping this request.ApiException
- if the remote call fails@BetaApi public final RegionInstanceGroupClient.ListRegionInstanceGroupsPagedResponse listRegionInstanceGroups(String region)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (InstanceGroup element : regionInstanceGroupClient.listRegionInstanceGroups(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region scoping this request.ApiException
- if the remote call fails@BetaApi public final RegionInstanceGroupClient.ListRegionInstanceGroupsPagedResponse listRegionInstanceGroups(ListRegionInstanceGroupsHttpRequest request)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRegionInstanceGroupsHttpRequest request = ListRegionInstanceGroupsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (InstanceGroup element : regionInstanceGroupClient.listRegionInstanceGroups(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<ListRegionInstanceGroupsHttpRequest,RegionInstanceGroupClient.ListRegionInstanceGroupsPagedResponse> listRegionInstanceGroupsPagedCallable()
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRegionInstanceGroupsHttpRequest request = ListRegionInstanceGroupsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListRegionInstanceGroupsPagedResponse> future = regionInstanceGroupClient.listRegionInstanceGroupsPagedCallable().futureCall(request);
// Do something
for (InstanceGroup element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListRegionInstanceGroupsHttpRequest,RegionInstanceGroupList> listRegionInstanceGroupsCallable()
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRegionInstanceGroupsHttpRequest request = ListRegionInstanceGroupsHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
RegionInstanceGroupList response = regionInstanceGroupClient.listRegionInstanceGroupsCallable().call(request);
for (InstanceGroup element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final RegionInstanceGroupClient.ListInstancesRegionInstanceGroupsPagedResponse listInstancesRegionInstanceGroups(ProjectRegionInstanceGroupName instanceGroup, RegionInstanceGroupsListInstancesRequest regionInstanceGroupsListInstancesRequestResource)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionInstanceGroupName instanceGroup = ProjectRegionInstanceGroupName.of("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsListInstancesRequest regionInstanceGroupsListInstancesRequestResource = RegionInstanceGroupsListInstancesRequest.newBuilder().build();
for (InstanceWithNamedPorts element : regionInstanceGroupClient.listInstancesRegionInstanceGroups(instanceGroup, regionInstanceGroupsListInstancesRequestResource).iterateAll()) {
// doThingsWith(element);
}
}
instanceGroup
- Name of the regional instance group for which we want to list the
instances.regionInstanceGroupsListInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final RegionInstanceGroupClient.ListInstancesRegionInstanceGroupsPagedResponse listInstancesRegionInstanceGroups(String instanceGroup, RegionInstanceGroupsListInstancesRequest regionInstanceGroupsListInstancesRequestResource)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionInstanceGroupName instanceGroup = ProjectRegionInstanceGroupName.of("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsListInstancesRequest regionInstanceGroupsListInstancesRequestResource = RegionInstanceGroupsListInstancesRequest.newBuilder().build();
for (InstanceWithNamedPorts element : regionInstanceGroupClient.listInstancesRegionInstanceGroups(instanceGroup.toString(), regionInstanceGroupsListInstancesRequestResource).iterateAll()) {
// doThingsWith(element);
}
}
instanceGroup
- Name of the regional instance group for which we want to list the
instances.regionInstanceGroupsListInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final RegionInstanceGroupClient.ListInstancesRegionInstanceGroupsPagedResponse listInstancesRegionInstanceGroups(ListInstancesRegionInstanceGroupsHttpRequest request)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectRegionInstanceGroupName.format("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsListInstancesRequest regionInstanceGroupsListInstancesRequestResource = RegionInstanceGroupsListInstancesRequest.newBuilder().build();
ListInstancesRegionInstanceGroupsHttpRequest request = ListInstancesRegionInstanceGroupsHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setRegionInstanceGroupsListInstancesRequestResource(regionInstanceGroupsListInstancesRequestResource)
.build();
for (InstanceWithNamedPorts element : regionInstanceGroupClient.listInstancesRegionInstanceGroups(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<ListInstancesRegionInstanceGroupsHttpRequest,RegionInstanceGroupClient.ListInstancesRegionInstanceGroupsPagedResponse> listInstancesRegionInstanceGroupsPagedCallable()
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectRegionInstanceGroupName.format("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsListInstancesRequest regionInstanceGroupsListInstancesRequestResource = RegionInstanceGroupsListInstancesRequest.newBuilder().build();
ListInstancesRegionInstanceGroupsHttpRequest request = ListInstancesRegionInstanceGroupsHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setRegionInstanceGroupsListInstancesRequestResource(regionInstanceGroupsListInstancesRequestResource)
.build();
ApiFuture<ListInstancesRegionInstanceGroupsPagedResponse> future = regionInstanceGroupClient.listInstancesRegionInstanceGroupsPagedCallable().futureCall(request);
// Do something
for (InstanceWithNamedPorts element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListInstancesRegionInstanceGroupsHttpRequest,RegionInstanceGroupsListInstances> listInstancesRegionInstanceGroupsCallable()
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectRegionInstanceGroupName.format("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsListInstancesRequest regionInstanceGroupsListInstancesRequestResource = RegionInstanceGroupsListInstancesRequest.newBuilder().build();
ListInstancesRegionInstanceGroupsHttpRequest request = ListInstancesRegionInstanceGroupsHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setRegionInstanceGroupsListInstancesRequestResource(regionInstanceGroupsListInstancesRequestResource)
.build();
while (true) {
RegionInstanceGroupsListInstances response = regionInstanceGroupClient.listInstancesRegionInstanceGroupsCallable().call(request);
for (InstanceWithNamedPorts element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation setNamedPortsRegionInstanceGroup(ProjectRegionInstanceGroupName instanceGroup, RegionInstanceGroupsSetNamedPortsRequest regionInstanceGroupsSetNamedPortsRequestResource)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionInstanceGroupName instanceGroup = ProjectRegionInstanceGroupName.of("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsSetNamedPortsRequest regionInstanceGroupsSetNamedPortsRequestResource = RegionInstanceGroupsSetNamedPortsRequest.newBuilder().build();
Operation response = regionInstanceGroupClient.setNamedPortsRegionInstanceGroup(instanceGroup, regionInstanceGroupsSetNamedPortsRequestResource);
}
instanceGroup
- The name of the regional instance group where the named ports are updated.regionInstanceGroupsSetNamedPortsRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation setNamedPortsRegionInstanceGroup(String instanceGroup, RegionInstanceGroupsSetNamedPortsRequest regionInstanceGroupsSetNamedPortsRequestResource)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
ProjectRegionInstanceGroupName instanceGroup = ProjectRegionInstanceGroupName.of("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsSetNamedPortsRequest regionInstanceGroupsSetNamedPortsRequestResource = RegionInstanceGroupsSetNamedPortsRequest.newBuilder().build();
Operation response = regionInstanceGroupClient.setNamedPortsRegionInstanceGroup(instanceGroup.toString(), regionInstanceGroupsSetNamedPortsRequestResource);
}
instanceGroup
- The name of the regional instance group where the named ports are updated.regionInstanceGroupsSetNamedPortsRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation setNamedPortsRegionInstanceGroup(SetNamedPortsRegionInstanceGroupHttpRequest request)
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectRegionInstanceGroupName.format("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsSetNamedPortsRequest regionInstanceGroupsSetNamedPortsRequestResource = RegionInstanceGroupsSetNamedPortsRequest.newBuilder().build();
SetNamedPortsRegionInstanceGroupHttpRequest request = SetNamedPortsRegionInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setRegionInstanceGroupsSetNamedPortsRequestResource(regionInstanceGroupsSetNamedPortsRequestResource)
.build();
Operation response = regionInstanceGroupClient.setNamedPortsRegionInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<SetNamedPortsRegionInstanceGroupHttpRequest,Operation> setNamedPortsRegionInstanceGroupCallable()
Sample code:
try (RegionInstanceGroupClient regionInstanceGroupClient = RegionInstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectRegionInstanceGroupName.format("[PROJECT]", "[REGION]", "[INSTANCE_GROUP]");
RegionInstanceGroupsSetNamedPortsRequest regionInstanceGroupsSetNamedPortsRequestResource = RegionInstanceGroupsSetNamedPortsRequest.newBuilder().build();
SetNamedPortsRegionInstanceGroupHttpRequest request = SetNamedPortsRegionInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setRegionInstanceGroupsSetNamedPortsRequestResource(regionInstanceGroupsSetNamedPortsRequestResource)
.build();
ApiFuture<Operation> future = regionInstanceGroupClient.setNamedPortsRegionInstanceGroupCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.