Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitae9a53b

Browse files
authored
fix: add "updated" as property for Bucket (#1220)
1 parentdcd6774 commitae9a53b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎google/cloud/storage/bucket.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2618,6 +2618,21 @@ def time_created(self):
26182618
ifvalueisnotNone:
26192619
return_rfc3339_nanos_to_datetime(value)
26202620

2621+
@property
2622+
defupdated(self):
2623+
"""Retrieve the timestamp at which the bucket was last updated.
2624+
2625+
See https://cloud.google.com/storage/docs/json_api/v1/buckets
2626+
2627+
:rtype: :class:`datetime.datetime` or ``NoneType``
2628+
:returns: Datetime object parsed from RFC3339 valid timestamp, or
2629+
``None`` if the bucket's resource has not been loaded
2630+
from the server.
2631+
"""
2632+
value=self._properties.get("updated")
2633+
ifvalueisnotNone:
2634+
return_rfc3339_nanos_to_datetime(value)
2635+
26212636
@property
26222637
defversioning_enabled(self):
26232638
"""Is versioning enabled for this bucket?

‎tests/unit/test_bucket.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,19 @@ def test_time_created_unset(self):
29592959
bucket=self._make_one()
29602960
self.assertIsNone(bucket.time_created)
29612961

2962+
deftest_updated(self):
2963+
fromgoogle.cloud._helpersimport_RFC3339_MICROS
2964+
2965+
TIMESTAMP=datetime.datetime(2023,11,5,20,34,37,tzinfo=_UTC)
2966+
UPDATED=TIMESTAMP.strftime(_RFC3339_MICROS)
2967+
properties= {"updated":UPDATED}
2968+
bucket=self._make_one(properties=properties)
2969+
self.assertEqual(bucket.updated,TIMESTAMP)
2970+
2971+
deftest_updated_unset(self):
2972+
bucket=self._make_one()
2973+
self.assertIsNone(bucket.updated)
2974+
29622975
deftest_versioning_enabled_getter_missing(self):
29632976
NAME="name"
29642977
bucket=self._make_one(name=NAME)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp