From 881a95330dfb0dbab71e9c405acd2a8423ff1fee Mon Sep 17 00:00:00 2001 From: y33zhang Date: Wed, 19 Oct 2016 21:45:03 -0700 Subject: [PATCH] Merge pull request #2571 from y33zhang:yyzhang-refresh Update Google Cloud Storage bucket classes. --- storage/google/cloud/storage/blob.py | 5 ++--- storage/google/cloud/storage/bucket.py | 14 ++++++-------- storage/unit_tests/test_bucket.py | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/storage/google/cloud/storage/blob.py b/storage/google/cloud/storage/blob.py index be964b179d8e..fe343afb696b 100644 --- a/storage/google/cloud/storage/blob.py +++ b/storage/google/cloud/storage/blob.py @@ -923,11 +923,10 @@ def storage_class(self): """Retrieve the storage class for the object. See: https://cloud.google.com/storage/docs/storage-classes - https://cloud.google.com/storage/docs/nearline-storage - https://cloud.google.com/storage/docs/durable-reduced-availability :rtype: string or ``NoneType`` - :returns: If set, one of "STANDARD", "NEARLINE", or + :returns: If set, one of "MULTI_REGIONAL", "REGIONAL", + "NEARLINE", "COLDLINE", "STANDARD", or "DURABLE_REDUCED_AVAILABILITY", else ``None``. """ return self._properties.get('storageClass') diff --git a/storage/google/cloud/storage/bucket.py b/storage/google/cloud/storage/bucket.py index 2c4aee98cccc..cbf663774863 100644 --- a/storage/google/cloud/storage/bucket.py +++ b/storage/google/cloud/storage/bucket.py @@ -84,7 +84,8 @@ class Bucket(_PropertyMixin): This is used in Bucket.delete() and Bucket.make_public(). """ - _STORAGE_CLASSES = ('STANDARD', 'NEARLINE', 'DURABLE_REDUCED_AVAILABILITY') + _STORAGE_CLASSES = ('STANDARD', 'NEARLINE', 'DURABLE_REDUCED_AVAILABILITY', + 'MULTI_REGIONAL', 'REGIONAL', 'COLDLINE') def __init__(self, client, name=None): super(Bucket, self).__init__(name=name) @@ -676,11 +677,10 @@ def storage_class(self): """Retrieve the storage class for the bucket. See: https://cloud.google.com/storage/docs/storage-classes - https://cloud.google.com/storage/docs/nearline-storage - https://cloud.google.com/storage/docs/durable-reduced-availability :rtype: string or ``NoneType`` - :returns: If set, one of "STANDARD", "NEARLINE", or + :returns: If set, one of "MULTI_REGIONAL", "REGIONAL", + "NEARLINE", "COLDLINE", "STANDARD", or "DURABLE_REDUCED_AVAILABILITY", else ``None``. """ return self._properties.get('storageClass') @@ -690,12 +690,10 @@ def storage_class(self, value): """Set the storage class for the bucket. See: https://cloud.google.com/storage/docs/storage-classes - https://cloud.google.com/storage/docs/nearline-storage - https://cloud.google.com/storage/docs/durable-reduced-availability :type value: string - :param value: one of "STANDARD", "NEARLINE", or - "DURABLE_REDUCED_AVAILABILITY" + :param value: one of "MULTI_REGIONAL", "REGIONAL", "NEARLINE", + "COLDLINE", "STANDARD", or "DURABLE_REDUCED_AVAILABILITY" """ if value not in self._STORAGE_CLASSES: raise ValueError('Invalid storage class: %s' % (value,)) diff --git a/storage/unit_tests/test_bucket.py b/storage/unit_tests/test_bucket.py index c887c2bc7929..59f48dedbfd8 100644 --- a/storage/unit_tests/test_bucket.py +++ b/storage/unit_tests/test_bucket.py @@ -746,6 +746,27 @@ def test_storage_class_setter_NEARLINE(self): self.assertEqual(bucket.storage_class, 'NEARLINE') self.assertTrue('storageClass' in bucket._changes) + def test_storage_class_setter_COLDLINE(self): + NAME = 'name' + bucket = self._makeOne(name=NAME) + bucket.storage_class = 'COLDLINE' + self.assertEqual(bucket.storage_class, 'COLDLINE') + self.assertTrue('storageClass' in bucket._changes) + + def test_storage_class_setter_MULTI_REGIONAL(self): + NAME = 'name' + bucket = self._makeOne(name=NAME) + bucket.storage_class = 'MULTI_REGIONAL' + self.assertEqual(bucket.storage_class, 'MULTI_REGIONAL') + self.assertTrue('storageClass' in bucket._changes) + + def test_storage_class_setter_REGIONAL(self): + NAME = 'name' + bucket = self._makeOne(name=NAME) + bucket.storage_class = 'REGIONAL' + self.assertEqual(bucket.storage_class, 'REGIONAL') + self.assertTrue('storageClass' in bucket._changes) + def test_storage_class_setter_DURABLE_REDUCED_AVAILABILITY(self): NAME = 'name' bucket = self._makeOne(name=NAME)