From f9d4e350dfb7fe5384eed7fbf9e71f7e10b0e032 Mon Sep 17 00:00:00 2001 From: y33zhang Date: Wed, 19 Oct 2016 12:18:10 -0700 Subject: [PATCH] storage class update for GCS storage class update for GCS --- packages/storage/src/index.js | 19 +++++++++++++------ packages/storage/test/index.js | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/packages/storage/src/index.js b/packages/storage/src/index.js index d59e22a3f303..ef4d06f600d1 100644 --- a/packages/storage/src/index.js +++ b/packages/storage/src/index.js @@ -187,18 +187,22 @@ Storage.prototype.channel = function(id, resourceId) { * [Bucket Naming Guidelines](https://cloud.google.com/storage/docs/bucketnaming.html#requirements). * * @resource [Buckets: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/insert} - * @resource [Durable Reduced Availability]{@link https://cloud.google.com/storage/docs/durable-reduced-availability} - * @resource [Nearline]{@link https://cloud.google.com/storage/docs/nearline} * @resource [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes} * * @throws {Error} If a name is not provided. * * @param {string} name - Name of the bucket to create. * @param {object=} metadata - Metadata to set for the bucket. + * @param {boolean=} metadata.multi_regional - Specify the storage class as + * Multi-Regional. + * @param {boolean=} metadata.regional - Specify the storage class as + * Regional. * @param {boolean=} metadata.dra - Specify the storage class as - * [Durable Reduced Availability](https://goo.gl/26lthK). + * Durable Reduced Availability. * @param {boolean=} metadata.nearline - Specify the storage class as - * [Nearline](https://goo.gl/sN5wNh). + * Nearline. + * @param {boolean=} metadata.coldline - Specify the storage class as + * Coldline. * @param {function} callback - The callback function. * @param {?error} callback.err - An error returned while making this request * @param {module:storage/bucket} callback.bucket - The newly created Bucket. @@ -219,7 +223,7 @@ Storage.prototype.channel = function(id, resourceId) { * //- * var metadata = { * location: 'US-CENTRAL1', - * dra: true + * regional: true * }; * * gcs.createBucket('new-bucket', metadata, callback); @@ -261,7 +265,10 @@ Storage.prototype.createBucket = function(name, metadata, callback) { var storageClasses = { dra: 'DURABLE_REDUCED_AVAILABILITY', - nearline: 'NEARLINE' + nearline: 'NEARLINE', + coldline: 'COLDLINE', + multi_regional: 'MULTI_REGIONAL', + regional: 'REGIONAL' }; Object.keys(storageClasses).forEach(function(storageClass) { diff --git a/packages/storage/test/index.js b/packages/storage/test/index.js index 33855e62cbcc..361d700a3e16 100644 --- a/packages/storage/test/index.js +++ b/packages/storage/test/index.js @@ -246,6 +246,30 @@ describe('Storage', function() { }); }); + it('should expand the Multi Regional option', function(done) { + storage.request = function(reqOpts) { + assert.strictEqual(reqOpts.json.storageClass, 'MULTI_REGIONAL'); + done(); + }; + storage.createBucket(BUCKET_NAME, { multi_regional: true }, function() {}); + }); + + it('should expand the Regional option', function(done) { + storage.request = function(reqOpts) { + assert.strictEqual(reqOpts.json.storageClass, 'REGIONAL'); + done(); + }; + storage.createBucket(BUCKET_NAME, { regional: true }, function() {}); + }); + + it('should expand the Coldline option', function(done) { + storage.request = function(reqOpts) { + assert.strictEqual(reqOpts.json.storageClass, 'COLDLINE'); + done(); + }; + storage.createBucket(BUCKET_NAME, { coldline: true }, function() {}); + }); + it('should expand the Nearline option', function(done) { storage.request = function(reqOpts) { assert.strictEqual(reqOpts.json.storageClass, 'NEARLINE');