@Generated(value="by gapic-generator") @BetaApi public class GlobalOperationClient 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 (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectGlobalOperationName operation = ProjectGlobalOperationName.of("[PROJECT]", "[OPERATION]");
globalOperationClient.deleteGlobalOperation(operation);
}
Note: close() needs to be called on the globalOperationClient 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 GlobalOperationSettings to create(). For example:
To customize credentials:
GlobalOperationSettings globalOperationSettings =
GlobalOperationSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
GlobalOperationClient globalOperationClient =
GlobalOperationClient.create(globalOperationSettings);
To customize the endpoint:
GlobalOperationSettings globalOperationSettings =
GlobalOperationSettings.newBuilder().setEndpoint(myEndpoint).build();
GlobalOperationClient globalOperationClient =
GlobalOperationClient.create(globalOperationSettings);
Modifier and Type | Class and Description |
---|---|
static class |
GlobalOperationClient.AggregatedListGlobalOperationsFixedSizeCollection |
static class |
GlobalOperationClient.AggregatedListGlobalOperationsPage |
static class |
GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse |
static class |
GlobalOperationClient.ListGlobalOperationsFixedSizeCollection |
static class |
GlobalOperationClient.ListGlobalOperationsPage |
static class |
GlobalOperationClient.ListGlobalOperationsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
GlobalOperationClient(GlobalOperationSettings settings)
Constructs an instance of GlobalOperationClient, using the given settings.
|
protected |
GlobalOperationClient(GlobalOperationStub stub) |
Modifier and Type | Method and Description |
---|---|
GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse |
aggregatedListGlobalOperations(AggregatedListGlobalOperationsHttpRequest request)
Retrieves an aggregated list of all operations.
|
GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse |
aggregatedListGlobalOperations(ProjectName project)
Retrieves an aggregated list of all operations.
|
GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse |
aggregatedListGlobalOperations(String project)
Retrieves an aggregated list of all operations.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListGlobalOperationsHttpRequest,OperationAggregatedList> |
aggregatedListGlobalOperationsCallable()
Retrieves an aggregated list of all operations.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListGlobalOperationsHttpRequest,GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse> |
aggregatedListGlobalOperationsPagedCallable()
Retrieves an aggregated list of all operations.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static GlobalOperationClient |
create()
Constructs an instance of GlobalOperationClient with default settings.
|
static GlobalOperationClient |
create(GlobalOperationSettings settings)
Constructs an instance of GlobalOperationClient, using the given settings.
|
static GlobalOperationClient |
create(GlobalOperationStub stub)
Constructs an instance of GlobalOperationClient, using the given stub for making calls.
|
void |
deleteGlobalOperation(DeleteGlobalOperationHttpRequest request)
Deletes the specified Operations resource.
|
void |
deleteGlobalOperation(ProjectGlobalOperationName operation)
Deletes the specified Operations resource.
|
void |
deleteGlobalOperation(String operation)
Deletes the specified Operations resource.
|
com.google.api.gax.rpc.UnaryCallable<DeleteGlobalOperationHttpRequest,Void> |
deleteGlobalOperationCallable()
Deletes the specified Operations resource.
|
Operation |
getGlobalOperation(GetGlobalOperationHttpRequest request)
Retrieves the specified Operations resource.
|
Operation |
getGlobalOperation(ProjectGlobalOperationName operation)
Retrieves the specified Operations resource.
|
Operation |
getGlobalOperation(String operation)
Retrieves the specified Operations resource.
|
com.google.api.gax.rpc.UnaryCallable<GetGlobalOperationHttpRequest,Operation> |
getGlobalOperationCallable()
Retrieves the specified Operations resource.
|
GlobalOperationSettings |
getSettings() |
GlobalOperationStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
GlobalOperationClient.ListGlobalOperationsPagedResponse |
listGlobalOperations(ListGlobalOperationsHttpRequest request)
Retrieves a list of Operation resources contained within the specified project.
|
GlobalOperationClient.ListGlobalOperationsPagedResponse |
listGlobalOperations(ProjectName project)
Retrieves a list of Operation resources contained within the specified project.
|
GlobalOperationClient.ListGlobalOperationsPagedResponse |
listGlobalOperations(String project)
Retrieves a list of Operation resources contained within the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListGlobalOperationsHttpRequest,OperationList> |
listGlobalOperationsCallable()
Retrieves a list of Operation resources contained within the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListGlobalOperationsHttpRequest,GlobalOperationClient.ListGlobalOperationsPagedResponse> |
listGlobalOperationsPagedCallable()
Retrieves a list of Operation resources contained within the specified project.
|
void |
shutdown() |
void |
shutdownNow() |
protected GlobalOperationClient(GlobalOperationSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected GlobalOperationClient(GlobalOperationStub stub)
public static final GlobalOperationClient create() throws IOException
IOException
public static final GlobalOperationClient create(GlobalOperationSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final GlobalOperationClient create(GlobalOperationStub stub)
public final GlobalOperationSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public GlobalOperationStub getStub()
@BetaApi public final GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse aggregatedListGlobalOperations(ProjectName project)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (OperationsScopedList element : globalOperationClient.aggregatedListGlobalOperations(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse aggregatedListGlobalOperations(String project)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (OperationsScopedList element : globalOperationClient.aggregatedListGlobalOperations(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse aggregatedListGlobalOperations(AggregatedListGlobalOperationsHttpRequest request)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListGlobalOperationsHttpRequest request = AggregatedListGlobalOperationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (OperationsScopedList element : globalOperationClient.aggregatedListGlobalOperations(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<AggregatedListGlobalOperationsHttpRequest,GlobalOperationClient.AggregatedListGlobalOperationsPagedResponse> aggregatedListGlobalOperationsPagedCallable()
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListGlobalOperationsHttpRequest request = AggregatedListGlobalOperationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListGlobalOperationsPagedResponse> future = globalOperationClient.aggregatedListGlobalOperationsPagedCallable().futureCall(request);
// Do something
for (OperationsScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListGlobalOperationsHttpRequest,OperationAggregatedList> aggregatedListGlobalOperationsCallable()
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListGlobalOperationsHttpRequest request = AggregatedListGlobalOperationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
OperationAggregatedList response = globalOperationClient.aggregatedListGlobalOperationsCallable().call(request);
for (OperationsScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final void deleteGlobalOperation(ProjectGlobalOperationName operation)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectGlobalOperationName operation = ProjectGlobalOperationName.of("[PROJECT]", "[OPERATION]");
globalOperationClient.deleteGlobalOperation(operation);
}
operation
- Name of the Operations resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final void deleteGlobalOperation(String operation)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectGlobalOperationName operation = ProjectGlobalOperationName.of("[PROJECT]", "[OPERATION]");
globalOperationClient.deleteGlobalOperation(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 deleteGlobalOperation(DeleteGlobalOperationHttpRequest request)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedOperation = ProjectGlobalOperationName.format("[PROJECT]", "[OPERATION]");
DeleteGlobalOperationHttpRequest request = DeleteGlobalOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
globalOperationClient.deleteGlobalOperation(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<DeleteGlobalOperationHttpRequest,Void> deleteGlobalOperationCallable()
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedOperation = ProjectGlobalOperationName.format("[PROJECT]", "[OPERATION]");
DeleteGlobalOperationHttpRequest request = DeleteGlobalOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
ApiFuture<Void> future = globalOperationClient.deleteGlobalOperationCallable().futureCall(request);
// Do something
future.get();
}
@BetaApi public final Operation getGlobalOperation(ProjectGlobalOperationName operation)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectGlobalOperationName operation = ProjectGlobalOperationName.of("[PROJECT]", "[OPERATION]");
Operation response = globalOperationClient.getGlobalOperation(operation);
}
operation
- Name of the Operations resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation getGlobalOperation(String operation)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectGlobalOperationName operation = ProjectGlobalOperationName.of("[PROJECT]", "[OPERATION]");
Operation response = globalOperationClient.getGlobalOperation(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 getGlobalOperation(GetGlobalOperationHttpRequest request)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedOperation = ProjectGlobalOperationName.format("[PROJECT]", "[OPERATION]");
GetGlobalOperationHttpRequest request = GetGlobalOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
Operation response = globalOperationClient.getGlobalOperation(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<GetGlobalOperationHttpRequest,Operation> getGlobalOperationCallable()
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedOperation = ProjectGlobalOperationName.format("[PROJECT]", "[OPERATION]");
GetGlobalOperationHttpRequest request = GetGlobalOperationHttpRequest.newBuilder()
.setOperation(formattedOperation)
.build();
ApiFuture<Operation> future = globalOperationClient.getGlobalOperationCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final GlobalOperationClient.ListGlobalOperationsPagedResponse listGlobalOperations(ProjectName project)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Operation element : globalOperationClient.listGlobalOperations(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final GlobalOperationClient.ListGlobalOperationsPagedResponse listGlobalOperations(String project)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Operation element : globalOperationClient.listGlobalOperations(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final GlobalOperationClient.ListGlobalOperationsPagedResponse listGlobalOperations(ListGlobalOperationsHttpRequest request)
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalOperationsHttpRequest request = ListGlobalOperationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (Operation element : globalOperationClient.listGlobalOperations(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<ListGlobalOperationsHttpRequest,GlobalOperationClient.ListGlobalOperationsPagedResponse> listGlobalOperationsPagedCallable()
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalOperationsHttpRequest request = ListGlobalOperationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListGlobalOperationsPagedResponse> future = globalOperationClient.listGlobalOperationsPagedCallable().futureCall(request);
// Do something
for (Operation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListGlobalOperationsHttpRequest,OperationList> listGlobalOperationsCallable()
Sample code:
try (GlobalOperationClient globalOperationClient = GlobalOperationClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalOperationsHttpRequest request = ListGlobalOperationsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
OperationList response = globalOperationClient.listGlobalOperationsCallable().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.