Skip to content

Commit

Permalink
feat: add support for archive storage class (#19)
Browse files Browse the repository at this point in the history
* feat: add support for archive storage class

* feat: fix review changes

* feat: fix review changes
  • Loading branch information
athakor authored and kolea2 committed Jan 6, 2020
1 parent a3727e9 commit a3fbd67
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 10 deletions.
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

0 comments on commit a3fbd67

Please sign in to comment.