@google-cloud/storage
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -16,6 +16,28 @@ /** | ||
*/ | ||
import { Service } from '@google-cloud/common'; | ||
import { Service, GoogleAuthOptions } from '@google-cloud/common'; | ||
import * as request from 'request'; | ||
import { Bucket } from './bucket'; | ||
import { Channel } from './channel'; | ||
import { File } from './file'; | ||
export interface StorageOptions extends GoogleAuthOptions { | ||
autoRetry?: boolean; | ||
maxRetries?: number; | ||
promise?: typeof Promise; | ||
} | ||
export interface BucketOptions { | ||
kmsKeyName?: string; | ||
userProject?: string; | ||
} | ||
export interface CreateBucketRequest { | ||
coldline?: boolean; | ||
dra?: boolean; | ||
multiRegional?: boolean; | ||
nearline?: boolean; | ||
regional?: boolean; | ||
requesterPays?: boolean; | ||
userProject?: string; | ||
} | ||
export interface BucketCallback { | ||
(err: Error | null, bucket?: Bucket | null, apiResponse?: request.Response): void; | ||
} | ||
/** | ||
@@ -203,3 +225,3 @@ * @typedef {object} ClientConfig | ||
getBucketsStream: any; | ||
constructor(options: any); | ||
constructor(options?: StorageOptions); | ||
/** | ||
@@ -224,3 +246,3 @@ * Get a reference to a Cloud Storage bucket. | ||
*/ | ||
bucket(name: any, options?: any): Bucket; | ||
bucket(name: string, options?: BucketOptions): Bucket; | ||
/** | ||
@@ -239,3 +261,3 @@ * Reference a channel to receive notifications about changes to your bucket. | ||
*/ | ||
channel(id: any, resourceId: any): Channel; | ||
channel(id: string, resourceId: string): Channel; | ||
/** | ||
@@ -333,3 +355,4 @@ * Metadata to set for the bucket. | ||
*/ | ||
createBucket(name: any, metadata: any, callback: any): void; | ||
createBucket(name: string, callback: BucketCallback): void; | ||
createBucket(name: string, metadata: CreateBucketRequest, callback: BucketCallback): void; | ||
/** | ||
@@ -336,0 +359,0 @@ * Query object for listing buckets. |
@@ -89,3 +89,3 @@ /** | ||
class Storage extends common_1.Service { | ||
constructor(options) { | ||
constructor(options = {}) { | ||
const config = { | ||
@@ -153,102 +153,14 @@ baseUrl: 'https://www.googleapis.com/storage/v1', | ||
} | ||
/** | ||
* Metadata to set for the bucket. | ||
* | ||
* @typedef {object} CreateBucketRequest | ||
* @property {boolean} [coldline=false] Specify the storage class as Coldline. | ||
* @property {boolean} [dra=false] Specify the storage class as Durable Reduced | ||
* Availability. | ||
* @property {boolean} [multiRegional=false] Specify the storage class as | ||
* Multi-Regional. | ||
* @property {boolean} [nearline=false] Specify the storage class as Nearline. | ||
* @property {boolean} [regional=false] Specify the storage class as Regional. | ||
* @property {boolean} [requesterPays=false] **Early Access Testers Only** | ||
* Force the use of the User Project metadata field to assign operational | ||
* costs when an operation is made on a Bucket and its objects. | ||
* @property {string} [userProject] The ID of the project which will be billed | ||
* for the request. | ||
*/ | ||
/** | ||
* @typedef {array} CreateBucketResponse | ||
* @property {Bucket} 0 The new {@link Bucket}. | ||
* @property {object} 1 The full API response. | ||
*/ | ||
/** | ||
* @callback CreateBucketCallback | ||
* @param {?Error} err Request error, if any. | ||
* @param {Bucket} bucket The new {@link Bucket}. | ||
* @param {object} apiResponse The full API response. | ||
*/ | ||
/** | ||
* Create a bucket. | ||
* | ||
* Cloud Storage uses a flat namespace, so you can't create a bucket with | ||
* a name that is already in use. For more information, see | ||
* [Bucket Naming | ||
* Guidelines](https://cloud.google.com/storage/docs/bucketnaming.html#requirements). | ||
* | ||
* @see [Buckets: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/insert} | ||
* @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes} | ||
* | ||
* @param {string} name Name of the bucket to create. | ||
* @param {CreateBucketRequest} [metadata] Metadata to set for the bucket. | ||
* @param {CreateBucketCallback} [callback] Callback function. | ||
* @returns {Promise<CreateBucketResponse>} | ||
* @throws {Error} If a name is not provided. | ||
* @see Bucket#create | ||
* | ||
* @example | ||
* const {Storage} = require('@google-cloud/storage'); | ||
* const storage = new Storage(); | ||
* const callback = function(err, bucket, apiResponse) { | ||
* // `bucket` is a Bucket object. | ||
* }; | ||
* | ||
* storage.createBucket('new-bucket', callback); | ||
* | ||
* //- | ||
* // Create a bucket in a specific location and region. <em>See the <a | ||
* // href="https://cloud.google.com/storage/docs/json_api/v1/buckets/insert"> | ||
* // Official JSON API docs</a> for complete details on the `location` | ||
* option. | ||
* // </em> | ||
* //- | ||
* const metadata = { | ||
* location: 'US-CENTRAL1', | ||
* regional: true | ||
* }; | ||
* | ||
* storage.createBucket('new-bucket', metadata, callback); | ||
* | ||
* //- | ||
* // Enable versioning on a new bucket. | ||
* //- | ||
* const metadata = { | ||
* versioning: { | ||
* enabled: true | ||
* } | ||
* }; | ||
* | ||
* storage.createBucket('new-bucket', metadata, callback); | ||
* | ||
* //- | ||
* // If the callback is omitted, we'll return a Promise. | ||
* //- | ||
* storage.createBucket('new-bucket').then(function(data) { | ||
* const bucket = data[0]; | ||
* const apiResponse = data[1]; | ||
* }); | ||
* | ||
* @example <caption>include:samples/buckets.js</caption> | ||
* region_tag:storage_create_bucket | ||
* Another example: | ||
*/ | ||
createBucket(name, metadata, callback) { | ||
createBucket(name, metadataOrCallback, callback) { | ||
if (!name) { | ||
throw new Error('A name is required to create a bucket.'); | ||
} | ||
let metadata; | ||
if (!callback) { | ||
callback = metadata; | ||
callback = metadataOrCallback; | ||
metadata = {}; | ||
} | ||
else { | ||
metadata = metadataOrCallback; | ||
} | ||
const body = extend({}, metadata, { | ||
@@ -255,0 +167,0 @@ name, |
@@ -7,2 +7,7 @@ # Changelog | ||
## v2.0.2 | ||
### Implementation Changes | ||
- Improve the types (#377) | ||
## v2.0.1 | ||
@@ -9,0 +14,0 @@ |
{ | ||
"name": "@google-cloud/storage", | ||
"description": "Cloud Storage Client Library for Node.js", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google Inc.", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
495052
10771