Skip to content

Commit

Permalink
Expose 'HMACKeyMetadata.id' field. (googleapis#9115)
Browse files Browse the repository at this point in the history
  • Loading branch information
tritone authored and tseaver committed Aug 28, 2019
1 parent 041d89e commit 5640610
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion storage/google/cloud/storage/hmac_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions storage/tests/unit/test_hmac_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 5640610

Please sign in to comment.