Search in sources :

Example 6 with Bucket

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

the class AsyncGetObject method asyncGetObject.

public static void asyncGetObject() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetObjectRequest request = GetObjectRequest.newBuilder().setBucket("bucket-1378203158").setObject("object-1023368385").setGeneration(305703192).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).setReadMask(FieldMask.newBuilder().build()).build();
        ApiFuture<Object> future = storageClient.getObjectCallable().futureCall(request);
        // Do something.
        Object response = future.get();
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object) GetObjectRequest(com.google.storage.v2.GetObjectRequest)

Example 7 with Bucket

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

the class SyncGetObjectStringStringLong method syncGetObjectStringStringLong.

public static void syncGetObjectStringStringLong() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        String bucket = "bucket-1378203158";
        String object = "object-1023368385";
        long generation = 305703192;
        Object response = storageClient.getObject(bucket, object, generation);
    }
}
Also used : StorageClient(com.google.storage.v2.StorageClient) Object(com.google.storage.v2.Object)

Example 8 with Bucket

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

the class AsyncListBuckets method asyncListBuckets.

public static void asyncListBuckets() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ListBucketsRequest request = ListBucketsRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setPrefix("prefix-980110702").setReadMask(FieldMask.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<Bucket> future = storageClient.listBucketsPagedCallable().futureCall(request);
        // Do something.
        for (Bucket element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : Bucket(com.google.storage.v2.Bucket) ListBucketsRequest(com.google.storage.v2.ListBucketsRequest) StorageClient(com.google.storage.v2.StorageClient)

Example 9 with Bucket

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

the class AsyncListBucketsPaged method asyncListBucketsPaged.

public static void asyncListBucketsPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ListBucketsRequest request = ListBucketsRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setPrefix("prefix-980110702").setReadMask(FieldMask.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        while (true) {
            ListBucketsResponse response = storageClient.listBucketsCallable().call(request);
            for (Bucket element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : ListBucketsResponse(com.google.storage.v2.ListBucketsResponse) Bucket(com.google.storage.v2.Bucket) ListBucketsRequest(com.google.storage.v2.ListBucketsRequest) StorageClient(com.google.storage.v2.StorageClient)

Example 10 with Bucket

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

the class SyncDeleteBucketBucketname method syncDeleteBucketBucketname.

public static void syncDeleteBucketBucketname() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        BucketName name = BucketName.of("[PROJECT]", "[BUCKET]");
        storageClient.deleteBucket(name);
    }
}
Also used : BucketName(com.google.storage.v2.BucketName) StorageClient(com.google.storage.v2.StorageClient)

Aggregations

StorageClient (com.google.storage.v2.StorageClient)39 Bucket (com.google.storage.v2.Bucket)17 AbstractMessage (com.google.protobuf.AbstractMessage)4 BucketName (com.google.storage.v2.BucketName)4 Notification (com.google.storage.v2.Notification)4 Object (com.google.storage.v2.Object)4 ListBucketsPagedResponse (com.google.storage.v2.StorageClient.ListBucketsPagedResponse)4 Test (org.junit.Test)4 Empty (com.google.protobuf.Empty)3 ByteString (com.google.protobuf.ByteString)2 CreateBucketRequest (com.google.storage.v2.CreateBucketRequest)2 DeleteNotificationRequest (com.google.storage.v2.DeleteNotificationRequest)2 DeleteObjectRequest (com.google.storage.v2.DeleteObjectRequest)2 GetBucketRequest (com.google.storage.v2.GetBucketRequest)2 GetNotificationRequest (com.google.storage.v2.GetNotificationRequest)2 GetObjectRequest (com.google.storage.v2.GetObjectRequest)2 ListBucketsRequest (com.google.storage.v2.ListBucketsRequest)2 LockBucketRetentionPolicyRequest (com.google.storage.v2.LockBucketRetentionPolicyRequest)2 RewriteObjectRequest (com.google.storage.v2.RewriteObjectRequest)2 RewriteResponse (com.google.storage.v2.RewriteResponse)2