@google-cloud/storage
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -113,2 +113,62 @@ /** | ||
} | ||
addLifecycleRule(rule, optionsOrCallback, callback) { | ||
let options; | ||
if (typeof optionsOrCallback === 'function') { | ||
callback = optionsOrCallback; | ||
} | ||
else if (optionsOrCallback) { | ||
options = optionsOrCallback; | ||
} | ||
options = options || {}; | ||
callback = callback || common_1.util.noop; | ||
const newLifecycleRules = arrify(rule).map(rule => { | ||
if (typeof rule.action === 'object') { | ||
// This is a raw-formatted rule object, the way the API expects. | ||
// Just pass it through as-is. | ||
return rule; | ||
} | ||
const apiFormattedRule = {}; | ||
apiFormattedRule.condition = {}; | ||
apiFormattedRule.action = { | ||
type: rule.action, | ||
}; | ||
// @TODO: Remove if the API becomes less picky. | ||
if (rule.action === 'delete') { | ||
apiFormattedRule.action.type = 'Delete'; | ||
} | ||
if (rule.storageClass) { | ||
apiFormattedRule.action.storageClass = rule.storageClass; | ||
} | ||
for (const condition in rule.condition) { | ||
if (rule.condition[condition] instanceof Date) { | ||
apiFormattedRule.condition[condition] = | ||
rule.condition[condition] | ||
.toISOString() | ||
.replace(/T.+$/, ''); | ||
} | ||
else { | ||
apiFormattedRule.condition[condition] = rule.condition[condition]; | ||
} | ||
} | ||
return apiFormattedRule; | ||
}); | ||
if (options.append === false) { | ||
this.setMetadata({ lifecycle: { rule: newLifecycleRules } }, callback); | ||
return; | ||
} | ||
// The default behavior appends the previously-defined lifecycle rules with | ||
// the new ones just passed in by the user. | ||
this.getMetadata((err, metadata) => { | ||
if (err) { | ||
callback(err); | ||
return; | ||
} | ||
const currentLifecycleRules = arrify(metadata.lifecycle && metadata.lifecycle.rule); | ||
this.setMetadata({ | ||
lifecycle: { | ||
rule: currentLifecycleRules.concat(newLifecycleRules), | ||
}, | ||
}, callback); | ||
}); | ||
} | ||
combine(sources, destination, optionsOrCallback, callback) { | ||
@@ -115,0 +175,0 @@ if (!Array.isArray(sources) || sources.length < 2) { |
@@ -57,2 +57,8 @@ /** | ||
} | ||
/** | ||
* @typedef {object} CreateBucketResponse | ||
* @property {Bucket} bucket The newly created Bucket object. | ||
* @property {object} apiResponse The full API response. | ||
*/ | ||
export declare type CreateBucketResponse = [Bucket, r.Response]; | ||
export interface BucketCallback { | ||
@@ -394,2 +400,3 @@ (err: Error | null, bucket?: Bucket | null, apiResponse?: r.Response): void; | ||
*/ | ||
createBucket(name: string): Promise<CreateBucketResponse>; | ||
createBucket(name: string, callback: BucketCallback): void; | ||
@@ -396,0 +403,0 @@ createBucket(name: string, metadata: CreateBucketRequest, callback: BucketCallback): void; |
@@ -7,2 +7,16 @@ # Changelog | ||
## v2.3.0 | ||
### Implementation Changes | ||
- fix(types): Fixes getSignedUrl Return Type ([#496](https://github.com/googleapis/nodejs-storage/pull/496)) | ||
- | ||
### New Features | ||
- Introduce Object Lifecycle Management ([#471](https://github.com/googleapis/nodejs-storage/pull/471)) | ||
### Dependencies | ||
- chore(deps): update dependency eslint-plugin-node to v8 ([#490](https://github.com/googleapis/nodejs-storage/pull/490)) | ||
### Internal / Testing Changes | ||
- chore: update issue templates ([#488](https://github.com/googleapis/nodejs-storage/pull/488)) | ||
## v2.2.0 | ||
@@ -9,0 +23,0 @@ |
{ | ||
"name": "@google-cloud/storage", | ||
"description": "Cloud Storage Client Library for Node.js", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"license": "Apache-2.0", | ||
@@ -128,3 +128,3 @@ "author": "Google Inc.", | ||
"eslint-config-prettier": "^3.0.0", | ||
"eslint-plugin-node": "^7.0.0", | ||
"eslint-plugin-node": "^8.0.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
@@ -131,0 +131,0 @@ "gts": "^0.8.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
377144
8971