use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.
the class AsyncCreateHmacKey method asyncCreateHmacKey.
public static void asyncCreateHmacKey() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
CreateHmacKeyRequest request = CreateHmacKeyRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setServiceAccountEmail("serviceAccountEmail1825953988").setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
ApiFuture<CreateHmacKeyResponse> future = storageClient.createHmacKeyCallable().futureCall(request);
// Do something.
CreateHmacKeyResponse response = future.get();
}
}
use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.
the class AsyncLockBucketRetentionPolicy method asyncLockBucketRetentionPolicy.
public static void asyncLockBucketRetentionPolicy() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
LockBucketRetentionPolicyRequest request = LockBucketRetentionPolicyRequest.newBuilder().setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString()).setIfMetagenerationMatch(1043427781).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
ApiFuture<Bucket> future = storageClient.lockBucketRetentionPolicyCallable().futureCall(request);
// Do something.
Bucket response = future.get();
}
}
use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.
the class AsyncListHmacKeysPaged method asyncListHmacKeysPaged.
public static void asyncListHmacKeysPaged() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
ListHmacKeysRequest request = ListHmacKeysRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setServiceAccountEmail("serviceAccountEmail1825953988").setShowDeletedKeys(true).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
while (true) {
ListHmacKeysResponse response = storageClient.listHmacKeysCallable().call(request);
for (HmacKeyMetadata 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.StorageClient in project gapic-generator-java by googleapis.
the class AsyncComposeObject method asyncComposeObject.
public static void asyncComposeObject() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
ComposeObjectRequest request = ComposeObjectRequest.newBuilder().setDestination(Object.newBuilder().build()).addAllSourceObjects(new ArrayList<ComposeObjectRequest.SourceObject>()).setDestinationPredefinedAcl(PredefinedObjectAcl.forNumber(0)).setIfGenerationMatch(-1086241088).setIfMetagenerationMatch(1043427781).setKmsKey(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
ApiFuture<Object> future = storageClient.composeObjectCallable().futureCall(request);
// Do something.
Object response = future.get();
}
}
use of com.google.storage.v2.StorageClient in project gapic-generator-java by googleapis.
the class SyncCreateSetCredentialsProvider method syncCreateSetCredentialsProvider.
public static void syncCreateSetCredentialsProvider() throws Exception {
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
StorageSettings storageSettings = StorageSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();
StorageClient storageClient = StorageClient.create(storageSettings);
}
Aggregations