From 56406105ea97812eb4adc3e62a580c97669484d7 Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Wed, 28 Aug 2019 09:59:42 -0400 Subject: [PATCH] Expose 'HMACKeyMetadata.id' field. (#9115) --- storage/google/cloud/storage/hmac_key.py | 11 ++++++++++- storage/tests/unit/test_hmac_key.py | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/storage/google/cloud/storage/hmac_key.py b/storage/google/cloud/storage/hmac_key.py index 257719ca80d0..09075896fcb2 100644 --- a/storage/google/cloud/storage/hmac_key.py +++ b/storage/google/cloud/storage/hmac_key.py @@ -63,7 +63,7 @@ def __hash__(self): @property def access_id(self): - """ID of the key. + """Access ID of the key. :rtype: str or None :returns: unique identifier of the key within a project. @@ -79,6 +79,15 @@ def etag(self): """ return self._properties.get("etag") + @property + def id(self): + """ID of the key, including the Project ID and the Access ID. + + :rtype: str or None + :returns: ID of the key. + """ + return self._properties.get("id") + @property def project(self): """Project ID associated with the key. diff --git a/storage/tests/unit/test_hmac_key.py b/storage/tests/unit/test_hmac_key.py index ecee7d9865a2..399a82682a64 100644 --- a/storage/tests/unit/test_hmac_key.py +++ b/storage/tests/unit/test_hmac_key.py @@ -36,6 +36,7 @@ def test_ctor_defaults(self): self.assertEqual(metadata._properties, {}) self.assertIsNone(metadata.access_id) self.assertIsNone(metadata.etag) + self.assertIsNone(metadata.id) self.assertIsNone(metadata.project) self.assertIsNone(metadata.service_account_email) self.assertIsNone(metadata.state) @@ -52,6 +53,7 @@ def test_ctor_explicit(self): self.assertEqual(metadata._properties, expected) self.assertEqual(metadata.access_id, ACCESS_ID) self.assertIsNone(metadata.etag) + self.assertIsNone(metadata.id) self.assertEqual(metadata.project, OTHER_PROJECT) self.assertIsNone(metadata.service_account_email) self.assertIsNone(metadata.state) @@ -104,6 +106,12 @@ def test_etag_getter(self): metadata._properties["etag"] = expected self.assertEqual(metadata.etag, expected) + def test_id_getter(self): + metadata = self._make_one() + expected = "ID" + metadata._properties["id"] = expected + self.assertEqual(metadata.id, expected) + def test_project_getter(self): metadata = self._make_one() expected = "PROJECT-ID"