@Generated(value="by gapic-generator") @BetaApi public class ZoneOperationClient extends Object implements com.google.api.gax.core.BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
zoneOperationClient.deleteZoneOperation(operation);
}
Note: close() needs to be called on the zoneOperationClient 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 ZoneOperationSettings to create(). For example:
To customize credentials:
ZoneOperationSettings zoneOperationSettings =
ZoneOperationSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ZoneOperationClient zoneOperationClient =
ZoneOperationClient.create(zoneOperationSettings);
To customize the endpoint:
ZoneOperationSettings zoneOperationSettings =
ZoneOperationSettings.newBuilder().setEndpoint(myEndpoint).build();
ZoneOperationClient zoneOperationClient =
ZoneOperationClient.create(zoneOperationSettings);
Modifier and Type | Class and Description |
---|---|
static class |
ZoneOperationClient.ListZoneOperationsFixedSizeCollection |
static class |
ZoneOperationClient.ListZoneOperationsPage |
static class |
ZoneOperationClient.ListZoneOperationsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ZoneOperationClient(ZoneOperationSettings settings)
Constructs an instance of ZoneOperationClient, using the given settings.
|
protected |
ZoneOperationClient(ZoneOperationStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ZoneOperationClient |
create()
Constructs an instance of ZoneOperationClient with default settings.
|
static ZoneOperationClient |
create(ZoneOperationSettings settings)
Constructs an instance of ZoneOperationClient, using the given settings.
|
static ZoneOperationClient |
create(ZoneOperationStub stub)
Constructs an instance of ZoneOperationClient, using the given stub for making calls.
|
void |
deleteZoneOperation(DeleteZoneOperationHttpRequest request)
Deletes the specified zone-specific Operations resource.
|
void |
deleteZoneOperation(ProjectZoneOperationName operation)
Deletes the specified zone-specific Operations resource.
|
void |
deleteZoneOperation(String operation)
Deletes the specified zone-specific Operations resource.
|
com.google.api.gax.rpc.UnaryCallable<DeleteZoneOperationHttpRequest,Void> |
deleteZoneOperationCallable()
Deletes the specified zone-specific Operations resource.
|
ZoneOperationSettings |
getSettings() |
ZoneOperationStub |
getStub() |
Operation |
getZoneOperation(GetZoneOperationHttpRequest request)
Retrieves the specified zone-specific Operations resource.
|
Operation |
getZoneOperation(ProjectZoneOperationName operation)
Retrieves the specified zone-specific Operations resource.
|
Operation |
getZoneOperation(String operation)
Retrieves the specified zone-specific Operations resource.
|
com.google.api.gax.rpc.UnaryCallable<GetZoneOperationHttpRequest,Operation> |
getZoneOperationCallable()
Retrieves the specified zone-specific Operations resource.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
ZoneOperationClient.ListZoneOperationsPagedResponse |
listZoneOperations(ListZoneOperationsHttpRequest request)
Retrieves a list of Operation resources contained within the specified zone.
|
ZoneOperationClient.ListZoneOperationsPagedResponse |
listZoneOperations(ProjectZoneName zone)
Retrieves a list of Operation resources contained within the specified zone.
|
ZoneOperationClient.ListZoneOperationsPagedResponse |
listZoneOperations(String zone)
Retrieves a list of Operation resources contained within the specified zone.
|
com.google.api.gax.rpc.UnaryCallable<ListZoneOperationsHttpRequest,OperationList> |
listZoneOperationsCallable()
Retrieves a list of Operation resources contained within the specified zone.
|
com.google.api.gax.rpc.UnaryCallable<ListZoneOperationsHttpRequest,ZoneOperationClient.ListZoneOperationsPagedResponse> |
listZoneOperationsPagedCallable()
Retrieves a list of Operation resources contained within the specified zone.
|
void |
shutdown() |
void |
shutdownNow() |
protected ZoneOperationClient(ZoneOperationSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ZoneOperationClient(ZoneOperationStub stub)
public static final ZoneOperationClient create() throws IOException
IOException
public static final ZoneOperationClient create(ZoneOperationSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ZoneOperationClient create(ZoneOperationStub stub)
public final ZoneOperationSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ZoneOperationStub getStub()
@BetaApi public final void deleteZoneOperation(ProjectZoneOperationName operation)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
zoneOperationClient.deleteZoneOperation(operation);
}
operation
- Name of the Operations resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final void deleteZoneOperation(String operation)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
zoneOperationClient.deleteZoneOperation(operation.toString());
}
operation
- Name of the Operations resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final void deleteZoneOperation(DeleteZoneOperationHttpRequest request)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
String formattedOperation = ProjectZoneOperationName.format("[PROJECT]", "[ZONE]", "[OPERATION]");
DeleteZoneOperationHttpRequest request = DeleteZoneOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
zoneOperationClient.deleteZoneOperation(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<DeleteZoneOperationHttpRequest,Void> deleteZoneOperationCallable()
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
String formattedOperation = ProjectZoneOperationName.format("[PROJECT]", "[ZONE]", "[OPERATION]");
DeleteZoneOperationHttpRequest request = DeleteZoneOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
ApiFuture<Void> future = zoneOperationClient.deleteZoneOperationCallable().futureCall(request);
// Do something
future.get();
}
@BetaApi public final Operation getZoneOperation(ProjectZoneOperationName operation)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
Operation response = zoneOperationClient.getZoneOperation(operation);
}
operation
- Name of the Operations resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation getZoneOperation(String operation)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneOperationName operation = ProjectZoneOperationName.of("[PROJECT]", "[ZONE]", "[OPERATION]");
Operation response = zoneOperationClient.getZoneOperation(operation.toString());
}
operation
- Name of the Operations resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation getZoneOperation(GetZoneOperationHttpRequest request)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
String formattedOperation = ProjectZoneOperationName.format("[PROJECT]", "[ZONE]", "[OPERATION]");
GetZoneOperationHttpRequest request = GetZoneOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
Operation response = zoneOperationClient.getZoneOperation(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<GetZoneOperationHttpRequest,Operation> getZoneOperationCallable()
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
String formattedOperation = ProjectZoneOperationName.format("[PROJECT]", "[ZONE]", "[OPERATION]");
GetZoneOperationHttpRequest request = GetZoneOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
ApiFuture<Operation> future = zoneOperationClient.getZoneOperationCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final ZoneOperationClient.ListZoneOperationsPagedResponse listZoneOperations(ProjectZoneName zone)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (Operation element : zoneOperationClient.listZoneOperations(zone).iterateAll()) {
// doThingsWith(element);
}
}
zone
- Name of the zone for request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ZoneOperationClient.ListZoneOperationsPagedResponse listZoneOperations(String zone)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
ProjectZoneName zone = ProjectZoneName.of("[PROJECT]", "[ZONE]");
for (Operation element : zoneOperationClient.listZoneOperations(zone.toString()).iterateAll()) {
// doThingsWith(element);
}
}
zone
- Name of the zone for request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ZoneOperationClient.ListZoneOperationsPagedResponse listZoneOperations(ListZoneOperationsHttpRequest request)
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListZoneOperationsHttpRequest request = ListZoneOperationsHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
for (Operation element : zoneOperationClient.listZoneOperations(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListZoneOperationsHttpRequest,ZoneOperationClient.ListZoneOperationsPagedResponse> listZoneOperationsPagedCallable()
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListZoneOperationsHttpRequest request = ListZoneOperationsHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
ApiFuture<ListZoneOperationsPagedResponse> future = zoneOperationClient.listZoneOperationsPagedCallable().futureCall(request);
// Do something
for (Operation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListZoneOperationsHttpRequest,OperationList> listZoneOperationsCallable()
Sample code:
try (ZoneOperationClient zoneOperationClient = ZoneOperationClient.create()) {
String formattedZone = ProjectZoneName.format("[PROJECT]", "[ZONE]");
ListZoneOperationsHttpRequest request = ListZoneOperationsHttpRequest.newBuilder()
.setZone(formattedZone)
.build();
while (true) {
OperationList response = zoneOperationClient.listZoneOperationsCallable().call(request);
for (Operation element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.