Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/storage/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 24 additions & 0 deletions packages/storage/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down