Skip to content

Commit 881a953

Browse files
y33zhangdhermes
authored andcommitted
Merge pull request googleapis#2571 from y33zhang:yyzhang-refresh
Update Google Cloud Storage bucket classes.
1 parent 85a0c1a commit 881a953

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

storage/google/cloud/storage/blob.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -923,11 +923,10 @@ def storage_class(self):
923923
"""Retrieve the storage class for the object.
924924
925925
See: https://cloud.google.com/storage/docs/storage-classes
926-
https://cloud.google.com/storage/docs/nearline-storage
927-
https://cloud.google.com/storage/docs/durable-reduced-availability
928926
929927
:rtype: string or ``NoneType``
930-
:returns: If set, one of "STANDARD", "NEARLINE", or
928+
:returns: If set, one of "MULTI_REGIONAL", "REGIONAL",
929+
"NEARLINE", "COLDLINE", "STANDARD", or
931930
"DURABLE_REDUCED_AVAILABILITY", else ``None``.
932931
"""
933932
return self._properties.get('storageClass')

storage/google/cloud/storage/bucket.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class Bucket(_PropertyMixin):
8484
This is used in Bucket.delete() and Bucket.make_public().
8585
"""
8686

87-
_STORAGE_CLASSES = ('STANDARD', 'NEARLINE', 'DURABLE_REDUCED_AVAILABILITY')
87+
_STORAGE_CLASSES = ('STANDARD', 'NEARLINE', 'DURABLE_REDUCED_AVAILABILITY',
88+
'MULTI_REGIONAL', 'REGIONAL', 'COLDLINE')
8889

8990
def __init__(self, client, name=None):
9091
super(Bucket, self).__init__(name=name)
@@ -676,11 +677,10 @@ def storage_class(self):
676677
"""Retrieve the storage class for the bucket.
677678
678679
See: https://cloud.google.com/storage/docs/storage-classes
679-
https://cloud.google.com/storage/docs/nearline-storage
680-
https://cloud.google.com/storage/docs/durable-reduced-availability
681680
682681
:rtype: string or ``NoneType``
683-
:returns: If set, one of "STANDARD", "NEARLINE", or
682+
:returns: If set, one of "MULTI_REGIONAL", "REGIONAL",
683+
"NEARLINE", "COLDLINE", "STANDARD", or
684684
"DURABLE_REDUCED_AVAILABILITY", else ``None``.
685685
"""
686686
return self._properties.get('storageClass')
@@ -690,12 +690,10 @@ def storage_class(self, value):
690690
"""Set the storage class for the bucket.
691691
692692
See: https://cloud.google.com/storage/docs/storage-classes
693-
https://cloud.google.com/storage/docs/nearline-storage
694-
https://cloud.google.com/storage/docs/durable-reduced-availability
695693
696694
:type value: string
697-
:param value: one of "STANDARD", "NEARLINE", or
698-
"DURABLE_REDUCED_AVAILABILITY"
695+
:param value: one of "MULTI_REGIONAL", "REGIONAL", "NEARLINE",
696+
"COLDLINE", "STANDARD", or "DURABLE_REDUCED_AVAILABILITY"
699697
"""
700698
if value not in self._STORAGE_CLASSES:
701699
raise ValueError('Invalid storage class: %s' % (value,))

storage/unit_tests/test_bucket.py

+21
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,27 @@ def test_storage_class_setter_NEARLINE(self):
746746
self.assertEqual(bucket.storage_class, 'NEARLINE')
747747
self.assertTrue('storageClass' in bucket._changes)
748748

749+
def test_storage_class_setter_COLDLINE(self):
750+
NAME = 'name'
751+
bucket = self._makeOne(name=NAME)
752+
bucket.storage_class = 'COLDLINE'
753+
self.assertEqual(bucket.storage_class, 'COLDLINE')
754+
self.assertTrue('storageClass' in bucket._changes)
755+
756+
def test_storage_class_setter_MULTI_REGIONAL(self):
757+
NAME = 'name'
758+
bucket = self._makeOne(name=NAME)
759+
bucket.storage_class = 'MULTI_REGIONAL'
760+
self.assertEqual(bucket.storage_class, 'MULTI_REGIONAL')
761+
self.assertTrue('storageClass' in bucket._changes)
762+
763+
def test_storage_class_setter_REGIONAL(self):
764+
NAME = 'name'
765+
bucket = self._makeOne(name=NAME)
766+
bucket.storage_class = 'REGIONAL'
767+
self.assertEqual(bucket.storage_class, 'REGIONAL')
768+
self.assertTrue('storageClass' in bucket._changes)
769+
749770
def test_storage_class_setter_DURABLE_REDUCED_AVAILABILITY(self):
750771
NAME = 'name'
751772
bucket = self._makeOne(name=NAME)

0 commit comments

Comments
 (0)