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
feat: Add RPO metadata settings #1105
Changes from 1 commit
f3c40da
6827362
1edd216
3861b37
fcb757d
ce47c97
5ea4e8b
38d38e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.storage; | ||
|
||
import com.google.api.core.ApiFunction; | ||
import com.google.cloud.StringEnumType; | ||
import com.google.cloud.StringEnumValue; | ||
|
||
public class Rpo extends StringEnumValue { | ||
JesseLovelace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private Rpo(String constant) { | ||
super(constant); | ||
} | ||
|
||
private static final ApiFunction<String, Rpo> CONSTRUCTOR = Rpo::new; | ||
|
||
private static final StringEnumType<Rpo> type = new StringEnumType(Rpo.class, CONSTRUCTOR); | ||
JesseLovelace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static final Rpo DEFAULT = type.createAndRegister("DEFAULT"); | ||
|
||
public static final Rpo ASYNC_TURBO = type.createAndRegister("ASYNC_TURBO"); | ||
|
||
/** | ||
* Get the Rpo for the given String constant, and throw an exception if the constant is not | ||
* recognized. | ||
*/ | ||
public static Rpo valueOfStrict(String constant) { | ||
return type.valueOfStrict(constant); | ||
} | ||
|
||
/** Get the Rpo for the given String constant, and allow unrecognized values. */ | ||
public static Rpo valueOf(String constant) { | ||
return type.valueOf(constant); | ||
} | ||
|
||
/** Return the known values for Rpo. */ | ||
public static Rpo[] values() { | ||
return type.values(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,34 +54,16 @@ | |
import com.google.cloud.kms.v1.KeyManagementServiceGrpc.KeyManagementServiceBlockingStub; | ||
import com.google.cloud.kms.v1.KeyRingName; | ||
import com.google.cloud.kms.v1.LocationName; | ||
import com.google.cloud.storage.Acl; | ||
import com.google.cloud.storage.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. intellij does this automatically and i can't figure out how to turn it off it's infuriating 😭 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import com.google.cloud.storage.Acl.Role; | ||
import com.google.cloud.storage.Acl.User; | ||
import com.google.cloud.storage.Blob; | ||
import com.google.cloud.storage.BlobId; | ||
import com.google.cloud.storage.BlobInfo; | ||
import com.google.cloud.storage.Bucket; | ||
import com.google.cloud.storage.BucketInfo; | ||
import com.google.cloud.storage.BucketInfo.LifecycleRule; | ||
import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction; | ||
import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleCondition; | ||
import com.google.cloud.storage.CopyWriter; | ||
import com.google.cloud.storage.Cors; | ||
import com.google.cloud.storage.HmacKey; | ||
import com.google.cloud.storage.HttpMethod; | ||
import com.google.cloud.storage.PostPolicyV4; | ||
import com.google.cloud.storage.PostPolicyV4.PostFieldsV4; | ||
import com.google.cloud.storage.ServiceAccount; | ||
import com.google.cloud.storage.Storage; | ||
import com.google.cloud.storage.Storage.BlobField; | ||
import com.google.cloud.storage.Storage.BlobWriteOption; | ||
import com.google.cloud.storage.Storage.BucketField; | ||
import com.google.cloud.storage.StorageBatch; | ||
import com.google.cloud.storage.StorageBatchResult; | ||
import com.google.cloud.storage.StorageClass; | ||
import com.google.cloud.storage.StorageException; | ||
import com.google.cloud.storage.StorageOptions; | ||
import com.google.cloud.storage.StorageRoles; | ||
import com.google.cloud.storage.spi.StorageRpcFactory; | ||
import com.google.cloud.storage.spi.v1.StorageRpc; | ||
import com.google.cloud.storage.spi.v1.StorageRpc.Option; | ||
|
@@ -3940,6 +3922,25 @@ protected Object handleInvocation( | |
assertArrayEquals(randStringBytes, actualData.toByteArray()); | ||
} | ||
|
||
@Test | ||
public void testRpoConfig() { | ||
String rpoBucket = RemoteStorageHelper.generateBucketName(); | ||
try { | ||
Bucket bucket = storage.create( | ||
BucketInfo.newBuilder(rpoBucket) | ||
.setLocation("NAM4") | ||
.setRpo(Rpo.ASYNC_TURBO) | ||
.build()); | ||
assertEquals("ASYNC_TURBO", bucket.getRpo().toString()); | ||
|
||
bucket.toBuilder().setRpo(Rpo.DEFAULT).build().update(); | ||
|
||
assertEquals("DEFAULT", storage.get(rpoBucket).getRpo().toString()); | ||
} finally { | ||
storage.delete(rpoBucket); | ||
} | ||
} | ||
|
||
private static String randString(Random rand, int length) { | ||
final StringBuilder sb = new StringBuilder(); | ||
while (sb.length() < length) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenWhitehead we hit this each time we make a change to a public interface, we've been told it's to protect us from breaking changes, however we are committing breaking changes. It has gone on for years. What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clirr is in place to primarily help us know if we are committing a change that breaks binary compatibility. The place it's most beneficial is on our generated code and our "main" apis. In this case, it's less beneficial and unfortunately BucketInfo.Builder is abstract and not annotated with
@InternalExtensionOnly
which would give us leeway to add methods with no guarantee of binary compatibility for out of project implementations. However, adding this annotation is itself considered a breaking change and would need to be performed at a major version.Our policy for model classes in general has been that we consider them to generally be safe for adding new methods, unfortunately clirr isn't capable of being made aware that this is a model class and instead requires an entry defined. Unfortunately, at this point, I think we're sort of stuck having to deal with this file until either we reach a new major version when we can annotate this builder and define a general rule or we decide to refactor things and make this class not be abstract and instead simply non-final.