/** * 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 = ""; * DeleteOperationRequest request = DeleteOperationRequest.newBuilder() * .setName(name) * .build(); * ApiFuture<Void> future = operationsClient.deleteOperationCallable().futureCall(request); * // Do something * future.get(); * } * </code></pre> */ public final UnaryCallable<DeleteOperationRequest, Empty> deleteOperationCallable() { return stub.deleteOperationCallable(); }
/** * 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 = ""; * DeleteOperationRequest request = DeleteOperationRequest.newBuilder() * .setName(name) * .build(); * ApiFuture<Void> future = operationsClient.deleteOperationCallable().futureCall(request); * // Do something * future.get(); * } * </code></pre> */ public final UnaryCallable<DeleteOperationRequest, Empty> deleteOperationCallable() { return stub.deleteOperationCallable(); }
@Override public UnaryCallable<String, Void> deleteOperationCallable() { return TranslatingUnaryCallable.create( operationsStub.deleteOperationCallable(), new ApiFunction<String, DeleteOperationRequest>() { @Override public DeleteOperationRequest apply(String request) { return DeleteOperationRequest.newBuilder().setName(request).build(); } }, new ApiFunction<Empty, Void>() { @Override public Void apply(Empty empty) { return null; } }); }
@Override public UnaryCallable<String, Void> deleteOperationCallable() { return TranslatingUnaryCallable.create( operationsStub.deleteOperationCallable(), new ApiFunction<String, DeleteOperationRequest>() { @Override public DeleteOperationRequest apply(String request) { return DeleteOperationRequest.newBuilder().setName(request).build(); } }, new ApiFunction<Empty, Void>() { @Override public Void apply(Empty empty) { return null; } }); }
@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(); } }