Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c03d6ae
feat(storage): add support of custom time metadata and timestamp
HemangChothani Jul 1, 2020
7347cf2
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani Jul 1, 2020
ef32ca2
Merge branch 'master' into storage_issue_196
jkwlui Jul 13, 2020
0212ca4
feat(storage): change the return type of custom_time_before
HemangChothani Jul 17, 2020
a6c830c
feat(storage): add setter method
HemangChothani Jul 24, 2020
3dbda6a
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani Jul 24, 2020
04e3a10
Merge branch 'master' into storage_issue_196
tseaver Jul 24, 2020
75e6067
feat(storage): add test for None value
HemangChothani Jul 27, 2020
7ee2796
Merge branch 'storage_issue_196' of https://github.com/q-logic/python…
HemangChothani Jul 27, 2020
e2793ce
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani Jul 27, 2020
43f1f5a
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani Aug 5, 2020
0bd9bf4
feat(storage): changes in unittest
HemangChothani Aug 5, 2020
fee993f
feat(storage): change custom_time type to date
HemangChothani Aug 5, 2020
76457b1
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani Aug 13, 2020
ae71f29
feat: change custom_time to datetime
HemangChothani Aug 17, 2020
d99fcb9
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani Aug 17, 2020
62781a3
Merge branch 'master' into storage_issue_196
frankyn Aug 24, 2020
0fcf160
Merge branch 'master' into storage_issue_196
frankyn Aug 24, 2020
39a12f0
feat: nit
HemangChothani Aug 25, 2020
285e15b
Merge branch 'storage_issue_196' of https://github.com/q-logic/python…
HemangChothani Aug 25, 2020
780a616
feat: resolve conflict and nit
HemangChothani Aug 26, 2020
e76b8bb
Merge branch 'master' into storage_issue_196
frankyn Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(storage): add setter method
  • Loading branch information
HemangChothani committed Jul 24, 2020
commit a6c830c5e56c64fcc1b9697b424a0d25785b2dec
13 changes: 13 additions & 0 deletions google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from google.api_core.iam import Policy
from google.cloud import exceptions
from google.cloud._helpers import _bytes_to_unicode
from google.cloud._helpers import _datetime_to_rfc3339
from google.cloud._helpers import _rfc3339_to_datetime
from google.cloud._helpers import _to_bytes
from google.cloud.exceptions import NotFound
Expand Down Expand Up @@ -3018,6 +3019,18 @@ def custom_time(self):
if value is not None:
return _rfc3339_to_datetime(value)

@custom_time.setter
def custom_time(self, value):
"""Set the custom time for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:type value: :class:`datetime.datetime`
:param value: (Optional) Set the custom time of blob. Datetime object parsed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the semantics of None value (which should be to clear any existing property value).

from RFC3339 valid timestamp.
"""
self._properties["customTime"] = _datetime_to_rfc3339(value)


def _get_encryption_headers(key, source=False):
"""Builds customer encryption key headers
Expand Down
13 changes: 12 additions & 1 deletion tests/unit/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -3792,7 +3792,7 @@ def test_updated_unset(self):
blob = self._make_one("blob-name", bucket=BUCKET)
self.assertIsNone(blob.updated)

def test_custom_time(self):
def test_custom_time_getter(self):
from google.cloud._helpers import _RFC3339_MICROS
from google.cloud._helpers import UTC

Expand All @@ -3804,6 +3804,17 @@ def test_custom_time(self):
blob = self._make_one(BLOB_NAME, bucket=bucket, properties=properties)
self.assertEqual(blob.custom_time, TIMESTAMP)

def test_custom_time_setter(self):
from google.cloud._helpers import UTC

BLOB_NAME = "blob-name"
bucket = _Bucket()
TIMESTAMP = datetime.datetime(2014, 11, 5, 20, 34, 37, tzinfo=UTC)
blob = self._make_one(BLOB_NAME, bucket=bucket)
self.assertIsNone(blob.custom_time)
blob.custom_time = TIMESTAMP
self.assertEqual(blob.custom_time, TIMESTAMP)

def test_custom_time_unset(self):
BUCKET = object()
blob = self._make_one("blob-name", bucket=BUCKET)
Expand Down