diff --git a/README.md b/README.md index 81cbf31e28..aa1fe0e7ab 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-storage/tree/ | Enable Lifecycle Management | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/EnableLifecycleManagement.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/EnableLifecycleManagement.java) | | Enable Requester Pays | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/EnableRequesterPays.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/EnableRequesterPays.java) | | Enable Uniform Bucket Level Access | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/EnableUniformBucketLevelAccess.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/EnableUniformBucketLevelAccess.java) | +| Get Bucket Autoclass | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/GetBucketAutoclass.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/GetBucketAutoclass.java) | | Get Bucket Metadata | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/GetBucketMetadata.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/GetBucketMetadata.java) | | Get Bucket Rpo | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/GetBucketRpo.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/GetBucketRpo.java) | | Get Default Event Based Hold | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/GetDefaultEventBasedHold.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/GetDefaultEventBasedHold.java) | @@ -271,6 +272,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-storage/tree/ | Remove Bucket Owner | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketOwner.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/RemoveBucketOwner.java) | | Remove Retention Policy | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/RemoveRetentionPolicy.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/RemoveRetentionPolicy.java) | | Set Async Turbo Rpo | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/SetAsyncTurboRpo.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/SetAsyncTurboRpo.java) | +| Set Bucket Autoclass | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/SetBucketAutoclass.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/SetBucketAutoclass.java) | | Set Bucket Default Kms Key | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/SetBucketDefaultKmsKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/SetBucketDefaultKmsKey.java) | | Set Bucket Website Info | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/SetBucketWebsiteInfo.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/SetBucketWebsiteInfo.java) | | Set Client Endpoint | [source code](https://github.com/googleapis/java-storage/blob/main/samples/snippets/src/main/java/com/example/storage/bucket/SetClientEndpoint.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-storage&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/storage/bucket/SetClientEndpoint.java) | diff --git a/samples/snippets/src/main/java/com/example/storage/bucket/GetBucketAutoclass.java b/samples/snippets/src/main/java/com/example/storage/bucket/GetBucketAutoclass.java index b413541c8b..d01e0b3936 100644 --- a/samples/snippets/src/main/java/com/example/storage/bucket/GetBucketAutoclass.java +++ b/samples/snippets/src/main/java/com/example/storage/bucket/GetBucketAutoclass.java @@ -35,8 +35,13 @@ public static void getBucketAutoclass(String projectId, String bucketName) { String status = autoclass.getEnabled() ? "enabled" : "disabled"; String toggleTime = autoclass.getToggleTime().toString(); - System.out.println("Autoclass is currently " + status + " for bucket " + bucketName - + " and was last changed at " + toggleTime); + System.out.println( + "Autoclass is currently " + + status + + " for bucket " + + bucketName + + " and was last changed at " + + toggleTime); } } // [END storage_get_autoclass] diff --git a/samples/snippets/src/main/java/com/example/storage/bucket/SetBucketAutoclass.java b/samples/snippets/src/main/java/com/example/storage/bucket/SetBucketAutoclass.java index ec6ea42040..f59e383af5 100644 --- a/samples/snippets/src/main/java/com/example/storage/bucket/SetBucketAutoclass.java +++ b/samples/snippets/src/main/java/com/example/storage/bucket/SetBucketAutoclass.java @@ -39,15 +39,14 @@ public static void setBucketAutoclass(String projectId, String bucketName) { Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService(); Bucket bucket = storage.get(bucketName); - bucket.toBuilder() - .setAutoclass(Autoclass.newBuilder() - .setEnabled(enabled) - .build()) + bucket + .toBuilder() + .setAutoclass(Autoclass.newBuilder().setEnabled(enabled).build()) .build() .update(); - System.out.println("Autoclass for bucket " + bucketName + " was " - + (enabled ? "enabled." : "disabled.")); + System.out.println( + "Autoclass for bucket " + bucketName + " was " + (enabled ? "enabled." : "disabled.")); } } // [END storage_set_autoclass] diff --git a/samples/snippets/src/test/java/com/example/storage/bucket/AutoclassTest.java b/samples/snippets/src/test/java/com/example/storage/bucket/AutoclassTest.java index 9ccda14ddb..beb0dea6d8 100644 --- a/samples/snippets/src/test/java/com/example/storage/bucket/AutoclassTest.java +++ b/samples/snippets/src/test/java/com/example/storage/bucket/AutoclassTest.java @@ -32,9 +32,10 @@ public class AutoclassTest extends TestBase { @Test public void testSetGetBucketAutoclass() { String autoclassBucket = RemoteStorageHelper.generateBucketName(); - storage.create(BucketInfo.newBuilder(autoclassBucket) - .setAutoclass(Autoclass.newBuilder().setEnabled(true).build()) - .build()); + storage.create( + BucketInfo.newBuilder(autoclassBucket) + .setAutoclass(Autoclass.newBuilder().setEnabled(true).build()) + .build()); try { SetBucketAutoclass.setBucketAutoclass(PROJECT_ID, autoclassBucket); Autoclass autoclass = storage.get(autoclassBucket).getAutoclass();