Skip to content
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

Introduce Object Lifecycle Management #471

Merged
merged 8 commits into from
Oct 31, 2018

Conversation

stephenplusplus
Copy link
Contributor

@stephenplusplus stephenplusplus commented Oct 19, 2018

To Dos

  • Docs
  • System tests
  • Unit tests

This introduces one method, bucket.addLifecycleRule(rule, [options], [callback]):

Add a rule

bucket.addLifecycleRule({
  action: 'delete',
  condition: {
    age: 365 * 3 // Specified in days.
  }
});

Replace any existing rules

bucket.addLifecycleRule({
  action: 'delete',
  condition: {
    age: 365 * 3 // Specified in days.
  }
}, { append: false });

Remove any existing rules

bucket.setMetadata({ lifecycle: null });

@stephenplusplus stephenplusplus added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 19, 2018
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 19, 2018
@ghost ghost assigned stephenplusplus Oct 19, 2018
Copy link
Contributor

@JustinBeckwith JustinBeckwith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/ nits

src/bucket.ts Outdated
* }, function(err, apiResponse) {});
*/
addLifecycleRule(rule: LifecycleRule): Promise<SetBucketMetadataResponse>;
addLifecycleRule(

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies on delay. Will perform another pass tomorrow morning. Overall I think it looks good so far.

I appreciate your patience!

src/bucket.ts Outdated
* condition: {
* createdBefore: new Date('2018')
* },
* storageClass: 'COLDLINE'

This comment was marked as spam.

@stephenplusplus stephenplusplus force-pushed the spp--lifecycle branch 2 times, most recently from 6005a30 to 6788426 Compare October 24, 2018 21:21
Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions, comments and nits.

Thanks @stephenplusplus

src/bucket.ts Outdated
@@ -989,6 +1004,140 @@ class Bucket extends ServiceObject {
this.getFilesStream = paginator.streamify('getFiles');
}

/**
* Set the object lifecycle rules for objects in this bucket.

This comment was marked as spam.

@@ -79,6 +79,21 @@ interface WatchAllOptions {
versions?: boolean;
}

/**
* @typedef {object} AddLifecycleRuleOptions Configuration options for Bucket#addLifecycleRule().
* @property {string} [append=true] The new rules will be appended to any

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

src/bucket.ts Outdated
*
* By default, the object lifecycle rule you provide to this method will be
* appended to any existing ones. To replace all existing rules, supply the
* `options` argument, setting `append` to `false`.

This comment was marked as spam.

src/bucket.ts Outdated
* bucket.addLifecycleRule({
* action: 'delete',
* condition: {
* matchesStorageClass: 'COLDLINE',

This comment was marked as spam.

src/bucket.ts Show resolved Hide resolved
src/bucket.ts Show resolved Hide resolved
* lifecycleRules.forEach(lifecycleRule => {});
* });
*
* //-

This comment was marked as spam.

*
* @param {LifecycleRule} rule The new lifecycle rule to be added to objects
* in this bucket.
* @param {string} [rule.storageClass] When using the `setStorageClass`

This comment was marked as spam.

This comment was marked as spam.

Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, lgtm

*
* @param {LifecycleRule} rule The new lifecycle rule to be added to objects
* in this bucket.
* @param {string} [rule.storageClass] When using the `setStorageClass`

This comment was marked as spam.

@@ -79,6 +79,21 @@ interface WatchAllOptions {
versions?: boolean;
}

/**
* @typedef {object} AddLifecycleRuleOptions Configuration options for Bucket#addLifecycleRule().
* @property {string} [append=true] The new rules will be appended to any

This comment was marked as spam.

@stephenplusplus stephenplusplus removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 26, 2018
@stephenplusplus
Copy link
Contributor Author

All tests have been written-- @callmehiphop want to take a quick look?

@JustinBeckwith
Copy link
Contributor

@callmehiphop 👋 mind taking a look? @stephenplusplus it would be rad to get this released :)

@callmehiphop callmehiphop merged commit 69df77f into googleapis:master Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants