Abacn commented on code in PR #17380:
URL: https://github.com/apache/beam/pull/17380#discussion_r863227799
##########
sdks/python/apache_beam/io/gcp/gcsio.py:
##########
@@ -532,39 +510,85 @@ def last_updated(self, path):
Returns: last updated time of the GCS object in second.
"""
+ return self._updated_to_seconds(self._gcs_object(path).updated)
+
+ def _status(self, path):
+ """For internal use only; no backwards-compatibility guarantees.
+
+ Returns supported fields (checksum, kms_key, last_updated, size) of a
+ single object as a dict at once.
+
+ This method does not perform glob expansion. Hence the given path must be
+ for a single GCS object.
+
+ Returns: dict of fields of the GCS object.
+ """
+ gcs_object = self._gcs_object(path)
+ file_status = {}
+ if hasattr(gcs_object, 'crc32c'):
+ file_status['checksum'] = gcs_object.crc32c
+ if hasattr(gcs_object, 'kmsKeyName'):
+ file_status['kms_key'] = gcs_object.kmsKeyName
+ if hasattr(gcs_object, 'updated'):
+ file_status['last_updated'] =
self._updated_to_seconds(gcs_object.updated)
Review Comment:
Yes, the response returned by client.objects.Get contains a updated field
which is a datetime object
https://cloud.google.com/storage/docs/json_api/v1/objects#resource-representations
. This piece of code uses existing code in GcsIO.last_updated method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]