diff --git a/storage/google/cloud/storage/blob.py b/storage/google/cloud/storage/blob.py index cf22a9a77ae2..1b718520865d 100644 --- a/storage/google/cloud/storage/blob.py +++ b/storage/google/cloud/storage/blob.py @@ -59,11 +59,12 @@ from google.cloud.storage._signing import generate_signed_url_v4 from google.cloud.storage.acl import ACL from google.cloud.storage.acl import ObjectACL -from google.cloud.storage.constants import STANDARD_STORAGE_CLASS -from google.cloud.storage.constants import NEARLINE_STORAGE_CLASS +from google.cloud.storage.constants import ARCHIVE_STORAGE_CLASS from google.cloud.storage.constants import COLDLINE_STORAGE_CLASS from google.cloud.storage.constants import MULTI_REGIONAL_LEGACY_STORAGE_CLASS +from google.cloud.storage.constants import NEARLINE_STORAGE_CLASS from google.cloud.storage.constants import REGIONAL_LEGACY_STORAGE_CLASS +from google.cloud.storage.constants import STANDARD_STORAGE_CLASS _STORAGE_HOST = _get_storage_host() @@ -143,6 +144,7 @@ class Blob(_PropertyMixin): STANDARD_STORAGE_CLASS, NEARLINE_STORAGE_CLASS, COLDLINE_STORAGE_CLASS, + ARCHIVE_STORAGE_CLASS, MULTI_REGIONAL_LEGACY_STORAGE_CLASS, REGIONAL_LEGACY_STORAGE_CLASS, ) @@ -1656,6 +1658,7 @@ def update_storage_class(self, new_class, client=None): new storage class for the object. One of: :attr:`~google.cloud.storage.constants.NEARLINE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.COLDLINE_STORAGE_CLASS`, + :attr:`~google.cloud.storage.constants.ARCHIVE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.STANDARD_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.MULTI_REGIONAL_LEGACY_STORAGE_CLASS`, or @@ -1951,6 +1954,7 @@ def kms_key_name(self): :attr:`~google.cloud.storage.constants.STANDARD_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.NEARLINE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.COLDLINE_STORAGE_CLASS`, + :attr:`~google.cloud.storage.constants.ARCHIVE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.MULTI_REGIONAL_LEGACY_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.REGIONAL_LEGACY_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.DURABLE_REDUCED_AVAILABILITY_STORAGE_CLASS`, diff --git a/storage/google/cloud/storage/bucket.py b/storage/google/cloud/storage/bucket.py index 48ab09e23e4f..764bd385789b 100644 --- a/storage/google/cloud/storage/bucket.py +++ b/storage/google/cloud/storage/bucket.py @@ -39,6 +39,7 @@ from google.cloud.storage.acl import BucketACL from google.cloud.storage.acl import DefaultObjectACL from google.cloud.storage.blob import Blob +from google.cloud.storage.constants import ARCHIVE_STORAGE_CLASS from google.cloud.storage.constants import COLDLINE_STORAGE_CLASS from google.cloud.storage.constants import DUAL_REGION_LOCATION_TYPE from google.cloud.storage.constants import ( @@ -402,6 +403,7 @@ class Bucket(_PropertyMixin): STANDARD_STORAGE_CLASS, NEARLINE_STORAGE_CLASS, COLDLINE_STORAGE_CLASS, + ARCHIVE_STORAGE_CLASS, MULTI_REGIONAL_LEGACY_STORAGE_CLASS, # legacy REGIONAL_LEGACY_STORAGE_CLASS, # legacy DURABLE_REDUCED_AVAILABILITY_LEGACY_STORAGE_CLASS, # legacy @@ -1634,6 +1636,7 @@ def storage_class(self): If set, one of :attr:`~google.cloud.storage.constants.NEARLINE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.COLDLINE_STORAGE_CLASS`, + :attr:`~google.cloud.storage.constants.ARCHIVE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.STANDARD_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.MULTI_REGIONAL_LEGACY_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.REGIONAL_LEGACY_STORAGE_CLASS`, @@ -1654,6 +1657,7 @@ def storage_class(self, value): One of :attr:`~google.cloud.storage.constants.NEARLINE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.COLDLINE_STORAGE_CLASS`, + :attr:`~google.cloud.storage.constants.ARCHIVE_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.STANDARD_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.MULTI_REGIONAL_LEGACY_STORAGE_CLASS`, :attr:`~google.cloud.storage.constants.REGIONAL_LEGACY_STORAGE_CLASS`, diff --git a/storage/google/cloud/storage/constants.py b/storage/google/cloud/storage/constants.py index e93d3ab29546..fa281649da29 100644 --- a/storage/google/cloud/storage/constants.py +++ b/storage/google/cloud/storage/constants.py @@ -24,6 +24,9 @@ COLDLINE_STORAGE_CLASS = "COLDLINE" """Storage class for objects accessed at most once per year.""" +ARCHIVE_STORAGE_CLASS = "ARCHIVE" +"""Storage class for objects accessed less frequently than once per year.""" + MULTI_REGIONAL_LEGACY_STORAGE_CLASS = "MULTI_REGIONAL" """Legacy storage class. diff --git a/storage/tests/unit/test_bucket.py b/storage/tests/unit/test_bucket.py index de943339e200..2eb6f7d57561 100644 --- a/storage/tests/unit/test_bucket.py +++ b/storage/tests/unit/test_bucket.py @@ -1773,6 +1773,15 @@ def test_storage_class_setter_COLDLINE(self): self.assertEqual(bucket.storage_class, COLDLINE_STORAGE_CLASS) self.assertTrue("storageClass" in bucket._changes) + def test_storage_class_setter_ARCHIVE(self): + from google.cloud.storage.constants import ARCHIVE_STORAGE_CLASS + + NAME = "name" + bucket = self._make_one(name=NAME) + bucket.storage_class = ARCHIVE_STORAGE_CLASS + self.assertEqual(bucket.storage_class, ARCHIVE_STORAGE_CLASS) + self.assertTrue("storageClass" in bucket._changes) + def test_storage_class_setter_MULTI_REGIONAL(self): from google.cloud.storage.constants import MULTI_REGIONAL_LEGACY_STORAGE_CLASS