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

feat: add support for archive storage class #19

Merged
merged 3 commits into from Jan 6, 2020
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 @@ -41,22 +41,44 @@ public StorageClass apply(String constant) {
private static final StringEnumType<StorageClass> type =
new StringEnumType(StorageClass.class, CONSTRUCTOR);

/** Regional storage class. */
public static final StorageClass REGIONAL = type.createAndRegister("REGIONAL");

/** Multi-regional storage class. */
public static final StorageClass MULTI_REGIONAL = type.createAndRegister("MULTI_REGIONAL");
/**
* Standard storage class. See: https://cloud.google.com/storage/docs/storage-classes for details
*/
public static final StorageClass STANDARD = type.createAndRegister("STANDARD");

/** Nearline storage class. */
/**
* Nearline storage class. See: https://cloud.google.com/storage/docs/storage-classes for details
*/
public static final StorageClass NEARLINE = type.createAndRegister("NEARLINE");

/** Coldline storage class. */
/**
* Coldline storage class. See: https://cloud.google.com/storage/docs/storage-classes for details
*/
public static final StorageClass COLDLINE = type.createAndRegister("COLDLINE");

/** Standard storage class. */
public static final StorageClass STANDARD = type.createAndRegister("STANDARD");
/**
* Archive storage class. See: https://cloud.google.com/storage/docs/storage-classes for details
*/
public static final StorageClass ARCHIVE = type.createAndRegister("ARCHIVE");

/**
* Regional storage class. This is supported as a legacy storage class and will be deprecated in
* the future. See: https://cloud.google.com/storage/docs/storage-classes for details
*/
public static final StorageClass REGIONAL = type.createAndRegister("REGIONAL");

/** Durable Reduced Availability (deprecated) */
/**
* Multi-regional storage class. This is supported as a legacy storage class and will be
* deprecated in the future. See: https://cloud.google.com/storage/docs/storage-classes for
* details
*/
public static final StorageClass MULTI_REGIONAL = type.createAndRegister("MULTI_REGIONAL");

/**
* Durable Reduced Availability storage class. This is supported as a legacy storage class and
* will be deprecated in the future. See: https://cloud.google.com/storage/docs/storage-classes
* for details
*/
public static final StorageClass DURABLE_REDUCED_AVAILABILITY =
type.createAndRegister("DURABLE_REDUCED_AVAILABILITY");

Expand Down
Expand Up @@ -80,6 +80,7 @@ public class BucketInfoTest {
private static final String NOT_FOUND_PAGE = "error.html";
private static final String LOCATION = "ASIA";
private static final StorageClass STORAGE_CLASS = StorageClass.STANDARD;
private static final StorageClass ARCHIVE_STORAGE_CLASS = StorageClass.ARCHIVE;
private static final String DEFAULT_KMS_KEY_NAME =
"projects/p/locations/kr-loc/keyRings/kr/cryptoKeys/key";
private static final Boolean VERSIONING_ENABLED = true;
Expand Down Expand Up @@ -130,6 +131,35 @@ public class BucketInfoTest {
.setRetentionPolicyIsLocked(RETENTION_POLICY_IS_LOCKED)
.setLogging(LOGGING)
.build();
private static final BucketInfo BUCKET_INFO_ARCHIVE =
BucketInfo.newBuilder("b")
.setAcl(ACL)
.setEtag(ETAG)
.setGeneratedId(GENERATED_ID)
.setMetageneration(META_GENERATION)
.setOwner(OWNER)
.setSelfLink(SELF_LINK)
.setCors(CORS)
.setCreateTime(CREATE_TIME)
.setDefaultAcl(DEFAULT_ACL)
.setDeleteRules(DELETE_RULES)
.setLifecycleRules(LIFECYCLE_RULES)
.setIndexPage(INDEX_PAGE)
.setIamConfiguration(IAM_CONFIGURATION)
.setNotFoundPage(NOT_FOUND_PAGE)
.setLocation(LOCATION)
.setLocationType(LOCATION_TYPE)
.setStorageClass(ARCHIVE_STORAGE_CLASS)
.setVersioningEnabled(VERSIONING_ENABLED)
.setLabels(BUCKET_LABELS)
.setRequesterPays(REQUESTER_PAYS)
.setDefaultKmsKeyName(DEFAULT_KMS_KEY_NAME)
.setDefaultEventBasedHold(DEFAULT_EVENT_BASED_HOLD)
.setRetentionEffectiveTime(RETENTION_EFFECTIVE_TIME)
.setRetentionPeriod(RETENTION_PERIOD)
.setRetentionPolicyIsLocked(RETENTION_POLICY_IS_LOCKED)
.setLogging(LOGGING)
.build();

@Test
public void testToBuilder() {
Expand All @@ -139,6 +169,7 @@ public void testToBuilder() {
assertEquals("id", bucketInfo.getGeneratedId());
bucketInfo = bucketInfo.toBuilder().setName("b").setGeneratedId(GENERATED_ID).build();
compareBuckets(BUCKET_INFO, bucketInfo);
assertEquals(ARCHIVE_STORAGE_CLASS, BUCKET_INFO_ARCHIVE.getStorageClass());
}

@Test
Expand Down