Repository: googleapis/python-storage

Issue:
Add update_time as property for Bucket
Thanks for stopping by to let us know something could be better!

**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

 **Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

So using python library built an app we now need a feature that requires update_time and it does not exist. Its does in Java and in rest api just missing from python implementation. Work around use discovery api.

 **Describe the solution you'd like**
A clear and concise description of what you want to happen.

update_time property supported on the Bucket class properly.

 **Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
 **Additional context**
Add any other context or screenshots about the feature request here.


Discussion:

Patch:
diff --git a/google/cloud/storage/bucket.py b/google/cloud/storage/bucket.py
index 215e9ea..caa3ddd 100644
--- a/google/cloud/storage/bucket.py
+++ b/google/cloud/storage/bucket.py
@@ -2618,6 +2618,21 @@ class Bucket(_PropertyMixin):
         if value is not None:
             return _rfc3339_nanos_to_datetime(value)
 
+    @property
+    def updated(self):
+        """Retrieve the timestamp at which the bucket was last updated.
+
+        See https://cloud.google.com/storage/docs/json_api/v1/buckets
+
+        :rtype: :class:`datetime.datetime` or ``NoneType``
+        :returns: Datetime object parsed from RFC3339 valid timestamp, or
+                  ``None`` if the bucket's resource has not been loaded
+                  from the server.
+        """
+        value = self._properties.get("updated")
+        if value is not None:
+            return _rfc3339_nanos_to_datetime(value)
+
     @property
     def versioning_enabled(self):
         """Is versioning enabled for this bucket?


Test patch:
diff --git a/tests/unit/test_bucket.py b/tests/unit/test_bucket.py
index 6a0e5e2..a5d2763 100644
--- a/tests/unit/test_bucket.py
+++ b/tests/unit/test_bucket.py
@@ -2959,6 +2959,19 @@ class Test_Bucket(unittest.TestCase):
         bucket = self._make_one()
         self.assertIsNone(bucket.time_created)
 
+    def test_updated(self):
+        from google.cloud._helpers import _RFC3339_MICROS
+
+        TIMESTAMP = datetime.datetime(2023, 11, 5, 20, 34, 37, tzinfo=_UTC)
+        UPDATED = TIMESTAMP.strftime(_RFC3339_MICROS)
+        properties = {"updated": UPDATED}
+        bucket = self._make_one(properties=properties)
+        self.assertEqual(bucket.updated, TIMESTAMP)
+
+    def test_updated_unset(self):
+        bucket = self._make_one()
+        self.assertIsNone(bucket.updated)
+
     def test_versioning_enabled_getter_missing(self):
         NAME = "name"
         bucket = self._make_one(name=NAME)