Search in sources :

Example 1 with DeleteExclusionRequest

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

the class SyncDeleteExclusion method syncDeleteExclusion.

public static void syncDeleteExclusion() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]").toString()).build();
        configClient.deleteExclusion(request);
    }
}
Also used : ConfigClient(com.google.cloud.logging.v2.ConfigClient) DeleteExclusionRequest(com.google.logging.v2.DeleteExclusionRequest)

Example 2 with DeleteExclusionRequest

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

the class ConfigClientTest method deleteExclusionTest.

@Test
public void deleteExclusionTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
    client.deleteExclusion(name);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteExclusionRequest actualRequest = ((DeleteExclusionRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteExclusionRequest(com.google.logging.v2.DeleteExclusionRequest) LogExclusionName(com.google.logging.v2.LogExclusionName) Test(org.junit.Test)

Example 3 with DeleteExclusionRequest

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

the class ConfigClientTest method deleteExclusionTest2.

@Test
public void deleteExclusionTest2() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockConfigServiceV2.addResponse(expectedResponse);
    String name = "name3373707";
    client.deleteExclusion(name);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteExclusionRequest actualRequest = ((DeleteExclusionRequest) 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) DeleteExclusionRequest(com.google.logging.v2.DeleteExclusionRequest) Test(org.junit.Test)

Example 4 with DeleteExclusionRequest

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

the class LoggingImplTest method testDeleteExclusion_Null.

@Test
public void testDeleteExclusion_Null() {
    DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(EXCLUSION_NAME_PB).build();
    ApiFuture<Empty> response = ApiFutures.immediateFuture(null);
    EasyMock.expect(loggingRpcMock.delete(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    assertFalse(logging.deleteExclusion(EXCLUSION_NAME));
}
Also used : Empty(com.google.protobuf.Empty) DeleteExclusionRequest(com.google.logging.v2.DeleteExclusionRequest) Test(org.junit.Test)

Example 5 with DeleteExclusionRequest

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

the class LoggingImplTest method testDeleteExclusionAsync_Null.

@Test
public void testDeleteExclusionAsync_Null() throws ExecutionException, InterruptedException {
    DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(EXCLUSION_NAME_PB).build();
    ApiFuture<Empty> response = ApiFutures.immediateFuture(null);
    EasyMock.expect(loggingRpcMock.delete(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    assertFalse(logging.deleteExclusionAsync(EXCLUSION_NAME).get());
}
Also used : Empty(com.google.protobuf.Empty) DeleteExclusionRequest(com.google.logging.v2.DeleteExclusionRequest) Test(org.junit.Test)

Aggregations

DeleteExclusionRequest (com.google.logging.v2.DeleteExclusionRequest)14 Empty (com.google.protobuf.Empty)9 Test (org.junit.Test)8 AbstractMessage (com.google.protobuf.AbstractMessage)4 ConfigClient (com.google.cloud.logging.v2.ConfigClient)2 LogExclusionName (com.google.logging.v2.LogExclusionName)2