Search in sources :

Example 21 with Bucket

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

the class SyncLockBucketRetentionPolicyBucketname method syncLockBucketRetentionPolicyBucketname.

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

Example 22 with Bucket

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

the class SyncLockBucketRetentionPolicyString method syncLockBucketRetentionPolicyString.

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

Example 23 with Bucket

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

the class AsyncRewriteObject method asyncRewriteObject.

public static void asyncRewriteObject() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        RewriteObjectRequest request = RewriteObjectRequest.newBuilder().setDestinationName("destinationName-1762755655").setDestinationBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString()).setDestinationKmsKey(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setDestination(Object.newBuilder().build()).setSourceBucket("sourceBucket841604581").setSourceObject("sourceObject1196439354").setSourceGeneration(1232209852).setRewriteToken("rewriteToken80654285").setDestinationPredefinedAcl(PredefinedObjectAcl.forNumber(0)).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setIfSourceGenerationMatch(-1427877280).setIfSourceGenerationNotMatch(1575612532).setIfSourceMetagenerationMatch(1143319909).setIfSourceMetagenerationNotMatch(1900822777).setMaxBytesRewrittenPerCall(1178170730).setCopySourceEncryptionAlgorithm("copySourceEncryptionAlgorithm-1524952548").setCopySourceEncryptionKeyBytes(ByteString.EMPTY).setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<RewriteResponse> future = storageClient.rewriteObjectCallable().futureCall(request);
        // Do something.
        RewriteResponse response = future.get();
    }
}
Also used : RewriteObjectRequest(com.google.storage.v2.RewriteObjectRequest) StorageClient(com.google.storage.v2.StorageClient) RewriteResponse(com.google.storage.v2.RewriteResponse)

Example 24 with Bucket

use of com.google.storage.v2.Bucket 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 25 with Bucket

use of com.google.storage.v2.Bucket 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

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