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

Add more in-depth support for object lifecycle management #1318

Merged
merged 5 commits into from
Sep 27, 2018

Conversation

dwsupplee
Copy link
Contributor

With this change set Google\Cloud\Storage\StorageClient::createBucket() and Google\Cloud\Storage\Bucket::update() can now both accept an instance of Google\Cloud\Storage\Lifecycle as opposed to a raw array.

Sample usage:

use Google\Cloud\Storage\Bucket;
use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient;
$bucket = $storage->createBucket('myBeautifulBucket', [
    'lifecycle' => Bucket::lifecycle()
        ->addDeleteRule([
            'age' => 50
        ])
]);

/cc @frankyn

@dwsupplee dwsupplee added the api: storage Issues related to the Cloud Storage API. label Sep 24, 2018
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 24, 2018
Copy link
Contributor

@jdpedrie jdpedrie left a comment

Choose a reason for hiding this comment

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

just one documentation suggestion. looks really nice!

* providing a callable you may define a custom route for how you
* would like to remove rules. The provided callable will be run
* through
* [array_filter](http://php.net/manual/en/function.array-filter.php).

This comment was marked as spam.

This comment was marked as spam.

@@ -779,7 +779,7 @@ public function delete(array $options = [])
* configuration.
* @type array $defaultObjectAcl Default access controls to apply to new
* objects when no ACL is provided.
* @type array $lifecycle The bucket's lifecycle configuration.
* @type array|Lifecycle $lifecycle The bucket's lifecycle configuration.

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.

@@ -779,7 +779,7 @@ public function delete(array $options = [])
* configuration.
* @type array $defaultObjectAcl Default access controls to apply to new
* objects when no ACL is provided.
* @type array $lifecycle The bucket's lifecycle configuration.
* @type array|Lifecycle $lifecycle The bucket's lifecycle configuration.

This comment was marked as spam.

}

/**
* @access private

This comment was marked as spam.

This comment was marked as spam.

* ->addDeleteRule([
* 'age' => 50,
* 'isLive' => true
* ]);

This comment was marked as spam.

This comment was marked as spam.

* @throws \InvalidArgumentException If a type other than a string or
* callabe is provided.
*/
public function clearRules($condition = null)

This comment was marked as spam.

This comment was marked as spam.

}

/**
* Adds a delete rule.

This comment was marked as spam.

This comment was marked as spam.

* @throws \InvalidArgumentException If a type other than a string or
* callabe is provided.
*/
public function clearRules($condition = null)

This comment was marked as spam.

This comment was marked as spam.

}

/**
* Adds a set storage class rule.

This comment was marked as spam.

This comment was marked as spam.

}

/**
* Clears out rules based on the provided condition.

This comment was marked as spam.

This comment was marked as spam.

*
* @see https://cloud.google.com/storage/docs/lifecycle Object Lifecycle Management API Documentation
*/
class Lifecycle

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.

@dwsupplee
Copy link
Contributor Author

Thank you for the review @frankyn. I touched on your feedback, PTAL.

Copy link
Contributor

@tmatsuo tmatsuo left a comment

Choose a reason for hiding this comment

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

LG, with some minor comments

* @param string $offset
* @param mixed $value
*/
public function offsetSet($offset, $value)

This comment was marked as spam.

This comment was marked as spam.

* @param string $offset
* @return mixed
*/
public function offsetGet($offset)

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.

I like the update, pending follow-up discussions in comments and some minor nits.

* @param array $options [optional] Configuration options.
* @return Lifecycle
*/
public function currentLifecycle(array $options = [])

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

*
* $storage = new StorageClient();
* $bucket = $storage->bucket('my-bucket');
* $lifecycle = $bucket->currentLifecycle();

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.

LGTM

@dwsupplee dwsupplee merged commit 81c4a94 into googleapis:master Sep 27, 2018
@tmatsuo tmatsuo mentioned this pull request Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. 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