Skip to content

Commit a3fbd67

Browse files
athakorkolea2
authored andcommitted
feat: add support for archive storage class (#19)
* feat: add support for archive storage class * feat: fix review changes * feat: fix review changes
1 parent a3727e9 commit a3fbd67

File tree

2 files changed

+63
-10
lines changed

2 files changed

+63
-10
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/StorageClass.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,44 @@ public StorageClass apply(String constant) {
4141
private static final StringEnumType<StorageClass> type =
4242
new StringEnumType(StorageClass.class, CONSTRUCTOR);
4343

44-
/** Regional storage class. */
45-
public static final StorageClass REGIONAL = type.createAndRegister("REGIONAL");
46-
47-
/** Multi-regional storage class. */
48-
public static final StorageClass MULTI_REGIONAL = type.createAndRegister("MULTI_REGIONAL");
44+
/**
45+
* Standard storage class. See: https://cloud.google.com/storage/docs/storage-classes for details
46+
*/
47+
public static final StorageClass STANDARD = type.createAndRegister("STANDARD");
4948

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

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

56-
/** Standard storage class. */
57-
public static final StorageClass STANDARD = type.createAndRegister("STANDARD");
59+
/**
60+
* Archive storage class. See: https://cloud.google.com/storage/docs/storage-classes for details
61+
*/
62+
public static final StorageClass ARCHIVE = type.createAndRegister("ARCHIVE");
63+
64+
/**
65+
* Regional storage class. This is supported as a legacy storage class and will be deprecated in
66+
* the future. See: https://cloud.google.com/storage/docs/storage-classes for details
67+
*/
68+
public static final StorageClass REGIONAL = type.createAndRegister("REGIONAL");
5869

59-
/** Durable Reduced Availability (deprecated) */
70+
/**
71+
* Multi-regional storage class. This is supported as a legacy storage class and will be
72+
* deprecated in the future. See: https://cloud.google.com/storage/docs/storage-classes for
73+
* details
74+
*/
75+
public static final StorageClass MULTI_REGIONAL = type.createAndRegister("MULTI_REGIONAL");
76+
77+
/**
78+
* Durable Reduced Availability storage class. This is supported as a legacy storage class and
79+
* will be deprecated in the future. See: https://cloud.google.com/storage/docs/storage-classes
80+
* for details
81+
*/
6082
public static final StorageClass DURABLE_REDUCED_AVAILABILITY =
6183
type.createAndRegister("DURABLE_REDUCED_AVAILABILITY");
6284

google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public class BucketInfoTest {
8080
private static final String NOT_FOUND_PAGE = "error.html";
8181
private static final String LOCATION = "ASIA";
8282
private static final StorageClass STORAGE_CLASS = StorageClass.STANDARD;
83+
private static final StorageClass ARCHIVE_STORAGE_CLASS = StorageClass.ARCHIVE;
8384
private static final String DEFAULT_KMS_KEY_NAME =
8485
"projects/p/locations/kr-loc/keyRings/kr/cryptoKeys/key";
8586
private static final Boolean VERSIONING_ENABLED = true;
@@ -130,6 +131,35 @@ public class BucketInfoTest {
130131
.setRetentionPolicyIsLocked(RETENTION_POLICY_IS_LOCKED)
131132
.setLogging(LOGGING)
132133
.build();
134+
private static final BucketInfo BUCKET_INFO_ARCHIVE =
135+
BucketInfo.newBuilder("b")
136+
.setAcl(ACL)
137+
.setEtag(ETAG)
138+
.setGeneratedId(GENERATED_ID)
139+
.setMetageneration(META_GENERATION)
140+
.setOwner(OWNER)
141+
.setSelfLink(SELF_LINK)
142+
.setCors(CORS)
143+
.setCreateTime(CREATE_TIME)
144+
.setDefaultAcl(DEFAULT_ACL)
145+
.setDeleteRules(DELETE_RULES)
146+
.setLifecycleRules(LIFECYCLE_RULES)
147+
.setIndexPage(INDEX_PAGE)
148+
.setIamConfiguration(IAM_CONFIGURATION)
149+
.setNotFoundPage(NOT_FOUND_PAGE)
150+
.setLocation(LOCATION)
151+
.setLocationType(LOCATION_TYPE)
152+
.setStorageClass(ARCHIVE_STORAGE_CLASS)
153+
.setVersioningEnabled(VERSIONING_ENABLED)
154+
.setLabels(BUCKET_LABELS)
155+
.setRequesterPays(REQUESTER_PAYS)
156+
.setDefaultKmsKeyName(DEFAULT_KMS_KEY_NAME)
157+
.setDefaultEventBasedHold(DEFAULT_EVENT_BASED_HOLD)
158+
.setRetentionEffectiveTime(RETENTION_EFFECTIVE_TIME)
159+
.setRetentionPeriod(RETENTION_PERIOD)
160+
.setRetentionPolicyIsLocked(RETENTION_POLICY_IS_LOCKED)
161+
.setLogging(LOGGING)
162+
.build();
133163

134164
@Test
135165
public void testToBuilder() {
@@ -139,6 +169,7 @@ public void testToBuilder() {
139169
assertEquals("id", bucketInfo.getGeneratedId());
140170
bucketInfo = bucketInfo.toBuilder().setName("b").setGeneratedId(GENERATED_ID).build();
141171
compareBuckets(BUCKET_INFO, bucketInfo);
172+
assertEquals(ARCHIVE_STORAGE_CLASS, BUCKET_INFO_ARCHIVE.getStorageClass());
142173
}
143174

144175
@Test

0 commit comments

Comments
 (0)