Skip to content

Storage: Improve docs for 'generate_signed_url'. #7201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 12 additions & 4 deletions storage/google/cloud/storage/_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
def ensure_signed_credentials(credentials):
"""Raise AttributeError if the credentials are unsigned.

:type credentials: :class:`google.auth.credentials.Signer`
:type credentials: :class:`google.auth.credentials.Signing`
:param credentials: The credentials used to create a private key
for signing text.

:raises: :exc:`AttributeError` if credentials is not an instance
of :class:`google.auth.credentials.Signing`.
"""
if not isinstance(credentials, google.auth.credentials.Signing):
auth_uri = (
Expand All @@ -49,7 +52,7 @@ def ensure_signed_credentials(credentials):
def get_signed_query_params(credentials, expiration, string_to_sign):
"""Gets query parameters for creating a signed URL.

:type credentials: :class:`google.auth.credentials.Signer`
:type credentials: :class:`google.auth.credentials.Signing`
:param credentials: The credentials used to create a private key
for signing text.

Expand All @@ -59,7 +62,8 @@ def get_signed_query_params(credentials, expiration, string_to_sign):
:type string_to_sign: str
:param string_to_sign: The string to be signed by the credentials.

:raises AttributeError: If :meth: sign_blob is unavailable.
:raises: :exc:`AttributeError` if credentials is not an instance
of :class:`google.auth.credentials.Signing`.

:rtype: dict
:returns: Query parameters matching the signing credentials with a
Expand All @@ -82,7 +86,7 @@ def get_expiration_seconds(expiration):
:type expiration: int, long, datetime.datetime, datetime.timedelta
:param expiration: When the signed URL should expire.

:raises TypeError: When expiration is not an integer.
:raises: :exc:`TypeError` when expiration is not a valid type.

:rtype: int
:returns: a timestamp as an absolute number of seconds.
Expand Down Expand Up @@ -184,6 +188,10 @@ def generate_signed_url(
:param generation: (Optional) A value that indicates which generation of
the resource to fetch.

:raises: :exc:`TypeError` when expiration is not a valid type.
:raises: :exc:`AttributeError` if credentials is not an instance
of :class:`google.auth.credentials.Signing`.

:rtype: str
:returns: A signed URL you can use to access the resource
until expiration.
Expand Down
4 changes: 4 additions & 0 deletions storage/google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ def generate_signed_url(
the URL. Defaults to the credentials stored on the
client used.

:raises: :exc:`TypeError` when expiration is not a valid type.
:raises: :exc:`AttributeError` if credentials is not an instance
of :class:`google.auth.credentials.Signing`.

:rtype: str
:returns: A signed URL you can use to access the resource
until expiration.
Expand Down