use of com.google.storage.v2.UpdateBucketRequest in project gapic-generator-java by googleapis.
the class ConfigClientTest method updateBucketTest.
@Test
public void updateBucketTest() throws Exception {
LogBucket expectedResponse = LogBucket.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setRetentionDays(1544391896).setLocked(true).setLifecycleState(LifecycleState.forNumber(0)).build();
mockConfigServiceV2.addResponse(expectedResponse);
UpdateBucketRequest request = UpdateBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setBucket(LogBucket.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
LogBucket actualResponse = client.updateBucket(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateBucketRequest actualRequest = ((UpdateBucketRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertEquals(request.getBucket(), actualRequest.getBucket());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.UpdateBucketRequest in project gapic-generator-java by googleapis.
the class ConfigClientTest method updateBucketExceptionTest.
@Test
public void updateBucketExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
UpdateBucketRequest request = UpdateBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setBucket(LogBucket.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
client.updateBucket(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.storage.v2.UpdateBucketRequest in project gapic-generator-java by googleapis.
the class SyncUpdateBucket method syncUpdateBucket.
public static void syncUpdateBucket() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
UpdateBucketRequest request = UpdateBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setBucket(LogBucket.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
LogBucket response = configClient.updateBucket(request);
}
}
use of com.google.storage.v2.UpdateBucketRequest in project gapic-generator-java by googleapis.
the class AsyncUpdateBucket method asyncUpdateBucket.
public static void asyncUpdateBucket() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
UpdateBucketRequest request = UpdateBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setBucket(LogBucket.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
ApiFuture<LogBucket> future = configClient.updateBucketCallable().futureCall(request);
// Do something.
LogBucket response = future.get();
}
}
use of com.google.storage.v2.UpdateBucketRequest in project java-logging by googleapis.
the class ConfigClientTest method updateBucketTest.
@Test
public void updateBucketTest() throws Exception {
LogBucket expectedResponse = LogBucket.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setRetentionDays(1544391896).setLocked(true).setLifecycleState(LifecycleState.forNumber(0)).addAllRestrictedFields(new ArrayList<String>()).setCmekSettings(CmekSettings.newBuilder().build()).build();
mockConfigServiceV2.addResponse(expectedResponse);
UpdateBucketRequest request = UpdateBucketRequest.newBuilder().setName(LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]").toString()).setBucket(LogBucket.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();
LogBucket actualResponse = client.updateBucket(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateBucketRequest actualRequest = ((UpdateBucketRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertEquals(request.getBucket(), actualRequest.getBucket());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations