@Generated(value="by gapic-generator") @BetaApi public class GlobalOperationClient 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 (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) |
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.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.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.ApiException
- if the remote call fails@BetaApi public final 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 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.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.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.ApiException
- if the remote call fails@BetaApi public final 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.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.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.ApiException
- if the remote call fails@BetaApi public final 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.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.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.ApiException
- if the remote call fails@BetaApi public final 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 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 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.