Search in sources :

Example 1 with DeleteViewRequest

use of com.google.logging.v2.DeleteViewRequest in project gapic-generator-java by googleapis.

the class ConfigClientTest method deleteViewExceptionTest.

@Test
public void deleteViewExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        DeleteViewRequest request = DeleteViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
        client.deleteView(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) DeleteViewRequest(com.google.logging.v2.DeleteViewRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 2 with DeleteViewRequest

use of com.google.logging.v2.DeleteViewRequest in project gapic-generator-java by googleapis.

the class AsyncDeleteView method asyncDeleteView.

public static void asyncDeleteView() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        DeleteViewRequest request = DeleteViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
        ApiFuture<Empty> future = configClient.deleteViewCallable().futureCall(request);
        // Do something.
        future.get();
    }
}
Also used : ConfigClient(com.google.cloud.logging.v2.ConfigClient) Empty(com.google.protobuf.Empty) DeleteViewRequest(com.google.logging.v2.DeleteViewRequest)

Example 3 with DeleteViewRequest

use of com.google.logging.v2.DeleteViewRequest in project gapic-generator-java by googleapis.

the class SyncDeleteView method syncDeleteView.

public static void syncDeleteView() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        DeleteViewRequest request = DeleteViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
        configClient.deleteView(request);
    }
}
Also used : ConfigClient(com.google.cloud.logging.v2.ConfigClient) DeleteViewRequest(com.google.logging.v2.DeleteViewRequest)

Example 4 with DeleteViewRequest

use of com.google.logging.v2.DeleteViewRequest in project java-logging by googleapis.

the class ConfigClientTest method deleteViewExceptionTest.

@Test
public void deleteViewExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        DeleteViewRequest request = DeleteViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
        client.deleteView(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) DeleteViewRequest(com.google.logging.v2.DeleteViewRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 5 with DeleteViewRequest

use of com.google.logging.v2.DeleteViewRequest in project java-logging by googleapis.

the class ConfigClientTest method deleteViewTest.

@Test
public void deleteViewTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    DeleteViewRequest request = DeleteViewRequest.newBuilder().setName(LogViewName.ofProjectLocationBucketViewName("[PROJECT]", "[LOCATION]", "[BUCKET]", "[VIEW]").toString()).build();
    client.deleteView(request);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteViewRequest actualRequest = ((DeleteViewRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteViewRequest(com.google.logging.v2.DeleteViewRequest) Test(org.junit.Test)

Aggregations

DeleteViewRequest (com.google.logging.v2.DeleteViewRequest)6 Test (org.junit.Test)4 Empty (com.google.protobuf.Empty)3 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)2 ConfigClient (com.google.cloud.logging.v2.ConfigClient)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2