Skip to content

Commit

Permalink
Merge pull request #2571 from y33zhang:yyzhang-refresh
Browse files Browse the repository at this point in the history
Update Google Cloud Storage bucket classes.
  • Loading branch information
y33zhang authored and dhermes committed Oct 20, 2016
1 parent 85a0c1a commit 881a953
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
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 @@ -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)
Expand Down Expand Up @@ -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')
Expand All @@ -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,))
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 @@ -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)
Expand Down

0 comments on commit 881a953

Please sign in to comment.