@Generated(value="by gapic-generator") @BetaApi public class AutoscalerClient 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 (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneAutoscalerName autoscaler = ProjectZoneAutoscalerName.of("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
Operation response = autoscalerClient.deleteAutoscaler(autoscaler);
}
Note: close() needs to be called on the autoscalerClient 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 AutoscalerSettings to create(). For example:
To customize credentials:
AutoscalerSettings autoscalerSettings =
AutoscalerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AutoscalerClient autoscalerClient =
AutoscalerClient.create(autoscalerSettings);
To customize the endpoint:
AutoscalerSettings autoscalerSettings =
AutoscalerSettings.newBuilder().setEndpoint(myEndpoint).build();
AutoscalerClient autoscalerClient =
AutoscalerClient.create(autoscalerSettings);
Modifier and Type | Class and Description |
---|---|
static class |
AutoscalerClient.AggregatedListAutoscalersFixedSizeCollection |
static class |
AutoscalerClient.AggregatedListAutoscalersPage |
static class |
AutoscalerClient.AggregatedListAutoscalersPagedResponse |
static class |
AutoscalerClient.ListAutoscalersFixedSizeCollection |
static class |
AutoscalerClient.ListAutoscalersPage |
static class |
AutoscalerClient.ListAutoscalersPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
AutoscalerClient(AutoscalerSettings settings)
Constructs an instance of AutoscalerClient, using the given settings.
|
protected |
AutoscalerClient(AutoscalerStub stub) |
Modifier and Type | Method and Description |
---|---|
AutoscalerClient.AggregatedListAutoscalersPagedResponse |
aggregatedListAutoscalers(AggregatedListAutoscalersHttpRequest request)
Retrieves an aggregated list of autoscalers.
|
AutoscalerClient.AggregatedListAutoscalersPagedResponse |
aggregatedListAutoscalers(ProjectName project)
Retrieves an aggregated list of autoscalers.
|
AutoscalerClient.AggregatedListAutoscalersPagedResponse |
aggregatedListAutoscalers(String project)
Retrieves an aggregated list of autoscalers.
|
UnaryCallable<AggregatedListAutoscalersHttpRequest,AutoscalerAggregatedList> |
aggregatedListAutoscalersCallable()
Retrieves an aggregated list of autoscalers.
|
UnaryCallable<AggregatedListAutoscalersHttpRequest,AutoscalerClient.AggregatedListAutoscalersPagedResponse> |
aggregatedListAutoscalersPagedCallable()
Retrieves an aggregated list of autoscalers.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static AutoscalerClient |
create()
Constructs an instance of AutoscalerClient with default settings.
|
static AutoscalerClient |
create(AutoscalerSettings settings)
Constructs an instance of AutoscalerClient, using the given settings.
|
static AutoscalerClient |
create(AutoscalerStub stub)
Constructs an instance of AutoscalerClient, using the given stub for making calls.
|
Operation |
deleteAutoscaler(DeleteAutoscalerHttpRequest request)
Deletes the specified autoscaler.
|
Operation |
deleteAutoscaler(ProjectZoneAutoscalerName autoscaler)
Deletes the specified autoscaler.
|
Operation |
deleteAutoscaler(String autoscaler)
Deletes the specified autoscaler.
|
UnaryCallable<DeleteAutoscalerHttpRequest,Operation> |
deleteAutoscalerCallable()
Deletes the specified autoscaler.
|
Autoscaler |
getAutoscaler(GetAutoscalerHttpRequest request)
Returns the specified autoscaler resource.
|
Autoscaler |
getAutoscaler(ProjectZoneAutoscalerName autoscaler)
Returns the specified autoscaler resource.
|
Autoscaler |
getAutoscaler(String autoscaler)
Returns the specified autoscaler resource.
|
UnaryCallable<GetAutoscalerHttpRequest,Autoscaler> |
getAutoscalerCallable()
Returns the specified autoscaler resource.
|
AutoscalerSettings |
getSettings() |
AutoscalerStub |
getStub() |
Operation |
insertAutoscaler(InsertAutoscalerHttpRequest request)
Creates an autoscaler in the specified project using the data included in the request.
|
Operation |
insertAutoscaler(ProjectZoneName zone,
Autoscaler autoscalerResource)
Creates an autoscaler in the specified project using the data included in the request.
|
Operation |
insertAutoscaler(String zone,
Autoscaler autoscalerResource)
Creates an autoscaler in the specified project using the data included in the request.
|
UnaryCallable<InsertAutoscalerHttpRequest,Operation> |
insertAutoscalerCallable()
Creates an autoscaler in the specified project using the data included in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
AutoscalerClient.ListAutoscalersPagedResponse |
listAutoscalers(ListAutoscalersHttpRequest request)
Retrieves a list of autoscalers contained within the specified zone.
|
AutoscalerClient.ListAutoscalersPagedResponse |
listAutoscalers(ProjectZoneName zone)
Retrieves a list of autoscalers contained within the specified zone.
|
AutoscalerClient.ListAutoscalersPagedResponse |
listAutoscalers(String zone)
Retrieves a list of autoscalers contained within the specified zone.
|
UnaryCallable<ListAutoscalersHttpRequest,AutoscalerList> |
listAutoscalersCallable()
Retrieves a list of autoscalers contained within the specified zone.
|
UnaryCallable<ListAutoscalersHttpRequest,AutoscalerClient.ListAutoscalersPagedResponse> |
listAutoscalersPagedCallable()
Retrieves a list of autoscalers contained within the specified zone.
|
Operation |
patchAutoscaler(PatchAutoscalerHttpRequest request)
Updates an autoscaler in the specified project using the data included in the request.
|
Operation |
patchAutoscaler(String autoscaler,
ProjectZoneName zone,
Autoscaler autoscalerResource,
List<String> fieldMask)
Updates an autoscaler in the specified project using the data included in the request.
|
Operation |
patchAutoscaler(String autoscaler,
String zone,
Autoscaler autoscalerResource,
List<String> fieldMask)
Updates an autoscaler in the specified project using the data included in the request.
|
UnaryCallable<PatchAutoscalerHttpRequest,Operation> |
patchAutoscalerCallable()
Updates an autoscaler in the specified project using the data included in the request.
|
void |
shutdown() |
void |
shutdownNow() |
Operation |
updateAutoscaler(String autoscaler,
ProjectZoneName zone,
Autoscaler autoscalerResource,
List<String> fieldMask)
Updates an autoscaler in the specified project using the data included in the request.
|
Operation |
updateAutoscaler(String autoscaler,
String zone,
Autoscaler autoscalerResource,
List<String> fieldMask)
Updates an autoscaler in the specified project using the data included in the request.
|
Operation |
updateAutoscaler(UpdateAutoscalerHttpRequest request)
Updates an autoscaler in the specified project using the data included in the request.
|
UnaryCallable<UpdateAutoscalerHttpRequest,Operation> |
updateAutoscalerCallable()
Updates an autoscaler in the specified project using the data included in the request.
|
protected AutoscalerClient(AutoscalerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected AutoscalerClient(AutoscalerStub stub)
public static final AutoscalerClient create() throws IOException
IOException
public static final AutoscalerClient create(AutoscalerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final AutoscalerClient create(AutoscalerStub stub)
public final AutoscalerSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public AutoscalerStub getStub()
@BetaApi public final AutoscalerClient.AggregatedListAutoscalersPagedResponse aggregatedListAutoscalers(ProjectName project)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (AutoscalersScopedList element : autoscalerClient.aggregatedListAutoscalers(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final AutoscalerClient.AggregatedListAutoscalersPagedResponse aggregatedListAutoscalers(String project)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (AutoscalersScopedList element : autoscalerClient.aggregatedListAutoscalers(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final AutoscalerClient.AggregatedListAutoscalersPagedResponse aggregatedListAutoscalers(AggregatedListAutoscalersHttpRequest request)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAutoscalersHttpRequest request = AggregatedListAutoscalersHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (AutoscalersScopedList element : autoscalerClient.aggregatedListAutoscalers(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<AggregatedListAutoscalersHttpRequest,AutoscalerClient.AggregatedListAutoscalersPagedResponse> aggregatedListAutoscalersPagedCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAutoscalersHttpRequest request = AggregatedListAutoscalersHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListAutoscalersPagedResponse> future = autoscalerClient.aggregatedListAutoscalersPagedCallable().futureCall(request);
// Do something
for (AutoscalersScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListAutoscalersHttpRequest,AutoscalerAggregatedList> aggregatedListAutoscalersCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListAutoscalersHttpRequest request = AggregatedListAutoscalersHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
AutoscalerAggregatedList response = autoscalerClient.aggregatedListAutoscalersCallable().call(request);
for (AutoscalersScopedList 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 deleteAutoscaler(ProjectZoneAutoscalerName autoscaler)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneAutoscalerName autoscaler = ProjectZoneAutoscalerName.of("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
Operation response = autoscalerClient.deleteAutoscaler(autoscaler);
}
autoscaler
- Name of the autoscaler to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteAutoscaler(String autoscaler)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneAutoscalerName autoscaler = ProjectZoneAutoscalerName.of("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
Operation response = autoscalerClient.deleteAutoscaler(autoscaler.toString());
}
autoscaler
- Name of the autoscaler to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteAutoscaler(DeleteAutoscalerHttpRequest request)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedAutoscaler = ProjectZoneAutoscalerName.format("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
DeleteAutoscalerHttpRequest request = DeleteAutoscalerHttpRequest.newBuilder()
.setAutoscaler(formattedAutoscaler)
.build();
Operation response = autoscalerClient.deleteAutoscaler(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteAutoscalerHttpRequest,Operation> deleteAutoscalerCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedAutoscaler = ProjectZoneAutoscalerName.format("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
DeleteAutoscalerHttpRequest request = DeleteAutoscalerHttpRequest.newBuilder()
.setAutoscaler(formattedAutoscaler)
.build();
ApiFuture<Operation> future = autoscalerClient.deleteAutoscalerCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Autoscaler getAutoscaler(ProjectZoneAutoscalerName autoscaler)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneAutoscalerName autoscaler = ProjectZoneAutoscalerName.of("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
Autoscaler response = autoscalerClient.getAutoscaler(autoscaler);
}
autoscaler
- Name of the autoscaler to return.ApiException
- if the remote call fails@BetaApi public final Autoscaler getAutoscaler(String autoscaler)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneAutoscalerName autoscaler = ProjectZoneAutoscalerName.of("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
Autoscaler response = autoscalerClient.getAutoscaler(autoscaler.toString());
}
autoscaler
- Name of the autoscaler to return.ApiException
- if the remote call fails@BetaApi public final Autoscaler getAutoscaler(GetAutoscalerHttpRequest request)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedAutoscaler = ProjectZoneAutoscalerName.format("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
GetAutoscalerHttpRequest request = GetAutoscalerHttpRequest.newBuilder()
.setAutoscaler(formattedAutoscaler)
.build();
Autoscaler response = autoscalerClient.getAutoscaler(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetAutoscalerHttpRequest,Autoscaler> getAutoscalerCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedAutoscaler = ProjectZoneAutoscalerName.format("[PROJECT]", "[ZONE]", "[AUTOSCALER]");
GetAutoscalerHttpRequest request = GetAutoscalerHttpRequest.newBuilder()
.setAutoscaler(formattedAutoscaler)
.build();
ApiFuture<Autoscaler> future = autoscalerClient.getAutoscalerCallable().futureCall(request);
// Do something
Autoscaler response = future.get();
}
@BetaApi public final Operation insertAutoscaler(ProjectZoneName zone, Autoscaler autoscalerResource)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
Operation response = autoscalerClient.insertAutoscaler(zone, autoscalerResource);
}
zone
- Name of the zone for this request.autoscalerResource
- Represents an Autoscaler resource. Autoscalers allow you to
automatically scale virtual machine instances in managed instance groups according to an
autoscaling policy that you define. For more information, read Autoscaling Groups of
Instances. (== resource_for beta.autoscalers ==) (== resource_for v1.autoscalers ==) (==
resource_for beta.regionAutoscalers ==) (== resource_for v1.regionAutoscalers ==)ApiException
- if the remote call fails@BetaApi public final Operation insertAutoscaler(String zone, Autoscaler autoscalerResource)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
Operation response = autoscalerClient.insertAutoscaler(zone.toString(), autoscalerResource);
}
zone
- Name of the zone for this request.autoscalerResource
- Represents an Autoscaler resource. Autoscalers allow you to
automatically scale virtual machine instances in managed instance groups according to an
autoscaling policy that you define. For more information, read Autoscaling Groups of
Instances. (== resource_for beta.autoscalers ==) (== resource_for v1.autoscalers ==) (==
resource_for beta.regionAutoscalers ==) (== resource_for v1.regionAutoscalers ==)ApiException
- if the remote call fails@BetaApi public final Operation insertAutoscaler(InsertAutoscalerHttpRequest request)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
InsertAutoscalerHttpRequest request = InsertAutoscalerHttpRequest.newBuilder()
.setZone(formattedZone)
.setAutoscalerResource(autoscalerResource)
.build();
Operation response = autoscalerClient.insertAutoscaler(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertAutoscalerHttpRequest,Operation> insertAutoscalerCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
InsertAutoscalerHttpRequest request = InsertAutoscalerHttpRequest.newBuilder()
.setZone(formattedZone)
.setAutoscalerResource(autoscalerResource)
.build();
ApiFuture<Operation> future = autoscalerClient.insertAutoscalerCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final AutoscalerClient.ListAutoscalersPagedResponse listAutoscalers(ProjectZoneName zone)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (Autoscaler element : autoscalerClient.listAutoscalers(zone).iterateAll()) {
// doThingsWith(element);
}
}
zone
- Name of the zone for this request.ApiException
- if the remote call fails@BetaApi public final AutoscalerClient.ListAutoscalersPagedResponse listAutoscalers(String zone)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (Autoscaler element : autoscalerClient.listAutoscalers(zone.toString()).iterateAll()) {
// doThingsWith(element);
}
}
zone
- Name of the zone for this request.ApiException
- if the remote call fails@BetaApi public final AutoscalerClient.ListAutoscalersPagedResponse listAutoscalers(ListAutoscalersHttpRequest request)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListAutoscalersHttpRequest request = ListAutoscalersHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
for (Autoscaler element : autoscalerClient.listAutoscalers(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<ListAutoscalersHttpRequest,AutoscalerClient.ListAutoscalersPagedResponse> listAutoscalersPagedCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListAutoscalersHttpRequest request = ListAutoscalersHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
ApiFuture<ListAutoscalersPagedResponse> future = autoscalerClient.listAutoscalersPagedCallable().futureCall(request);
// Do something
for (Autoscaler element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListAutoscalersHttpRequest,AutoscalerList> listAutoscalersCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListAutoscalersHttpRequest request = ListAutoscalersHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
while (true) {
AutoscalerList response = autoscalerClient.listAutoscalersCallable().call(request);
for (Autoscaler 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 patchAutoscaler(String autoscaler, ProjectZoneName zone, Autoscaler autoscalerResource, List<String> fieldMask)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = autoscalerClient.patchAutoscaler(autoscaler, zone, autoscalerResource, fieldMask);
}
autoscaler
- Name of the autoscaler to patch.zone
- Name of the zone for this request.autoscalerResource
- Represents an Autoscaler resource. Autoscalers allow you to
automatically scale virtual machine instances in managed instance groups according to an
autoscaling policy that you define. For more information, read Autoscaling Groups of
Instances. (== resource_for beta.autoscalers ==) (== resource_for v1.autoscalers ==) (==
resource_for beta.regionAutoscalers ==) (== resource_for v1.regionAutoscalers ==)fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation patchAutoscaler(String autoscaler, String zone, Autoscaler autoscalerResource, List<String> fieldMask)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = autoscalerClient.patchAutoscaler(autoscaler, zone.toString(), autoscalerResource, fieldMask);
}
autoscaler
- Name of the autoscaler to patch.zone
- Name of the zone for this request.autoscalerResource
- Represents an Autoscaler resource. Autoscalers allow you to
automatically scale virtual machine instances in managed instance groups according to an
autoscaling policy that you define. For more information, read Autoscaling Groups of
Instances. (== resource_for beta.autoscalers ==) (== resource_for v1.autoscalers ==) (==
resource_for beta.regionAutoscalers ==) (== resource_for v1.regionAutoscalers ==)fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation patchAutoscaler(PatchAutoscalerHttpRequest request)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchAutoscalerHttpRequest request = PatchAutoscalerHttpRequest.newBuilder()
.setAutoscaler(autoscaler)
.setZone(formattedZone)
.setAutoscalerResource(autoscalerResource)
.addAllFieldMask(fieldMask)
.build();
Operation response = autoscalerClient.patchAutoscaler(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<PatchAutoscalerHttpRequest,Operation> patchAutoscalerCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchAutoscalerHttpRequest request = PatchAutoscalerHttpRequest.newBuilder()
.setAutoscaler(autoscaler)
.setZone(formattedZone)
.setAutoscalerResource(autoscalerResource)
.addAllFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = autoscalerClient.patchAutoscalerCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation updateAutoscaler(String autoscaler, ProjectZoneName zone, Autoscaler autoscalerResource, List<String> fieldMask)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = autoscalerClient.updateAutoscaler(autoscaler, zone, autoscalerResource, fieldMask);
}
autoscaler
- Name of the autoscaler to update.zone
- Name of the zone for this request.autoscalerResource
- Represents an Autoscaler resource. Autoscalers allow you to
automatically scale virtual machine instances in managed instance groups according to an
autoscaling policy that you define. For more information, read Autoscaling Groups of
Instances. (== resource_for beta.autoscalers ==) (== resource_for v1.autoscalers ==) (==
resource_for beta.regionAutoscalers ==) (== resource_for v1.regionAutoscalers ==)fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation updateAutoscaler(String autoscaler, String zone, Autoscaler autoscalerResource, List<String> fieldMask)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = autoscalerClient.updateAutoscaler(autoscaler, zone.toString(), autoscalerResource, fieldMask);
}
autoscaler
- Name of the autoscaler to update.zone
- Name of the zone for this request.autoscalerResource
- Represents an Autoscaler resource. Autoscalers allow you to
automatically scale virtual machine instances in managed instance groups according to an
autoscaling policy that you define. For more information, read Autoscaling Groups of
Instances. (== resource_for beta.autoscalers ==) (== resource_for v1.autoscalers ==) (==
resource_for beta.regionAutoscalers ==) (== resource_for v1.regionAutoscalers ==)fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation updateAutoscaler(UpdateAutoscalerHttpRequest request)
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
UpdateAutoscalerHttpRequest request = UpdateAutoscalerHttpRequest.newBuilder()
.setAutoscaler(autoscaler)
.setZone(formattedZone)
.setAutoscalerResource(autoscalerResource)
.addAllFieldMask(fieldMask)
.build();
Operation response = autoscalerClient.updateAutoscaler(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<UpdateAutoscalerHttpRequest,Operation> updateAutoscalerCallable()
Sample code:
try (AutoscalerClient autoscalerClient = AutoscalerClient.create()) {
String autoscaler = "";
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
Autoscaler autoscalerResource = Autoscaler.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
UpdateAutoscalerHttpRequest request = UpdateAutoscalerHttpRequest.newBuilder()
.setAutoscaler(autoscaler)
.setZone(formattedZone)
.setAutoscalerResource(autoscalerResource)
.addAllFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = autoscalerClient.updateAutoscalerCallable().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.