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();
}
}
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);
}
}
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);
}
}
}
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;
}
}
}
}
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);
}
}
Aggregations