From 00fc236de5ff389069a3ccfebda93d832c95b007 Mon Sep 17 00:00:00 2001 From: HemangChothani Date: Wed, 19 Aug 2020 17:47:31 +0530 Subject: [PATCH 1/3] docs: add docs expiration take default utc --- google/cloud/storage/_signing.py | 16 ++++++++++++---- google/cloud/storage/blob.py | 4 +++- google/cloud/storage/bucket.py | 4 +++- google/cloud/storage/client.py | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/google/cloud/storage/_signing.py b/google/cloud/storage/_signing.py index 8e18bdaea..65e187121 100644 --- a/google/cloud/storage/_signing.py +++ b/google/cloud/storage/_signing.py @@ -91,7 +91,9 @@ def get_expiration_seconds_v2(expiration): """Convert 'expiration' to a number of seconds in the future. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Point in time when the signed URL should expire. + :param expiration: Point in time when the signed URL should expire. If + expiration in datetime, then need to pass timezone + with it. Default value of ``tzinfo`` is ``UTC``. :raises: :exc:`TypeError` when expiration is not a valid type. @@ -123,7 +125,9 @@ def get_expiration_seconds_v4(expiration): """Convert 'expiration' to a number of seconds offset from the current time. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Point in time when the signed URL should expire. + :param expiration: Point in time when the signed URL should expire. If + expiration in datetime, then need to pass timezone + with it. Default value of ``tzinfo`` is ``UTC``. :raises: :exc:`TypeError` when expiration is not a valid type. :raises: :exc:`ValueError` when expiration is too large. @@ -299,7 +303,9 @@ def generate_signed_url_v2( Caller should have already URL-encoded the value. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Point in time when the signed URL should expire. + :param expiration: Point in time when the signed URL should expire. If + expiration in datetime, then need to pass timezone with + it. Default value of ``tzinfo`` is ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. Defaults to empty string. @@ -461,7 +467,9 @@ def generate_signed_url_v4( Caller should have already URL-encoded the value. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Point in time when the signed URL should expire. + :param expiration: Point in time when the signed URL should expire. If + expiration in datetime, then need to pass timezone with + it. Default value of ``tzinfo`` is ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. Defaults to diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py index c2ff5790e..6c95f703b 100644 --- a/google/cloud/storage/blob.py +++ b/google/cloud/storage/blob.py @@ -411,7 +411,9 @@ def generate_signed_url( log in. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Point in time when the signed URL should expire. + :param expiration: Point in time when the signed URL should expire. If + expiration in datetime, then need to pass timezone + with it. Default value of ``tzinfo`` is ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. diff --git a/google/cloud/storage/bucket.py b/google/cloud/storage/bucket.py index ad7eaf6df..29eb283c4 100644 --- a/google/cloud/storage/bucket.py +++ b/google/cloud/storage/bucket.py @@ -2955,7 +2955,9 @@ def generate_signed_url( log in. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Point in time when the signed URL should expire. + :param expiration: Point in time when the signed URL should expire. If + expiration in datetime, then need to pass timezone + with it. Default value of ``tzinfo`` is ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index 6c7fa73c8..43531d5d4 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -962,7 +962,9 @@ def generate_signed_post_policy_v4( :param blob_name: Object name. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Policy expiration time. + :param expiration: Policy expiration time. If expiration in datetime, + then need to pass timezone with it. Default value of + ``tzinfo`` is ``UTC``. :type conditions: list :param conditions: (Optional) List of POST policy conditions, which are @@ -1004,11 +1006,13 @@ def generate_signed_post_policy_v4( Generate signed POST policy and upload a file. >>> from google.cloud import storage + >>> import pytz >>> client = storage.Client() + >>> tz = pytz.timezone('America/New_York') >>> policy = client.generate_signed_post_policy_v4( "bucket-name", "blob-name", - expiration=datetime.datetime(2020, 3, 17), + expiration=datetime.datetime(2020, 3, 17, tzinfo=tz), conditions=[ ["content-length-range", 0, 255] ], From a714474bb504d89ce39e2074bd09926694839ccc Mon Sep 17 00:00:00 2001 From: HemangChothani Date: Thu, 20 Aug 2020 12:18:54 +0530 Subject: [PATCH 2/3] docs: nit --- google/cloud/storage/_signing.py | 16 ++++++++-------- google/cloud/storage/blob.py | 4 ++-- google/cloud/storage/bucket.py | 4 ++-- google/cloud/storage/client.py | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/google/cloud/storage/_signing.py b/google/cloud/storage/_signing.py index 65e187121..88f19ddf1 100644 --- a/google/cloud/storage/_signing.py +++ b/google/cloud/storage/_signing.py @@ -92,8 +92,8 @@ def get_expiration_seconds_v2(expiration): :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If - expiration in datetime, then need to pass timezone - with it. Default value of ``tzinfo`` is ``UTC``. + a ``datetime`` instance is passed without an explicit + ``tzinfo`` set, it will be converted to ``UTC``. :raises: :exc:`TypeError` when expiration is not a valid type. @@ -126,8 +126,8 @@ def get_expiration_seconds_v4(expiration): :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If - expiration in datetime, then need to pass timezone - with it. Default value of ``tzinfo`` is ``UTC``. + a ``datetime`` instance is passed without an explicit + ``tzinfo`` set, it will be converted to ``UTC``. :raises: :exc:`TypeError` when expiration is not a valid type. :raises: :exc:`ValueError` when expiration is too large. @@ -304,8 +304,8 @@ def generate_signed_url_v2( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If - expiration in datetime, then need to pass timezone with - it. Default value of ``tzinfo`` is ``UTC``. + a ``datetime`` instance is passed without an explicit + ``tzinfo`` set, it will be converted to ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. Defaults to empty string. @@ -468,8 +468,8 @@ def generate_signed_url_v4( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If - expiration in datetime, then need to pass timezone with - it. Default value of ``tzinfo`` is ``UTC``. + a ``datetime`` instance is passed without an explicit + ``tzinfo`` set, it will be converted to ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. Defaults to diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py index 6c95f703b..269467afb 100644 --- a/google/cloud/storage/blob.py +++ b/google/cloud/storage/blob.py @@ -412,8 +412,8 @@ def generate_signed_url( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If - expiration in datetime, then need to pass timezone - with it. Default value of ``tzinfo`` is ``UTC``. + a ``datetime`` instance is passed without an explicit + ``tzinfo`` set, it will be converted to ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. diff --git a/google/cloud/storage/bucket.py b/google/cloud/storage/bucket.py index 29eb283c4..4d34b5644 100644 --- a/google/cloud/storage/bucket.py +++ b/google/cloud/storage/bucket.py @@ -2956,8 +2956,8 @@ def generate_signed_url( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If - expiration in datetime, then need to pass timezone - with it. Default value of ``tzinfo`` is ``UTC``. + a ``datetime`` instance is passed without an explicit + ``tzinfo`` set, it will be converted to ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index 43531d5d4..e559f7636 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -962,9 +962,9 @@ def generate_signed_post_policy_v4( :param blob_name: Object name. :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] - :param expiration: Policy expiration time. If expiration in datetime, - then need to pass timezone with it. Default value of - ``tzinfo`` is ``UTC``. + :param expiration: Policy expiration time. If a ``datetime`` instance is + passed without an explicit ``tzinfo`` set, it will be + converted to ``UTC``. :type conditions: list :param conditions: (Optional) List of POST policy conditions, which are From 3b0b9d58a443b94e90784626e41e43b01e06a20d Mon Sep 17 00:00:00 2001 From: HemangChothani Date: Tue, 25 Aug 2020 10:37:43 +0530 Subject: [PATCH 3/3] docs: nit --- google/cloud/storage/_signing.py | 8 ++++---- google/cloud/storage/blob.py | 2 +- google/cloud/storage/bucket.py | 2 +- google/cloud/storage/client.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/google/cloud/storage/_signing.py b/google/cloud/storage/_signing.py index 88f19ddf1..1382ebc77 100644 --- a/google/cloud/storage/_signing.py +++ b/google/cloud/storage/_signing.py @@ -93,7 +93,7 @@ def get_expiration_seconds_v2(expiration): :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If a ``datetime`` instance is passed without an explicit - ``tzinfo`` set, it will be converted to ``UTC``. + ``tzinfo`` set, it will be assumed to be ``UTC``. :raises: :exc:`TypeError` when expiration is not a valid type. @@ -127,7 +127,7 @@ def get_expiration_seconds_v4(expiration): :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If a ``datetime`` instance is passed without an explicit - ``tzinfo`` set, it will be converted to ``UTC``. + ``tzinfo`` set, it will be assumed to be ``UTC``. :raises: :exc:`TypeError` when expiration is not a valid type. :raises: :exc:`ValueError` when expiration is too large. @@ -305,7 +305,7 @@ def generate_signed_url_v2( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If a ``datetime`` instance is passed without an explicit - ``tzinfo`` set, it will be converted to ``UTC``. + ``tzinfo`` set, it will be assumed to be ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. Defaults to empty string. @@ -469,7 +469,7 @@ def generate_signed_url_v4( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If a ``datetime`` instance is passed without an explicit - ``tzinfo`` set, it will be converted to ``UTC``. + ``tzinfo`` set, it will be assumed to be ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. Defaults to diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py index 269467afb..e48a43567 100644 --- a/google/cloud/storage/blob.py +++ b/google/cloud/storage/blob.py @@ -413,7 +413,7 @@ def generate_signed_url( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If a ``datetime`` instance is passed without an explicit - ``tzinfo`` set, it will be converted to ``UTC``. + ``tzinfo`` set, it will be assumed to be ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. diff --git a/google/cloud/storage/bucket.py b/google/cloud/storage/bucket.py index 4d34b5644..8c50884a7 100644 --- a/google/cloud/storage/bucket.py +++ b/google/cloud/storage/bucket.py @@ -2957,7 +2957,7 @@ def generate_signed_url( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Point in time when the signed URL should expire. If a ``datetime`` instance is passed without an explicit - ``tzinfo`` set, it will be converted to ``UTC``. + ``tzinfo`` set, it will be assumed to be ``UTC``. :type api_access_endpoint: str :param api_access_endpoint: (Optional) URI base. diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index e559f7636..fd29abe9c 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -964,7 +964,7 @@ def generate_signed_post_policy_v4( :type expiration: Union[Integer, datetime.datetime, datetime.timedelta] :param expiration: Policy expiration time. If a ``datetime`` instance is passed without an explicit ``tzinfo`` set, it will be - converted to ``UTC``. + assumed to be ``UTC``. :type conditions: list :param conditions: (Optional) List of POST policy conditions, which are