Search in sources :

Example 1 with CancelOperationRequest

use of com.google.container.v1.CancelOperationRequest in project java-container by googleapis.

the class ClusterManagerClient method cancelOperation.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Cancels the specified operation.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (ClusterManagerClient clusterManagerClient = ClusterManagerClient.create()) {
 *   String projectId = "projectId-894832108";
 *   String zone = "zone3744684";
 *   String operationId = "operationId129704162";
 *   clusterManagerClient.cancelOperation(projectId, zone, operationId);
 * }
 * }</pre>
 *
 * @param projectId Required. Deprecated. The Google Developers Console [project ID or project
 *     number](https://support.google.com/cloud/answer/6158840). This field has been deprecated
 *     and replaced by the name field.
 * @param zone Required. Deprecated. The name of the Google Compute Engine
 *     [zone](https://cloud.google.com/compute/docs/zones#available) in which the operation
 *     resides. This field has been deprecated and replaced by the name field.
 * @param operationId Required. Deprecated. The server-assigned `name` of the operation. This
 *     field has been deprecated and replaced by the name field.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void cancelOperation(String projectId, String zone, String operationId) {
    CancelOperationRequest request = CancelOperationRequest.newBuilder().setProjectId(projectId).setZone(zone).setOperationId(operationId).build();
    cancelOperation(request);
}
Also used : CancelOperationRequest(com.google.container.v1beta1.CancelOperationRequest)

Example 2 with CancelOperationRequest

use of com.google.container.v1.CancelOperationRequest in project java-container by googleapis.

the class ClusterManagerClient method cancelOperation.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Cancels the specified operation.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (ClusterManagerClient clusterManagerClient = ClusterManagerClient.create()) {
 *   String projectId = "projectId-894832108";
 *   String zone = "zone3744684";
 *   String operationId = "operationId129704162";
 *   clusterManagerClient.cancelOperation(projectId, zone, operationId);
 * }
 * }</pre>
 *
 * @param projectId Deprecated. The Google Developers Console [project ID or project
 *     number](https://support.google.com/cloud/answer/6158840). This field has been deprecated
 *     and replaced by the name field.
 * @param zone Deprecated. The name of the Google Compute Engine
 *     [zone](https://cloud.google.com/compute/docs/zones#available) in which the operation
 *     resides. This field has been deprecated and replaced by the name field.
 * @param operationId Deprecated. The server-assigned `name` of the operation. This field has been
 *     deprecated and replaced by the name field.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void cancelOperation(String projectId, String zone, String operationId) {
    CancelOperationRequest request = CancelOperationRequest.newBuilder().setProjectId(projectId).setZone(zone).setOperationId(operationId).build();
    cancelOperation(request);
}
Also used : CancelOperationRequest(com.google.container.v1.CancelOperationRequest)

Example 3 with CancelOperationRequest

use of com.google.container.v1.CancelOperationRequest in project java-container by googleapis.

the class ClusterManagerClientTest method cancelOperationTest.

@Test
public void cancelOperationTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockClusterManager.addResponse(expectedResponse);
    String name = "name3373707";
    client.cancelOperation(name);
    List<AbstractMessage> actualRequests = mockClusterManager.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CancelOperationRequest actualRequest = ((CancelOperationRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) CancelOperationRequest(com.google.container.v1.CancelOperationRequest) Test(org.junit.Test)

Example 4 with CancelOperationRequest

use of com.google.container.v1.CancelOperationRequest in project java-container by googleapis.

the class ClusterManagerClientTest method cancelOperationTest2.

@Test
public void cancelOperationTest2() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockClusterManager.addResponse(expectedResponse);
    String projectId = "projectId-894832108";
    String zone = "zone3744684";
    String operationId = "operationId129704162";
    client.cancelOperation(projectId, zone, operationId);
    List<AbstractMessage> actualRequests = mockClusterManager.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CancelOperationRequest actualRequest = ((CancelOperationRequest) actualRequests.get(0));
    Assert.assertEquals(projectId, actualRequest.getProjectId());
    Assert.assertEquals(zone, actualRequest.getZone());
    Assert.assertEquals(operationId, actualRequest.getOperationId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) CancelOperationRequest(com.google.container.v1.CancelOperationRequest) Test(org.junit.Test)

Example 5 with CancelOperationRequest

use of com.google.container.v1.CancelOperationRequest in project java-container by googleapis.

the class ClusterManagerClientTest method cancelOperationTest.

@Test
public void cancelOperationTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockClusterManager.addResponse(expectedResponse);
    String projectId = "projectId-894832108";
    String zone = "zone3744684";
    String operationId = "operationId129704162";
    client.cancelOperation(projectId, zone, operationId);
    List<AbstractMessage> actualRequests = mockClusterManager.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CancelOperationRequest actualRequest = ((CancelOperationRequest) actualRequests.get(0));
    Assert.assertEquals(projectId, actualRequest.getProjectId());
    Assert.assertEquals(zone, actualRequest.getZone());
    Assert.assertEquals(operationId, actualRequest.getOperationId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) CancelOperationRequest(com.google.container.v1beta1.CancelOperationRequest) Test(org.junit.Test)

Aggregations

CancelOperationRequest (com.google.container.v1.CancelOperationRequest)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 Empty (com.google.protobuf.Empty)3 Test (org.junit.Test)3 CancelOperationRequest (com.google.container.v1beta1.CancelOperationRequest)2