-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Bucket/Object lock operations #320
Support Bucket/Object lock operations #320
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stephenplusplus, getting back on track for bucket lock.
src/file.js
Outdated
* retention policy will expire. | ||
*/ | ||
/** | ||
* Get a Date object representing the earliest time this file will expire. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/bucket.js
Outdated
@@ -1799,6 +1836,34 @@ class Bucket extends common.ServiceObject { | |||
return new Notification(this, id); | |||
} | |||
|
|||
/** | |||
* Remove an already-existing retention policy from this bucket. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/bucket.js
Outdated
* {@link File#removeRetentionPeriod} and {@link File#setRetentionPeriod}. A | ||
* locked retention policy cannot be removed or shortened in duration for the | ||
* lifetime of the bucket. Attempting to remove or decrease period of a locked | ||
* retention policy will result in a `PERMISSION_DENIED` error. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/file.js
Outdated
* released. | ||
* | ||
* @param {object} [options] Configuration object. | ||
* @param {boolean} [options.temporary=false] - Set a temporary hold. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/file.js
Outdated
* @param {SetFileMetadataCallback} [callback] Callback function. | ||
* @returns {Promise<SetFileMetadataResponse>} | ||
*/ | ||
hold(options, callback) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
fb92583
to
e1297b5
Compare
Codecov Report
@@ Coverage Diff @@
## master #320 +/- ##
=========================================
Coverage ? 96.98%
=========================================
Files ? 7
Lines ? 1063
Branches ? 0
=========================================
Hits ? 1031
Misses ? 32
Partials ? 0
Continue to review full report at Codecov.
|
src/bucket.js
Outdated
* const storage = require('@google-cloud/storage')(); | ||
* const bucket = storage.bucket('albums'); | ||
* | ||
* bucket.lock(function(err, apiResponse) {}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/bucket.js
Outdated
@@ -1799,6 +1836,34 @@ class Bucket extends common.ServiceObject { | |||
return new Notification(this, id); | |||
} | |||
|
|||
/** | |||
* Remove an already-existing retention policy from this bucket. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/file.js
Outdated
* @param {SetFileMetadataCallback} [callback] Callback function. | ||
* @returns {Promise<SetFileMetadataResponse>} | ||
*/ | ||
hold(options, callback) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
e1297b5
to
06d0e89
Compare
@frankyn I've added the system tests to verify the hold behavior will block overwrite and delete operations on File objects. I've also removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stephenplusplus, rest of the surface LGTM. Only requested change is to include a paramater for metageneration in lockRetentionPolicy() instead of performing a getMetadata() beforehand.
src/bucket.ts
Outdated
* //- | ||
* // If the callback is omitted, we'll return a Promise. | ||
* //- | ||
* bucket.lock().then(function(data) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stephenplusplus! Lgtm
This reverts commit 2b1ffaf.
…" (googleapis#373)" This reverts commit 702d7bd.
To Dos
References
This introduces new behavior:
Buckets
bucket#lock()
Lock a previously-defined retention policy. This will prevent changes to the policy.
bucket#removeRetentionPeriod()
Remove an already-existing retention policy from this bucket.
bucket#setRetentionPeriod(durationInSeconds)
Lock all objects contained in the bucket, based on their creation time.
Files
Get a Date object representing the earliest time this file will expire.
Additionally,
bucket#getMetadata()
,bucket#setMetadata()
,file#getMetadata()
, andfile#setMetadata()
are available if users wish to interact with the raw resource schemas as defined by the API.