Class GlobalOperationsClient (1.64.0)

GitHub RepositoryProduct Reference

Service Description: The GlobalOperations API.

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   String project = "project-309310695";
   String operation = "operation1662702951";
   DeleteGlobalOperationResponse response = globalOperationsClient.delete(project, operation);
 }
 

Note: close() needs to be called on the GlobalOperationsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

AggregatedList

Retrieves an aggregated list of all operations. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • aggregatedList(AggregatedListGlobalOperationsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • aggregatedList(String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • aggregatedListPagedCallable()

  • aggregatedListCallable()

Delete

Deletes the specified Operations resource.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • delete(DeleteGlobalOperationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • delete(String project, String operation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteCallable()

Get

Retrieves the specified Operations resource.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • get(GetGlobalOperationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • get(String project, String operation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getCallable()

List

Retrieves a list of Operation resources contained within the specified project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • list(ListGlobalOperationsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • list(String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listPagedCallable()

  • listCallable()

Wait

Waits for the specified Operation resource to return as DONE or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the GET method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be DONE or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not DONE.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • wait(WaitGlobalOperationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • wait(String project, String operation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • waitCallable()

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 GlobalOperationsSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 GlobalOperationsSettings globalOperationsSettings =
     GlobalOperationsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 GlobalOperationsClient globalOperationsClient =
     GlobalOperationsClient.create(globalOperationsSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 GlobalOperationsSettings globalOperationsSettings =
     GlobalOperationsSettings.newBuilder().setEndpoint(myEndpoint).build();
 GlobalOperationsClient globalOperationsClient =
     GlobalOperationsClient.create(globalOperationsSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > GlobalOperationsClient

Static Methods

create()

public static final GlobalOperationsClient create()

Constructs an instance of GlobalOperationsClient with default settings.

Returns
Type Description
GlobalOperationsClient
Exceptions
Type Description
IOException

create(GlobalOperationsSettings settings)

public static final GlobalOperationsClient create(GlobalOperationsSettings settings)

Constructs an instance of GlobalOperationsClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings GlobalOperationsSettings
Returns
Type Description
GlobalOperationsClient
Exceptions
Type Description
IOException

create(GlobalOperationsStub stub)

public static final GlobalOperationsClient create(GlobalOperationsStub stub)

Constructs an instance of GlobalOperationsClient, using the given stub for making calls. This is for advanced usage - prefer using create(GlobalOperationsSettings).

Parameter
Name Description
stub GlobalOperationsStub
Returns
Type Description
GlobalOperationsClient

Constructors

GlobalOperationsClient(GlobalOperationsSettings settings)

protected GlobalOperationsClient(GlobalOperationsSettings settings)

Constructs an instance of GlobalOperationsClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings GlobalOperationsSettings

GlobalOperationsClient(GlobalOperationsStub stub)

protected GlobalOperationsClient(GlobalOperationsStub stub)
Parameter
Name Description
stub GlobalOperationsStub

Methods

aggregatedList(AggregatedListGlobalOperationsRequest request)

public final GlobalOperationsClient.AggregatedListPagedResponse aggregatedList(AggregatedListGlobalOperationsRequest request)

Retrieves an aggregated list of all operations. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   AggregatedListGlobalOperationsRequest request =
       AggregatedListGlobalOperationsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setIncludeAllScopes(true)
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .setServiceProjectNumber(-1293855239)
           .build();
   for (Map.Entry<String, OperationsScopedList> element :
       globalOperationsClient.aggregatedList(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request AggregatedListGlobalOperationsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
GlobalOperationsClient.AggregatedListPagedResponse

aggregatedList(String project)

public final GlobalOperationsClient.AggregatedListPagedResponse aggregatedList(String project)

Retrieves an aggregated list of all operations. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   String project = "project-309310695";
   for (Map.Entry<String, OperationsScopedList> element :
       globalOperationsClient.aggregatedList(project).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
project String

Project ID for this request.

Returns
Type Description
GlobalOperationsClient.AggregatedListPagedResponse

aggregatedListCallable()

public final UnaryCallable<AggregatedListGlobalOperationsRequest,OperationAggregatedList> aggregatedListCallable()

Retrieves an aggregated list of all operations. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   AggregatedListGlobalOperationsRequest request =
       AggregatedListGlobalOperationsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setIncludeAllScopes(true)
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .setServiceProjectNumber(-1293855239)
           .build();
   while (true) {
     OperationAggregatedList response =
         globalOperationsClient.aggregatedListCallable().call(request);
     for (Map.Entry<String, OperationsScopedList> element : response.getItemsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<AggregatedListGlobalOperationsRequest,OperationAggregatedList>

aggregatedListPagedCallable()

public final UnaryCallable<AggregatedListGlobalOperationsRequest,GlobalOperationsClient.AggregatedListPagedResponse> aggregatedListPagedCallable()

Retrieves an aggregated list of all operations. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   AggregatedListGlobalOperationsRequest request =
       AggregatedListGlobalOperationsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setIncludeAllScopes(true)
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .setServiceProjectNumber(-1293855239)
           .build();
   ApiFuture<Map.Entry<String, OperationsScopedList>> future =
       globalOperationsClient.aggregatedListPagedCallable().futureCall(request);
   // Do something.
   for (Map.Entry<String, OperationsScopedList> element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<AggregatedListGlobalOperationsRequest,AggregatedListPagedResponse>

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

delete(DeleteGlobalOperationRequest request)

public final DeleteGlobalOperationResponse delete(DeleteGlobalOperationRequest request)

Deletes the specified Operations resource.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   DeleteGlobalOperationRequest request =
       DeleteGlobalOperationRequest.newBuilder()
           .setOperation("operation1662702951")
           .setProject("project-309310695")
           .build();
   DeleteGlobalOperationResponse response = globalOperationsClient.delete(request);
 }
 
Parameter
Name Description
request DeleteGlobalOperationRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
DeleteGlobalOperationResponse

delete(String project, String operation)

public final DeleteGlobalOperationResponse delete(String project, String operation)

Deletes the specified Operations resource.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   String project = "project-309310695";
   String operation = "operation1662702951";
   DeleteGlobalOperationResponse response = globalOperationsClient.delete(project, operation);
 }
 
Parameters
Name Description
project String

Project ID for this request.

operation String

Name of the Operations resource to delete, or its unique numeric identifier.

Returns
Type Description
DeleteGlobalOperationResponse

deleteCallable()

public final UnaryCallable<DeleteGlobalOperationRequest,DeleteGlobalOperationResponse> deleteCallable()

Deletes the specified Operations resource.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   DeleteGlobalOperationRequest request =
       DeleteGlobalOperationRequest.newBuilder()
           .setOperation("operation1662702951")
           .setProject("project-309310695")
           .build();
   ApiFuture<DeleteGlobalOperationResponse> future =
       globalOperationsClient.deleteCallable().futureCall(request);
   // Do something.
   DeleteGlobalOperationResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteGlobalOperationRequest,DeleteGlobalOperationResponse>

get(GetGlobalOperationRequest request)

public final Operation get(GetGlobalOperationRequest request)

Retrieves the specified Operations resource.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   GetGlobalOperationRequest request =
       GetGlobalOperationRequest.newBuilder()
           .setOperation("operation1662702951")
           .setProject("project-309310695")
           .build();
   Operation response = globalOperationsClient.get(request);
 }
 
Parameter
Name Description
request GetGlobalOperationRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Operation

get(String project, String operation)

public final Operation get(String project, String operation)

Retrieves the specified Operations resource.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   String project = "project-309310695";
   String operation = "operation1662702951";
   Operation response = globalOperationsClient.get(project, operation);
 }
 
Parameters
Name Description
project String

Project ID for this request.

operation String

Name of the Operations resource to return, or its unique numeric identifier.

Returns
Type Description
Operation

getCallable()

public final UnaryCallable<GetGlobalOperationRequest,Operation> getCallable()

Retrieves the specified Operations resource.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   GetGlobalOperationRequest request =
       GetGlobalOperationRequest.newBuilder()
           .setOperation("operation1662702951")
           .setProject("project-309310695")
           .build();
   ApiFuture<Operation> future = globalOperationsClient.getCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetGlobalOperationRequest,Operation>

getSettings()

public final GlobalOperationsSettings getSettings()
Returns
Type Description
GlobalOperationsSettings

getStub()

public GlobalOperationsStub getStub()
Returns
Type Description
GlobalOperationsStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

list(ListGlobalOperationsRequest request)

public final GlobalOperationsClient.ListPagedResponse list(ListGlobalOperationsRequest request)

Retrieves a list of Operation resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   ListGlobalOperationsRequest request =
       ListGlobalOperationsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   for (Operation element : globalOperationsClient.list(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListGlobalOperationsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
GlobalOperationsClient.ListPagedResponse

list(String project)

public final GlobalOperationsClient.ListPagedResponse list(String project)

Retrieves a list of Operation resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   String project = "project-309310695";
   for (Operation element : globalOperationsClient.list(project).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
project String

Project ID for this request.

Returns
Type Description
GlobalOperationsClient.ListPagedResponse

listCallable()

public final UnaryCallable<ListGlobalOperationsRequest,OperationList> listCallable()

Retrieves a list of Operation resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   ListGlobalOperationsRequest request =
       ListGlobalOperationsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   while (true) {
     OperationList response = globalOperationsClient.listCallable().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;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListGlobalOperationsRequest,OperationList>

listPagedCallable()

public final UnaryCallable<ListGlobalOperationsRequest,GlobalOperationsClient.ListPagedResponse> listPagedCallable()

Retrieves a list of Operation resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   ListGlobalOperationsRequest request =
       ListGlobalOperationsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   ApiFuture<Operation> future = globalOperationsClient.listPagedCallable().futureCall(request);
   // Do something.
   for (Operation element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListGlobalOperationsRequest,ListPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

wait(WaitGlobalOperationRequest request)

public final Operation wait(WaitGlobalOperationRequest request)

Waits for the specified Operation resource to return as DONE or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the GET method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be DONE or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not DONE.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   WaitGlobalOperationRequest request =
       WaitGlobalOperationRequest.newBuilder()
           .setOperation("operation1662702951")
           .setProject("project-309310695")
           .build();
   Operation response = globalOperationsClient.wait(request);
 }
 
Parameter
Name Description
request WaitGlobalOperationRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Operation

wait(String project, String operation)

public final Operation wait(String project, String operation)

Waits for the specified Operation resource to return as DONE or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the GET method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be DONE or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not DONE.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   String project = "project-309310695";
   String operation = "operation1662702951";
   Operation response = globalOperationsClient.wait(project, operation);
 }
 
Parameters
Name Description
project String

Project ID for this request.

operation String

Name of the Operations resource to return, or its unique numeric identifier.

Returns
Type Description
Operation

waitCallable()

public final UnaryCallable<WaitGlobalOperationRequest,Operation> waitCallable()

Waits for the specified Operation resource to return as DONE or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the GET method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be DONE or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not DONE.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) {
   WaitGlobalOperationRequest request =
       WaitGlobalOperationRequest.newBuilder()
           .setOperation("operation1662702951")
           .setProject("project-309310695")
           .build();
   ApiFuture<Operation> future = globalOperationsClient.waitCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<WaitGlobalOperationRequest,Operation>