Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update PAP to use inherited instead of unspecified #1051

Merged
merged 2 commits into from Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -113,13 +113,19 @@ 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"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shaffeeullah will the service still support unspecified to continue supporting clients that are released?

/**
* 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;

Expand All @@ -133,10 +139,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;
}
}
}
Expand Down Expand Up @@ -300,7 +310,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 <a
* href="https://cloud.google.com/storage/docs/public-access-prevention">public-access-prevention</a>
Expand Down
Expand Up @@ -3296,7 +3296,7 @@ private Bucket generatePublicAccessPreventionBucket(String bucketName, boolean e
.setPublicAccessPrevention(
enforced
? BucketInfo.PublicAccessPrevention.ENFORCED
: BucketInfo.PublicAccessPrevention.UNSPECIFIED)
: BucketInfo.PublicAccessPrevention.INHERITED)
.build())
.build());
}
Expand Down Expand Up @@ -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());

Expand Down