Search in sources :

Example 6 with GetBucketRequest

use of com.google.storage.v2.GetBucketRequest in project gapic-generator-java by googleapis.

the class AsyncGetBucket method asyncGetBucket.

public static void asyncGetBucket() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetBucketRequest request = GetBucketRequest.newBuilder().setName(BucketName.of("[PROJECT]", "[BUCKET]").toString()).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonRequestParams(CommonRequestParams.newBuilder().build()).setReadMask(FieldMask.newBuilder().build()).build();
        ApiFuture<Bucket> future = storageClient.getBucketCallable().futureCall(request);
        // Do something.
        Bucket response = future.get();
    }
}
Also used : Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient) GetBucketRequest(com.google.storage.v2.GetBucketRequest)

Example 7 with GetBucketRequest

use of com.google.storage.v2.GetBucketRequest in project gapic-generator-java by googleapis.

the class SyncGetBucket method syncGetBucket.

public static void syncGetBucket() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetBucketRequest request = GetBucketRequest.newBuilder().setName(BucketName.of("[PROJECT]", "[BUCKET]").toString()).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonRequestParams(CommonRequestParams.newBuilder().build()).setReadMask(FieldMask.newBuilder().build()).build();
        Bucket response = storageClient.getBucket(request);
    }
}
Also used : Bucket(com.google.storage.v2.Bucket) StorageClient(com.google.storage.v2.StorageClient) GetBucketRequest(com.google.storage.v2.GetBucketRequest)

Aggregations

GetBucketRequest (com.google.logging.v2.GetBucketRequest)5 Test (org.junit.Test)4 LogBucket (com.google.logging.v2.LogBucket)3 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Bucket (com.google.storage.v2.Bucket)2 GetBucketRequest (com.google.storage.v2.GetBucketRequest)2 StorageClient (com.google.storage.v2.StorageClient)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 ConfigClient (com.google.cloud.logging.v2.ConfigClient)1