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

Update Google Cloud Storage bucket classes. #2571

Merged
merged 2 commits into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions storage/google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
14 changes: 6 additions & 8 deletions storage/google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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)
Expand Down Expand Up @@ -700,11 +701,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')
Expand All @@ -714,12 +714,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,))
Expand Down
21 changes: 21 additions & 0 deletions storage/unit_tests/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,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)
Expand Down