Skip to content

Commit

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

* classify and sort storage classes appropriately

Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
Co-authored-by: Jonathan Lui <jonathanlui@google.com>
  • Loading branch information
4 people committed Jan 2, 2020
1 parent 26ab4e3 commit 63f63f4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2902,9 +2902,10 @@ class Bucket extends ServiceObject {
* @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes}
*
* @param {string} storageClass The new storage class. (`standard`,
* `nearline`, `coldline`, or `durable_reduced_availability`).
* **Note:** The storage classes `multi_regional` and `regional`
* are now legacy and will be deprecated in the future.
* `nearline`, `coldline`, or `archive`).
* **Note:** The storage classes `multi_regional`, `regional`, and
* `durable_reduced_availability` are now legacy and will be deprecated in
* the future.
* @param {object} [options] Configuration options.
* @param {string} [options.userProject] - The ID of the project which will be
* billed for the request.
Expand Down
2 changes: 1 addition & 1 deletion src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3245,7 +3245,7 @@ class File extends ServiceObject<File> {
* @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes}
*
* @param {string} storageClass The new storage class. (`standard`,
* `nearline`, or `coldline`)
* `nearline`, `coldline`, or `archive`)
* **Note:** The storage classes `multi_regional` and `regional`
* are now legacy and will be deprecated in the future.
* @param {SetStorageClassOptions} [options] Configuration options.
Expand Down
3 changes: 3 additions & 0 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface BucketOptions {
}

export interface CreateBucketRequest {
archive?: boolean;
coldline?: boolean;
dra?: boolean;
multiRegional?: boolean;
Expand Down Expand Up @@ -474,6 +475,7 @@ export class Storage extends Service {
* Metadata to set for the bucket.
*
* @typedef {object} CreateBucketRequest
* @property {boolean} [archive=false] Specify the storage class as Archive.
* @property {boolean} [coldline=false] Specify the storage class as Coldline.
* @property {boolean} [dra=false] Specify the storage class as Durable Reduced
* Availability.
Expand Down Expand Up @@ -585,6 +587,7 @@ export class Storage extends Service {
};

const storageClasses = {
archive: 'ARCHIVE',
coldline: 'COLDLINE',
dra: 'DURABLE_REDUCED_AVAILABILITY',
multiRegional: 'MULTI_REGIONAL',
Expand Down
9 changes: 9 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,15 @@ describe('Storage', () => {
});

describe('storage classes', () => {
it('should expand metadata.archive', done => {
storage.request = (reqOpts: DecorateRequestOptions) => {
assert.strictEqual(reqOpts.json.storageClass, 'ARCHIVE');
done();
};

storage.createBucket(BUCKET_NAME, {archive: true}, assert.ifError);
});

it('should expand metadata.coldline', done => {
storage.request = (reqOpts: DecorateRequestOptions) => {
assert.strictEqual(reqOpts.json.storageClass, 'COLDLINE');
Expand Down

0 comments on commit 63f63f4

Please sign in to comment.