Search in sources :

Example 1 with GetCmekSettingsRequest

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

the class ConfigClientTest method getCmekSettingsTest.

@Test
public void getCmekSettingsTest() throws Exception {
    CmekSettings expectedResponse = CmekSettings.newBuilder().setName(CmekSettingsName.ofProjectName("[PROJECT]").toString()).setKmsKeyName("kmsKeyName412586233").setServiceAccountId("serviceAccountId1964232947").build();
    mockConfigServiceV2.addResponse(expectedResponse);
    GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().setName(CmekSettingsName.ofProjectName("[PROJECT]").toString()).build();
    CmekSettings actualResponse = client.getCmekSettings(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetCmekSettingsRequest actualRequest = ((GetCmekSettingsRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CmekSettings(com.google.logging.v2.CmekSettings) GetCmekSettingsRequest(com.google.logging.v2.GetCmekSettingsRequest) Test(org.junit.Test)

Example 2 with GetCmekSettingsRequest

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

the class AsyncGetCmekSettings method asyncGetCmekSettings.

public static void asyncGetCmekSettings() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().setName(CmekSettingsName.ofProjectName("[PROJECT]").toString()).build();
        ApiFuture<CmekSettings> future = configClient.getCmekSettingsCallable().futureCall(request);
        // Do something.
        CmekSettings response = future.get();
    }
}
Also used : ConfigClient(com.google.cloud.logging.v2.ConfigClient) CmekSettings(com.google.logging.v2.CmekSettings) GetCmekSettingsRequest(com.google.logging.v2.GetCmekSettingsRequest)

Example 3 with GetCmekSettingsRequest

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

the class ConfigClientTest method getCmekSettingsTest.

@Test
public void getCmekSettingsTest() throws Exception {
    CmekSettings expectedResponse = CmekSettings.newBuilder().setName(CmekSettingsName.ofProjectCmekSettingsName("[PROJECT]").toString()).setKmsKeyName("kmsKeyName412586233").setServiceAccountId("serviceAccountId1964232947").build();
    mockConfigServiceV2.addResponse(expectedResponse);
    GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().setName(CmekSettingsName.ofProjectCmekSettingsName("[PROJECT]").toString()).build();
    CmekSettings actualResponse = client.getCmekSettings(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetCmekSettingsRequest actualRequest = ((GetCmekSettingsRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CmekSettings(com.google.logging.v2.CmekSettings) GetCmekSettingsRequest(com.google.logging.v2.GetCmekSettingsRequest) Test(org.junit.Test)

Example 4 with GetCmekSettingsRequest

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

the class ConfigClientTest method getCmekSettingsExceptionTest.

@Test
public void getCmekSettingsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().setName(CmekSettingsName.ofProjectCmekSettingsName("[PROJECT]").toString()).build();
        client.getCmekSettings(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) GetCmekSettingsRequest(com.google.logging.v2.GetCmekSettingsRequest) Test(org.junit.Test)

Example 5 with GetCmekSettingsRequest

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

the class SyncGetCmekSettings method syncGetCmekSettings.

public static void syncGetCmekSettings() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().setName(CmekSettingsName.ofProjectName("[PROJECT]").toString()).build();
        CmekSettings response = configClient.getCmekSettings(request);
    }
}
Also used : ConfigClient(com.google.cloud.logging.v2.ConfigClient) CmekSettings(com.google.logging.v2.CmekSettings) GetCmekSettingsRequest(com.google.logging.v2.GetCmekSettingsRequest)

Aggregations

GetCmekSettingsRequest (com.google.logging.v2.GetCmekSettingsRequest)6 CmekSettings (com.google.logging.v2.CmekSettings)4 Test (org.junit.Test)4 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