Search in sources :

Example 1 with DeleteOperationRequest

use of com.google.longrunning.DeleteOperationRequest in project gax-java by googleapis.

the class GrpcLongRunningClientTest method delete.

@Test
public void delete() {
    OperationsStub operationsStub = mock(OperationsStub.class);
    when(operationsStub.deleteOperationCallable()).thenReturn(new UnaryCallable<DeleteOperationRequest, Empty>() {

        @Override
        public ApiFuture<Empty> futureCall(DeleteOperationRequest request, ApiCallContext context) {
            if (!request.getName().equals("poseidon")) {
                return ApiFutures.immediateFailedFuture(new IllegalStateException("Unexpected request: " + request));
            } else {
                return ApiFutures.immediateFuture(Empty.getDefaultInstance());
            }
        }
    });
    LongRunningClient longRunningClient = new GrpcLongRunningClient(operationsStub);
    Truth.assertThat(longRunningClient.deleteOperationCallable().call("poseidon")).isNull();
}
Also used : ApiFuture(com.google.api.core.ApiFuture) OperationsStub(com.google.longrunning.stub.OperationsStub) Empty(com.google.protobuf.Empty) LongRunningClient(com.google.api.gax.rpc.LongRunningClient) ApiCallContext(com.google.api.gax.rpc.ApiCallContext) DeleteOperationRequest(com.google.longrunning.DeleteOperationRequest) Test(org.junit.Test)

Example 2 with DeleteOperationRequest

use of com.google.longrunning.DeleteOperationRequest in project gax-java by googleapis.

the class OperationsClient method deleteOperation.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a long-running operation. This method indicates that the client is no longer interested
 * in the operation result. It does not cancel the operation. If the server doesn't support this
 * method, it returns `google.rpc.Code.UNIMPLEMENTED`.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (OperationsClient operationsClient = OperationsClient.create()) {
 *   String name = "name3373707";
 *   operationsClient.deleteOperation(name);
 * }
 * }</pre>
 *
 * @param name The name of the operation resource to be deleted.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteOperation(String name) {
    DeleteOperationRequest request = DeleteOperationRequest.newBuilder().setName(name).build();
    deleteOperation(request);
}
Also used : DeleteOperationRequest(com.google.longrunning.DeleteOperationRequest)

Aggregations

DeleteOperationRequest (com.google.longrunning.DeleteOperationRequest)2 ApiFuture (com.google.api.core.ApiFuture)1 ApiCallContext (com.google.api.gax.rpc.ApiCallContext)1 LongRunningClient (com.google.api.gax.rpc.LongRunningClient)1 OperationsStub (com.google.longrunning.stub.OperationsStub)1 Empty (com.google.protobuf.Empty)1 Test (org.junit.Test)1