Search in sources :

Example 6 with UpdateBucketRequest

use of com.google.storage.v2.UpdateBucketRequest in project java-logging 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.
    }
}
Also used : UpdateBucketRequest(com.google.logging.v2.UpdateBucketRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 7 with UpdateBucketRequest

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 (StorageClient storageClient = StorageClient.create()) {
        UpdateBucketRequest request = UpdateBucketRequest.newBuilder().setBucket(Bucket.newBuilder().build()).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setPredefinedAcl(PredefinedBucketAcl.forNumber(0)).setPredefinedDefaultObjectAcl(PredefinedObjectAcl.forNumber(0)).setUpdateMask(FieldMask.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<Bucket> future = storageClient.updateBucketCallable().futureCall(request);
        // Do something.
        Bucket response = future.get();
    }
}
Also used : UpdateBucketRequest(com.google.storage.v2.UpdateBucketRequest) Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient)

Example 8 with UpdateBucketRequest

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 (StorageClient storageClient = StorageClient.create()) {
        UpdateBucketRequest request = UpdateBucketRequest.newBuilder().setBucket(Bucket.newBuilder().build()).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setPredefinedAcl(PredefinedBucketAcl.forNumber(0)).setPredefinedDefaultObjectAcl(PredefinedObjectAcl.forNumber(0)).setUpdateMask(FieldMask.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        Bucket response = storageClient.updateBucket(request);
    }
}
Also used : UpdateBucketRequest(com.google.storage.v2.UpdateBucketRequest) Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient)

Aggregations

UpdateBucketRequest (com.google.logging.v2.UpdateBucketRequest)6 LogBucket (com.google.logging.v2.LogBucket)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 Bucket (com.google.storage.v2.Bucket)2 StorageClient (com.google.storage.v2.StorageClient)2 UpdateBucketRequest (com.google.storage.v2.UpdateBucketRequest)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2