@BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected IntentsClient(IntentsStub stub) { this.settings = null; this.stub = stub; this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); }
/** * Starts asynchronous cancellation on a long-running operation. The server makes a best effort to * cancel the operation, but success is not guaranteed. If the server doesn't support this method, * it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or other methods to check * whether the cancellation succeeded or whether the operation completed despite cancellation. On * successful cancellation, the operation is not deleted; instead, it becomes an operation with an * [Operation.error][google.longrunning.Operation.error] value with a * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. * * <p>Sample code: * * <pre><code> * try (OperationsClient operationsClient = OperationsClient.create()) { * String name = ""; * operationsClient.cancelOperation(name); * } * </code></pre> * * @param name The name of the operation resource to be cancelled. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void cancelOperation(String name) { CancelOperationRequest request = CancelOperationRequest.newBuilder().setName(name).build(); cancelOperation(request); }
/** * 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 = ""; * operationsClient.deleteOperation(name); * } * </code></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); }
/** * Gets the latest state of a long-running operation. Clients can use this method to poll the * operation result at intervals as recommended by the API service. * * <p>Sample code: * * <pre><code> * try (OperationsClient operationsClient = OperationsClient.create()) { * String name = ""; * Operation response = operationsClient.getOperation(name); * } * </code></pre> * * @param name The name of the operation resource. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Operation getOperation(String name) { GetOperationRequest request = GetOperationRequest.newBuilder().setName(name).build(); return getOperation(request); }
/** * Lists operations that match the specified filter in the request. If the server doesn't support * this method, it returns `UNIMPLEMENTED`. * * <p>NOTE: the `name` binding below allows API services to override the binding to use different * resource name schemes, such as `users/*/operations`. * * <p>Sample code: * * <pre><code> * try (OperationsClient operationsClient = OperationsClient.create()) { * String name = ""; * String filter = ""; * for (Operation element : operationsClient.listOperations(name, filter).iterateAll()) { * // doThingsWith(element); * } * } * </code></pre> * * @param name The name of the operation collection. * @param filter The standard list filter. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListOperationsPagedResponse listOperations(String name, String filter) { ListOperationsRequest request = ListOperationsRequest.newBuilder().setName(name).setFilter(filter).build(); return listOperations(request); }
/** * Constructs an instance of OperationsClient, using the given settings. The channels are created * based on the settings passed in, or defaults for any settings that are not set. */ public static final OperationsClient create(OperationsSettings settings) throws IOException { return new OperationsClient(settings); }
/** * Starts asynchronous cancellation on a long-running operation. The server makes a best effort to * cancel the operation, but success is not guaranteed. If the server doesn't support this method, * it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use * [Operations.GetOperation][google.longrunning.Operations.GetOperation] or other methods to check * whether the cancellation succeeded or whether the operation completed despite cancellation. On * successful cancellation, the operation is not deleted; instead, it becomes an operation with an * [Operation.error][google.longrunning.Operation.error] value with a * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to `Code.CANCELLED`. * * <p>Sample code: * * <pre><code> * try (OperationsClient operationsClient = OperationsClient.create()) { * String name = ""; * operationsClient.cancelOperation(name); * } * </code></pre> * * @param name The name of the operation resource to be cancelled. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void cancelOperation(String name) { CancelOperationRequest request = CancelOperationRequest.newBuilder().setName(name).build(); cancelOperation(request); }
/** * 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 = ""; * operationsClient.deleteOperation(name); * } * </code></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); }
/** * Gets the latest state of a long-running operation. Clients can use this method to poll the * operation result at intervals as recommended by the API service. * * <p>Sample code: * * <pre><code> * try (OperationsClient operationsClient = OperationsClient.create()) { * String name = ""; * Operation response = operationsClient.getOperation(name); * } * </code></pre> * * @param name The name of the operation resource. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Operation getOperation(String name) { GetOperationRequest request = GetOperationRequest.newBuilder().setName(name).build(); return getOperation(request); }
/** * Lists operations that match the specified filter in the request. If the server doesn't support * this method, it returns `UNIMPLEMENTED`. * * <p>NOTE: the `name` binding below allows API services to override the binding to use different * resource name schemes, such as `users/*/operations`. * * <p>Sample code: * * <pre><code> * try (OperationsClient operationsClient = OperationsClient.create()) { * String name = ""; * String filter = ""; * for (Operation element : operationsClient.listOperations(name, filter).iterateAll()) { * // doThingsWith(element); * } * } * </code></pre> * * @param name The name of the operation collection. * @param filter The standard list filter. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListOperationsPagedResponse listOperations(String name, String filter) { ListOperationsRequest request = ListOperationsRequest.newBuilder().setName(name).setFilter(filter).build(); return listOperations(request); }
/** * Constructs an instance of OperationsClient, using the given settings. The channels are created * based on the settings passed in, or defaults for any settings that are not set. */ public static final OperationsClient create(OperationsSettings settings) throws IOException { return new OperationsClient(settings); }
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected VideoIntelligenceServiceClient(VideoIntelligenceServiceStub stub) { this.settings = null; this.stub = stub; this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); }
@Test @SuppressWarnings("all") public void cancelOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); try { String name = "name3373707"; client.cancelOperation(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void deleteOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); try { String name = "name3373707"; client.deleteOperation(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } } }
@Test @SuppressWarnings("all") public void getOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); try { String name = "name3373707"; client.getOperation(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void listOperationsExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); try { String name = "name3373707"; String filter = "filter-1274492040"; client.listOperations(name, filter); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
/** * Constructs an instance of OperationsClient, using the given stub for making calls. This is for * advanced usage - prefer to use OperationsSettings}. */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final OperationsClient create(OperationsStub stub) { return new OperationsClient(stub); }
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected BaseBigtableInstanceAdminClient(BigtableInstanceAdminStub stub) { this.settings = null; this.stub = stub; this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); }
@Test @SuppressWarnings("all") public void cancelOperationTest() { Empty expectedResponse = Empty.newBuilder().build(); mockOperations.addResponse(expectedResponse); String name = "name3373707"; client.cancelOperation(name); List<GeneratedMessageV3> actualRequests = mockOperations.getRequests(); Assert.assertEquals(1, actualRequests.size()); CancelOperationRequest actualRequest = (CancelOperationRequest) actualRequests.get(0); Assert.assertEquals(name, actualRequest.getName()); }
@Test @SuppressWarnings("all") public void deleteOperationTest() { Empty expectedResponse = Empty.newBuilder().build(); mockOperations.addResponse(expectedResponse); String name = "name3373707"; client.deleteOperation(name); List<GeneratedMessageV3> actualRequests = mockOperations.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteOperationRequest actualRequest = (DeleteOperationRequest) actualRequests.get(0); Assert.assertEquals(name, actualRequest.getName()); }