diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/StorageSnippets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/StorageSnippets.java index b1c17ca75957..b82184df6721 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/StorageSnippets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/snippets/StorageSnippets.java @@ -1538,9 +1538,8 @@ public Bucket enableBucketPolicyOnly(String bucketName) throws StorageException // The name of a bucket, e.g. "my-bucket" // String bucketName = "my-bucket"; - BucketInfo.BucketPolicyOnly bucketPolicyOnly = BucketInfo.BucketPolicyOnly.newBuilder().setEnabled(true).build(); - BucketInfo.IamConfiguration iamConfiguration = BucketInfo.IamConfiguration.newBuilder().setBucketPolicyOnly( - bucketPolicyOnly).build(); + BucketInfo.IamConfiguration iamConfiguration = BucketInfo.IamConfiguration.newBuilder().setIsBucketPolicyOnlyEnabled( + true).build(); Bucket bucket = storage.update(BucketInfo.newBuilder(bucketName).setIamConfiguration(iamConfiguration).build()); @@ -1560,9 +1559,8 @@ public Bucket disableBucketPolicyOnly(String bucketName) throws StorageException // The name of a bucket, e.g. "my-bucket" // String bucketName = "my-bucket"; - BucketInfo.BucketPolicyOnly bucketPolicyOnly = BucketInfo.BucketPolicyOnly.newBuilder().setEnabled(false).build(); - BucketInfo.IamConfiguration iamConfiguration = BucketInfo.IamConfiguration.newBuilder().setBucketPolicyOnly( - bucketPolicyOnly).build(); + BucketInfo.IamConfiguration iamConfiguration = BucketInfo.IamConfiguration.newBuilder().setIsBucketPolicyOnlyEnabled( + false).build(); Bucket bucket = storage.update(BucketInfo.newBuilder(bucketName).setIamConfiguration(iamConfiguration).build()); @@ -1585,8 +1583,8 @@ public Bucket getBucketPolicyOnly(String bucketName) throws StorageException { Bucket bucket = storage.get(bucketName, BucketGetOption.fields(BucketField.IAMCONFIGURATION)); BucketInfo.IamConfiguration iamConfiguration = bucket.getIamConfiguration(); - Boolean enabled = iamConfiguration.getBucketPolicyOnly().getEnabled(); - Date lockedTime = new Date(iamConfiguration.getBucketPolicyOnly().getLockedTime().getValue()); + Boolean enabled = iamConfiguration.isBucketPolicyOnlyEnabled(); + Date lockedTime = new Date(iamConfiguration.getBucketPolicyOnlyLockedTime()); if (enabled != null && enabled) { System.out.println("Bucket Policy Only is enabled for " + bucketName); diff --git a/google-cloud-examples/src/test/java/com/google/cloud/examples/storage/snippets/ITStorageSnippets.java b/google-cloud-examples/src/test/java/com/google/cloud/examples/storage/snippets/ITStorageSnippets.java index 9d8b2b2c10b5..fe618755d5cd 100644 --- a/google-cloud-examples/src/test/java/com/google/cloud/examples/storage/snippets/ITStorageSnippets.java +++ b/google-cloud-examples/src/test/java/com/google/cloud/examples/storage/snippets/ITStorageSnippets.java @@ -553,12 +553,12 @@ public void testBucketPolicyOnly() { Bucket bucket = storageSnippets.createBucket(tempBucket); assertNotNull(bucket); bucket = storageSnippets.enableBucketPolicyOnly(tempBucket); - assertTrue(bucket.getIamConfiguration().getBucketPolicyOnly().getEnabled()); - assertNotNull(bucket.getIamConfiguration().getBucketPolicyOnly().getLockedTime()); + assertTrue(bucket.getIamConfiguration().isBucketPolicyOnlyEnabled()); + assertNotNull(bucket.getIamConfiguration().getBucketPolicyOnlyLockedTime()); bucket = storageSnippets.getBucketPolicyOnly(tempBucket); - assertTrue(bucket.getIamConfiguration().getBucketPolicyOnly().getEnabled()); - assertNotNull(bucket.getIamConfiguration().getBucketPolicyOnly().getLockedTime()); + assertTrue(bucket.getIamConfiguration().isBucketPolicyOnlyEnabled()); + assertNotNull(bucket.getIamConfiguration().getBucketPolicyOnlyLockedTime()); bucket = storageSnippets.disableBucketPolicyOnly(tempBucket); - assertFalse(bucket.getIamConfiguration().getBucketPolicyOnly().getEnabled()); + assertFalse(bucket.getIamConfiguration().isBucketPolicyOnlyEnabled()); } }