Search in sources :

Example 1 with UpdateCmekSettingsRequest

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

the class ConfigClientTest method updateCmekSettingsExceptionTest.

@Test
public void updateCmekSettingsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        UpdateCmekSettingsRequest request = UpdateCmekSettingsRequest.newBuilder().setName("name3373707").setCmekSettings(CmekSettings.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
        client.updateCmekSettings(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : UpdateCmekSettingsRequest(com.google.logging.v2.UpdateCmekSettingsRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 2 with UpdateCmekSettingsRequest

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

the class AsyncUpdateCmekSettings method asyncUpdateCmekSettings.

public static void asyncUpdateCmekSettings() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        UpdateCmekSettingsRequest request = UpdateCmekSettingsRequest.newBuilder().setName("name3373707").setCmekSettings(CmekSettings.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
        ApiFuture<CmekSettings> future = configClient.updateCmekSettingsCallable().futureCall(request);
        // Do something.
        CmekSettings response = future.get();
    }
}
Also used : UpdateCmekSettingsRequest(com.google.logging.v2.UpdateCmekSettingsRequest) ConfigClient(com.google.cloud.logging.v2.ConfigClient) CmekSettings(com.google.logging.v2.CmekSettings)

Example 3 with UpdateCmekSettingsRequest

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

the class SyncUpdateCmekSettings method syncUpdateCmekSettings.

public static void syncUpdateCmekSettings() throws Exception {
    // It may require modifications to work in your environment.
    try (ConfigClient configClient = ConfigClient.create()) {
        UpdateCmekSettingsRequest request = UpdateCmekSettingsRequest.newBuilder().setName("name3373707").setCmekSettings(CmekSettings.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
        CmekSettings response = configClient.updateCmekSettings(request);
    }
}
Also used : UpdateCmekSettingsRequest(com.google.logging.v2.UpdateCmekSettingsRequest) ConfigClient(com.google.cloud.logging.v2.ConfigClient) CmekSettings(com.google.logging.v2.CmekSettings)

Example 4 with UpdateCmekSettingsRequest

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

the class ConfigClientTest method updateCmekSettingsTest.

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

Example 5 with UpdateCmekSettingsRequest

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

the class ConfigClientTest method updateCmekSettingsExceptionTest.

@Test
public void updateCmekSettingsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        UpdateCmekSettingsRequest request = UpdateCmekSettingsRequest.newBuilder().setName("name3373707").setCmekSettings(CmekSettings.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
        client.updateCmekSettings(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : UpdateCmekSettingsRequest(com.google.logging.v2.UpdateCmekSettingsRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

UpdateCmekSettingsRequest (com.google.logging.v2.UpdateCmekSettingsRequest)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