From 9bd620806dd7a2106738f4e710c8e534c9a43e14 Mon Sep 17 00:00:00 2001 From: BenWhitehead Date: Tue, 28 Sep 2021 10:05:47 -0400 Subject: [PATCH 1/2] fix: update PAP to use inherited instead of unspecified --- .../com/google/cloud/storage/BucketInfo.java | 25 +++++++++++++------ .../cloud/storage/it/ITStorageTest.java | 4 +-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java index 2bc3df390..6235a57ab 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java @@ -113,13 +113,18 @@ public com.google.api.services.storage.model.Bucket apply(BucketInfo bucketInfo) */ public enum PublicAccessPrevention { ENFORCED("enforced"), - /** Default value for Public Access Prevention */ - UNSPECIFIED("unspecified"), + /** + * Default value for Public Access Prevention + * @deprecated use {@link #INHERITED} + */ + @Deprecated + UNSPECIFIED("inherited"), /** * If the api returns a value that isn't defined in {@link PublicAccessPrevention} this value * will be returned. */ - UNKNOWN(null); + UNKNOWN(null), + INHERITED("inherited"); private final String value; @@ -133,10 +138,14 @@ public String getValue() { public static PublicAccessPrevention parse(String value) { String upper = value.toUpperCase(); - try { - return valueOf(upper); - } catch (IllegalArgumentException ignore) { - return UNKNOWN; + switch (upper) { + case "ENFORCED": + return ENFORCED; + case "UNSPECIFIED": + case "INHERITED": + return INHERITED; + default: + return UNKNOWN; } } } @@ -300,7 +309,7 @@ Builder setUniformBucketLevelAccessLockedTime(Long uniformBucketLevelAccessLocke /** * Sets the bucket's Public Access Prevention configuration. Currently supported options are - * {@link PublicAccessPrevention#UNSPECIFIED} or {@link PublicAccessPrevention#ENFORCED} + * {@link PublicAccessPrevention#INHERITED} or {@link PublicAccessPrevention#ENFORCED} * * @see public-access-prevention diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java index f8f51d386..73ef7e9b8 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java @@ -3296,7 +3296,7 @@ private Bucket generatePublicAccessPreventionBucket(String bucketName, boolean e .setPublicAccessPrevention( enforced ? BucketInfo.PublicAccessPrevention.ENFORCED - : BucketInfo.PublicAccessPrevention.UNSPECIFIED) + : BucketInfo.PublicAccessPrevention.INHERITED) .build()) .build()); } @@ -3389,7 +3389,7 @@ public void testUBLAWithPublicAccessPreventionOnBucket() throws Exception { Bucket bucket = generatePublicAccessPreventionBucket(papBucket, false); assertEquals( bucket.getIamConfiguration().getPublicAccessPrevention(), - BucketInfo.PublicAccessPrevention.UNSPECIFIED); + BucketInfo.PublicAccessPrevention.INHERITED); assertFalse(bucket.getIamConfiguration().isUniformBucketLevelAccessEnabled()); assertFalse(bucket.getIamConfiguration().isBucketPolicyOnlyEnabled()); From 53c7ce264a3aa6b4d4683ead5c2cb6779229ce14 Mon Sep 17 00:00:00 2001 From: BenWhitehead Date: Tue, 28 Sep 2021 10:07:18 -0400 Subject: [PATCH 2/2] chore: format --- .../src/main/java/com/google/cloud/storage/BucketInfo.java | 1 + 1 file changed, 1 insertion(+) diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java index 6235a57ab..83a836f78 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java @@ -115,6 +115,7 @@ public enum PublicAccessPrevention { ENFORCED("enforced"), /** * Default value for Public Access Prevention + * * @deprecated use {@link #INHERITED} */ @Deprecated