@Generated(value="by gapic-generator") @BetaApi public class InstanceGroupClient 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 (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource = InstanceGroupsAddInstancesRequest.newBuilder().build();
Operation response = instanceGroupClient.addInstancesInstanceGroup(instanceGroup, instanceGroupsAddInstancesRequestResource);
}
Note: close() needs to be called on the instanceGroupClient 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 InstanceGroupSettings to create(). For example:
To customize credentials:
InstanceGroupSettings instanceGroupSettings =
InstanceGroupSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
InstanceGroupClient instanceGroupClient =
InstanceGroupClient.create(instanceGroupSettings);
To customize the endpoint:
InstanceGroupSettings instanceGroupSettings =
InstanceGroupSettings.newBuilder().setEndpoint(myEndpoint).build();
InstanceGroupClient instanceGroupClient =
InstanceGroupClient.create(instanceGroupSettings);
Modifier and Type | Class and Description |
---|---|
static class |
InstanceGroupClient.AggregatedListInstanceGroupsFixedSizeCollection |
static class |
InstanceGroupClient.AggregatedListInstanceGroupsPage |
static class |
InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse |
static class |
InstanceGroupClient.ListInstanceGroupsFixedSizeCollection |
static class |
InstanceGroupClient.ListInstanceGroupsPage |
static class |
InstanceGroupClient.ListInstanceGroupsPagedResponse |
static class |
InstanceGroupClient.ListInstancesInstanceGroupsFixedSizeCollection |
static class |
InstanceGroupClient.ListInstancesInstanceGroupsPage |
static class |
InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
InstanceGroupClient(InstanceGroupSettings settings)
Constructs an instance of InstanceGroupClient, using the given settings.
|
protected |
InstanceGroupClient(InstanceGroupStub stub) |
Modifier and Type | Method and Description |
---|---|
Operation |
addInstancesInstanceGroup(AddInstancesInstanceGroupHttpRequest request)
Adds a list of instances to the specified instance group.
|
Operation |
addInstancesInstanceGroup(ProjectZoneInstanceGroupName instanceGroup,
InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource)
Adds a list of instances to the specified instance group.
|
Operation |
addInstancesInstanceGroup(String instanceGroup,
InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource)
Adds a list of instances to the specified instance group.
|
UnaryCallable<AddInstancesInstanceGroupHttpRequest,Operation> |
addInstancesInstanceGroupCallable()
Adds a list of instances to the specified instance group.
|
InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse |
aggregatedListInstanceGroups(AggregatedListInstanceGroupsHttpRequest request)
Retrieves the list of instance groups and sorts them by zone.
|
InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse |
aggregatedListInstanceGroups(ProjectName project)
Retrieves the list of instance groups and sorts them by zone.
|
InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse |
aggregatedListInstanceGroups(String project)
Retrieves the list of instance groups and sorts them by zone.
|
UnaryCallable<AggregatedListInstanceGroupsHttpRequest,InstanceGroupAggregatedList> |
aggregatedListInstanceGroupsCallable()
Retrieves the list of instance groups and sorts them by zone.
|
UnaryCallable<AggregatedListInstanceGroupsHttpRequest,InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse> |
aggregatedListInstanceGroupsPagedCallable()
Retrieves the list of instance groups and sorts them by zone.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static InstanceGroupClient |
create()
Constructs an instance of InstanceGroupClient with default settings.
|
static InstanceGroupClient |
create(InstanceGroupSettings settings)
Constructs an instance of InstanceGroupClient, using the given settings.
|
static InstanceGroupClient |
create(InstanceGroupStub stub)
Constructs an instance of InstanceGroupClient, using the given stub for making calls.
|
Operation |
deleteInstanceGroup(DeleteInstanceGroupHttpRequest request)
Deletes the specified instance group.
|
Operation |
deleteInstanceGroup(ProjectZoneInstanceGroupName instanceGroup)
Deletes the specified instance group.
|
Operation |
deleteInstanceGroup(String instanceGroup)
Deletes the specified instance group.
|
UnaryCallable<DeleteInstanceGroupHttpRequest,Operation> |
deleteInstanceGroupCallable()
Deletes the specified instance group.
|
InstanceGroup |
getInstanceGroup(GetInstanceGroupHttpRequest request)
Returns the specified instance group.
|
InstanceGroup |
getInstanceGroup(ProjectZoneInstanceGroupName instanceGroup)
Returns the specified instance group.
|
InstanceGroup |
getInstanceGroup(String instanceGroup)
Returns the specified instance group.
|
UnaryCallable<GetInstanceGroupHttpRequest,InstanceGroup> |
getInstanceGroupCallable()
Returns the specified instance group.
|
InstanceGroupSettings |
getSettings() |
InstanceGroupStub |
getStub() |
Operation |
insertInstanceGroup(InsertInstanceGroupHttpRequest request)
Creates an instance group in the specified project using the parameters that are included in
the request.
|
Operation |
insertInstanceGroup(ProjectZoneName zone,
InstanceGroup instanceGroupResource)
Creates an instance group in the specified project using the parameters that are included in
the request.
|
Operation |
insertInstanceGroup(String zone,
InstanceGroup instanceGroupResource)
Creates an instance group in the specified project using the parameters that are included in
the request.
|
UnaryCallable<InsertInstanceGroupHttpRequest,Operation> |
insertInstanceGroupCallable()
Creates an instance group in the specified project using the parameters that are included in
the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
InstanceGroupClient.ListInstanceGroupsPagedResponse |
listInstanceGroups(ListInstanceGroupsHttpRequest request)
Retrieves the list of instance groups that are located in the specified project and zone.
|
InstanceGroupClient.ListInstanceGroupsPagedResponse |
listInstanceGroups(ProjectZoneName zone)
Retrieves the list of instance groups that are located in the specified project and zone.
|
InstanceGroupClient.ListInstanceGroupsPagedResponse |
listInstanceGroups(String zone)
Retrieves the list of instance groups that are located in the specified project and zone.
|
UnaryCallable<ListInstanceGroupsHttpRequest,InstanceGroupList> |
listInstanceGroupsCallable()
Retrieves the list of instance groups that are located in the specified project and zone.
|
UnaryCallable<ListInstanceGroupsHttpRequest,InstanceGroupClient.ListInstanceGroupsPagedResponse> |
listInstanceGroupsPagedCallable()
Retrieves the list of instance groups that are located in the specified project and zone.
|
InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse |
listInstancesInstanceGroups(ListInstancesInstanceGroupsHttpRequest request)
Lists the instances in the specified instance group.
|
InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse |
listInstancesInstanceGroups(ProjectZoneInstanceGroupName instanceGroup,
InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource)
Lists the instances in the specified instance group.
|
InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse |
listInstancesInstanceGroups(String instanceGroup,
InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource)
Lists the instances in the specified instance group.
|
UnaryCallable<ListInstancesInstanceGroupsHttpRequest,InstanceGroupsListInstances> |
listInstancesInstanceGroupsCallable()
Lists the instances in the specified instance group.
|
UnaryCallable<ListInstancesInstanceGroupsHttpRequest,InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse> |
listInstancesInstanceGroupsPagedCallable()
Lists the instances in the specified instance group.
|
Operation |
removeInstancesInstanceGroup(ProjectZoneInstanceGroupName instanceGroup,
InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource)
Removes one or more instances from the specified instance group, but does not delete those
instances.
|
Operation |
removeInstancesInstanceGroup(RemoveInstancesInstanceGroupHttpRequest request)
Removes one or more instances from the specified instance group, but does not delete those
instances.
|
Operation |
removeInstancesInstanceGroup(String instanceGroup,
InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource)
Removes one or more instances from the specified instance group, but does not delete those
instances.
|
UnaryCallable<RemoveInstancesInstanceGroupHttpRequest,Operation> |
removeInstancesInstanceGroupCallable()
Removes one or more instances from the specified instance group, but does not delete those
instances.
|
Operation |
setNamedPortsInstanceGroup(ProjectZoneInstanceGroupName instanceGroup,
InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource)
Sets the named ports for the specified instance group.
|
Operation |
setNamedPortsInstanceGroup(SetNamedPortsInstanceGroupHttpRequest request)
Sets the named ports for the specified instance group.
|
Operation |
setNamedPortsInstanceGroup(String instanceGroup,
InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource)
Sets the named ports for the specified instance group.
|
UnaryCallable<SetNamedPortsInstanceGroupHttpRequest,Operation> |
setNamedPortsInstanceGroupCallable()
Sets the named ports for the specified instance group.
|
void |
shutdown() |
void |
shutdownNow() |
protected InstanceGroupClient(InstanceGroupSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected InstanceGroupClient(InstanceGroupStub stub)
public static final InstanceGroupClient create() throws IOException
IOException
public static final InstanceGroupClient create(InstanceGroupSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final InstanceGroupClient create(InstanceGroupStub stub)
public final InstanceGroupSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public InstanceGroupStub getStub()
@BetaApi public final Operation addInstancesInstanceGroup(ProjectZoneInstanceGroupName instanceGroup, InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource = InstanceGroupsAddInstancesRequest.newBuilder().build();
Operation response = instanceGroupClient.addInstancesInstanceGroup(instanceGroup, instanceGroupsAddInstancesRequestResource);
}
instanceGroup
- The name of the instance group where you are adding instances.instanceGroupsAddInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation addInstancesInstanceGroup(String instanceGroup, InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource = InstanceGroupsAddInstancesRequest.newBuilder().build();
Operation response = instanceGroupClient.addInstancesInstanceGroup(instanceGroup.toString(), instanceGroupsAddInstancesRequestResource);
}
instanceGroup
- The name of the instance group where you are adding instances.instanceGroupsAddInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation addInstancesInstanceGroup(AddInstancesInstanceGroupHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource = InstanceGroupsAddInstancesRequest.newBuilder().build();
AddInstancesInstanceGroupHttpRequest request = AddInstancesInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsAddInstancesRequestResource(instanceGroupsAddInstancesRequestResource)
.build();
Operation response = instanceGroupClient.addInstancesInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<AddInstancesInstanceGroupHttpRequest,Operation> addInstancesInstanceGroupCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsAddInstancesRequest instanceGroupsAddInstancesRequestResource = InstanceGroupsAddInstancesRequest.newBuilder().build();
AddInstancesInstanceGroupHttpRequest request = AddInstancesInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsAddInstancesRequestResource(instanceGroupsAddInstancesRequestResource)
.build();
ApiFuture<Operation> future = instanceGroupClient.addInstancesInstanceGroupCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse aggregatedListInstanceGroups(ProjectName project)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (InstanceGroupsScopedList element : instanceGroupClient.aggregatedListInstanceGroups(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse aggregatedListInstanceGroups(String project)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (InstanceGroupsScopedList element : instanceGroupClient.aggregatedListInstanceGroups(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse aggregatedListInstanceGroups(AggregatedListInstanceGroupsHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListInstanceGroupsHttpRequest request = AggregatedListInstanceGroupsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (InstanceGroupsScopedList element : instanceGroupClient.aggregatedListInstanceGroups(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<AggregatedListInstanceGroupsHttpRequest,InstanceGroupClient.AggregatedListInstanceGroupsPagedResponse> aggregatedListInstanceGroupsPagedCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListInstanceGroupsHttpRequest request = AggregatedListInstanceGroupsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListInstanceGroupsPagedResponse> future = instanceGroupClient.aggregatedListInstanceGroupsPagedCallable().futureCall(request);
// Do something
for (InstanceGroupsScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListInstanceGroupsHttpRequest,InstanceGroupAggregatedList> aggregatedListInstanceGroupsCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListInstanceGroupsHttpRequest request = AggregatedListInstanceGroupsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
InstanceGroupAggregatedList response = instanceGroupClient.aggregatedListInstanceGroupsCallable().call(request);
for (InstanceGroupsScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation deleteInstanceGroup(ProjectZoneInstanceGroupName instanceGroup)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
Operation response = instanceGroupClient.deleteInstanceGroup(instanceGroup);
}
instanceGroup
- The name of the instance group to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteInstanceGroup(String instanceGroup)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
Operation response = instanceGroupClient.deleteInstanceGroup(instanceGroup.toString());
}
instanceGroup
- The name of the instance group to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteInstanceGroup(DeleteInstanceGroupHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
DeleteInstanceGroupHttpRequest request = DeleteInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.build();
Operation response = instanceGroupClient.deleteInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteInstanceGroupHttpRequest,Operation> deleteInstanceGroupCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
DeleteInstanceGroupHttpRequest request = DeleteInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.build();
ApiFuture<Operation> future = instanceGroupClient.deleteInstanceGroupCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final InstanceGroup getInstanceGroup(ProjectZoneInstanceGroupName instanceGroup)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroup response = instanceGroupClient.getInstanceGroup(instanceGroup);
}
instanceGroup
- The name of the instance group.ApiException
- if the remote call fails@BetaApi public final InstanceGroup getInstanceGroup(String instanceGroup)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroup response = instanceGroupClient.getInstanceGroup(instanceGroup.toString());
}
instanceGroup
- The name of the instance group.ApiException
- if the remote call fails@BetaApi public final InstanceGroup getInstanceGroup(GetInstanceGroupHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
GetInstanceGroupHttpRequest request = GetInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.build();
InstanceGroup response = instanceGroupClient.getInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetInstanceGroupHttpRequest,InstanceGroup> getInstanceGroupCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
GetInstanceGroupHttpRequest request = GetInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.build();
ApiFuture<InstanceGroup> future = instanceGroupClient.getInstanceGroupCallable().futureCall(request);
// Do something
InstanceGroup response = future.get();
}
@BetaApi public final Operation insertInstanceGroup(ProjectZoneName zone, InstanceGroup instanceGroupResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
InstanceGroup instanceGroupResource = InstanceGroup.newBuilder().build();
Operation response = instanceGroupClient.insertInstanceGroup(zone, instanceGroupResource);
}
zone
- The name of the zone where you want to create the instance group.instanceGroupResource
- InstanceGroups (== resource_for beta.instanceGroups ==) (==
resource_for v1.instanceGroups ==) (== resource_for beta.regionInstanceGroups ==) (==
resource_for v1.regionInstanceGroups ==)ApiException
- if the remote call fails@BetaApi public final Operation insertInstanceGroup(String zone, InstanceGroup instanceGroupResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
InstanceGroup instanceGroupResource = InstanceGroup.newBuilder().build();
Operation response = instanceGroupClient.insertInstanceGroup(zone.toString(), instanceGroupResource);
}
zone
- The name of the zone where you want to create the instance group.instanceGroupResource
- InstanceGroups (== resource_for beta.instanceGroups ==) (==
resource_for v1.instanceGroups ==) (== resource_for beta.regionInstanceGroups ==) (==
resource_for v1.regionInstanceGroups ==)ApiException
- if the remote call fails@BetaApi public final Operation insertInstanceGroup(InsertInstanceGroupHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
InstanceGroup instanceGroupResource = InstanceGroup.newBuilder().build();
InsertInstanceGroupHttpRequest request = InsertInstanceGroupHttpRequest.newBuilder()
.setZone(formattedZone)
.setInstanceGroupResource(instanceGroupResource)
.build();
Operation response = instanceGroupClient.insertInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertInstanceGroupHttpRequest,Operation> insertInstanceGroupCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
InstanceGroup instanceGroupResource = InstanceGroup.newBuilder().build();
InsertInstanceGroupHttpRequest request = InsertInstanceGroupHttpRequest.newBuilder()
.setZone(formattedZone)
.setInstanceGroupResource(instanceGroupResource)
.build();
ApiFuture<Operation> future = instanceGroupClient.insertInstanceGroupCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final InstanceGroupClient.ListInstanceGroupsPagedResponse listInstanceGroups(ProjectZoneName zone)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (InstanceGroup element : instanceGroupClient.listInstanceGroups(zone).iterateAll()) {
// doThingsWith(element);
}
}
zone
- The name of the zone where the instance group is located.ApiException
- if the remote call fails@BetaApi public final InstanceGroupClient.ListInstanceGroupsPagedResponse listInstanceGroups(String zone)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (InstanceGroup element : instanceGroupClient.listInstanceGroups(zone.toString()).iterateAll()) {
// doThingsWith(element);
}
}
zone
- The name of the zone where the instance group is located.ApiException
- if the remote call fails@BetaApi public final InstanceGroupClient.ListInstanceGroupsPagedResponse listInstanceGroups(ListInstanceGroupsHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListInstanceGroupsHttpRequest request = ListInstanceGroupsHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
for (InstanceGroup element : instanceGroupClient.listInstanceGroups(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<ListInstanceGroupsHttpRequest,InstanceGroupClient.ListInstanceGroupsPagedResponse> listInstanceGroupsPagedCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListInstanceGroupsHttpRequest request = ListInstanceGroupsHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
ApiFuture<ListInstanceGroupsPagedResponse> future = instanceGroupClient.listInstanceGroupsPagedCallable().futureCall(request);
// Do something
for (InstanceGroup element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListInstanceGroupsHttpRequest,InstanceGroupList> listInstanceGroupsCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListInstanceGroupsHttpRequest request = ListInstanceGroupsHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
while (true) {
InstanceGroupList response = instanceGroupClient.listInstanceGroupsCallable().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 InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse listInstancesInstanceGroups(ProjectZoneInstanceGroupName instanceGroup, InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource = InstanceGroupsListInstancesRequest.newBuilder().build();
for (InstanceWithNamedPorts element : instanceGroupClient.listInstancesInstanceGroups(instanceGroup, instanceGroupsListInstancesRequestResource).iterateAll()) {
// doThingsWith(element);
}
}
instanceGroup
- The name of the instance group from which you want to generate a list of
included instances.instanceGroupsListInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse listInstancesInstanceGroups(String instanceGroup, InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource = InstanceGroupsListInstancesRequest.newBuilder().build();
for (InstanceWithNamedPorts element : instanceGroupClient.listInstancesInstanceGroups(instanceGroup.toString(), instanceGroupsListInstancesRequestResource).iterateAll()) {
// doThingsWith(element);
}
}
instanceGroup
- The name of the instance group from which you want to generate a list of
included instances.instanceGroupsListInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse listInstancesInstanceGroups(ListInstancesInstanceGroupsHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource = InstanceGroupsListInstancesRequest.newBuilder().build();
ListInstancesInstanceGroupsHttpRequest request = ListInstancesInstanceGroupsHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsListInstancesRequestResource(instanceGroupsListInstancesRequestResource)
.build();
for (InstanceWithNamedPorts element : instanceGroupClient.listInstancesInstanceGroups(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<ListInstancesInstanceGroupsHttpRequest,InstanceGroupClient.ListInstancesInstanceGroupsPagedResponse> listInstancesInstanceGroupsPagedCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource = InstanceGroupsListInstancesRequest.newBuilder().build();
ListInstancesInstanceGroupsHttpRequest request = ListInstancesInstanceGroupsHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsListInstancesRequestResource(instanceGroupsListInstancesRequestResource)
.build();
ApiFuture<ListInstancesInstanceGroupsPagedResponse> future = instanceGroupClient.listInstancesInstanceGroupsPagedCallable().futureCall(request);
// Do something
for (InstanceWithNamedPorts element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListInstancesInstanceGroupsHttpRequest,InstanceGroupsListInstances> listInstancesInstanceGroupsCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsListInstancesRequest instanceGroupsListInstancesRequestResource = InstanceGroupsListInstancesRequest.newBuilder().build();
ListInstancesInstanceGroupsHttpRequest request = ListInstancesInstanceGroupsHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsListInstancesRequestResource(instanceGroupsListInstancesRequestResource)
.build();
while (true) {
InstanceGroupsListInstances response = instanceGroupClient.listInstancesInstanceGroupsCallable().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 removeInstancesInstanceGroup(ProjectZoneInstanceGroupName instanceGroup, InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource)
If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted.
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource = InstanceGroupsRemoveInstancesRequest.newBuilder().build();
Operation response = instanceGroupClient.removeInstancesInstanceGroup(instanceGroup, instanceGroupsRemoveInstancesRequestResource);
}
instanceGroup
- The name of the instance group where the specified instances will be
removed.instanceGroupsRemoveInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation removeInstancesInstanceGroup(String instanceGroup, InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource)
If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted.
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource = InstanceGroupsRemoveInstancesRequest.newBuilder().build();
Operation response = instanceGroupClient.removeInstancesInstanceGroup(instanceGroup.toString(), instanceGroupsRemoveInstancesRequestResource);
}
instanceGroup
- The name of the instance group where the specified instances will be
removed.instanceGroupsRemoveInstancesRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation removeInstancesInstanceGroup(RemoveInstancesInstanceGroupHttpRequest request)
If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted.
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource = InstanceGroupsRemoveInstancesRequest.newBuilder().build();
RemoveInstancesInstanceGroupHttpRequest request = RemoveInstancesInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsRemoveInstancesRequestResource(instanceGroupsRemoveInstancesRequestResource)
.build();
Operation response = instanceGroupClient.removeInstancesInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<RemoveInstancesInstanceGroupHttpRequest,Operation> removeInstancesInstanceGroupCallable()
If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted.
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsRemoveInstancesRequest instanceGroupsRemoveInstancesRequestResource = InstanceGroupsRemoveInstancesRequest.newBuilder().build();
RemoveInstancesInstanceGroupHttpRequest request = RemoveInstancesInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsRemoveInstancesRequestResource(instanceGroupsRemoveInstancesRequestResource)
.build();
ApiFuture<Operation> future = instanceGroupClient.removeInstancesInstanceGroupCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation setNamedPortsInstanceGroup(ProjectZoneInstanceGroupName instanceGroup, InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource = InstanceGroupsSetNamedPortsRequest.newBuilder().build();
Operation response = instanceGroupClient.setNamedPortsInstanceGroup(instanceGroup, instanceGroupsSetNamedPortsRequestResource);
}
instanceGroup
- The name of the instance group where the named ports are updated.instanceGroupsSetNamedPortsRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation setNamedPortsInstanceGroup(String instanceGroup, InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
ProjectZoneInstanceGroupName instanceGroup = ProjectZoneInstanceGroupName.of("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource = InstanceGroupsSetNamedPortsRequest.newBuilder().build();
Operation response = instanceGroupClient.setNamedPortsInstanceGroup(instanceGroup.toString(), instanceGroupsSetNamedPortsRequestResource);
}
instanceGroup
- The name of the instance group where the named ports are updated.instanceGroupsSetNamedPortsRequestResource
- ApiException
- if the remote call fails@BetaApi public final Operation setNamedPortsInstanceGroup(SetNamedPortsInstanceGroupHttpRequest request)
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource = InstanceGroupsSetNamedPortsRequest.newBuilder().build();
SetNamedPortsInstanceGroupHttpRequest request = SetNamedPortsInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsSetNamedPortsRequestResource(instanceGroupsSetNamedPortsRequestResource)
.build();
Operation response = instanceGroupClient.setNamedPortsInstanceGroup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<SetNamedPortsInstanceGroupHttpRequest,Operation> setNamedPortsInstanceGroupCallable()
Sample code:
try (InstanceGroupClient instanceGroupClient = InstanceGroupClient.create()) {
String formattedInstanceGroup = ProjectZoneInstanceGroupName.format("[PROJECT]", "[ZONE]", "[INSTANCE_GROUP]");
InstanceGroupsSetNamedPortsRequest instanceGroupsSetNamedPortsRequestResource = InstanceGroupsSetNamedPortsRequest.newBuilder().build();
SetNamedPortsInstanceGroupHttpRequest request = SetNamedPortsInstanceGroupHttpRequest.newBuilder()
.setInstanceGroup(formattedInstanceGroup)
.setInstanceGroupsSetNamedPortsRequestResource(instanceGroupsSetNamedPortsRequestResource)
.build();
ApiFuture<Operation> future = instanceGroupClient.setNamedPortsInstanceGroupCallable().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.