Skip to content

Commit

Permalink
fix: fix typo in Bucket.clear_lifecycle_rules() (#1169)
Browse files Browse the repository at this point in the history
Fixes #1074 🦕
  • Loading branch information
andrewsg committed Oct 23, 2023
1 parent eac91cb commit eae9ebe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2275,14 +2275,18 @@ def lifecycle_rules(self, rules):
rules = [dict(rule) for rule in rules] # Convert helpers if needed
self._patch_property("lifecycle", {"rule": rules})

def clear_lifecyle_rules(self):
def clear_lifecycle_rules(self):
"""Clear lifecycle rules configured for this bucket.
See https://cloud.google.com/storage/docs/lifecycle and
https://cloud.google.com/storage/docs/json_api/v1/buckets
"""
self.lifecycle_rules = []

def clear_lifecyle_rules(self):
"""Deprecated alias for clear_lifecycle_rules."""
return self.clear_lifecycle_rules()

def add_lifecycle_delete_rule(self, **kw):
"""Add a "delete" rule to lifecycle rules configured for this bucket.
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,7 @@ def test_clear_lifecycle_rules(self):
bucket._properties["lifecycle"] = {"rule": rules}
self.assertEqual(list(bucket.lifecycle_rules), rules)

# This is a deprecated alias and will test both methods
bucket.clear_lifecyle_rules()

self.assertEqual(list(bucket.lifecycle_rules), [])
Expand Down

0 comments on commit eae9ebe

Please sign in to comment.