Skip to content

Commit

Permalink
docs: streamline docs for c.g.c migration (#876)
Browse files Browse the repository at this point in the history
* docs: remove literalinclude in client module

* remove literalinclude and update samples in Blob

* replace literalinclude with samples in Bucket

* update docstrings and remove inline samples

* update docstrings
  • Loading branch information
cojenco authored Oct 20, 2022
1 parent b6cc4d1 commit 7c8a178
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 504 deletions.
29 changes: 12 additions & 17 deletions google/cloud/storage/_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,11 @@ def generate_signed_url_v2(
.. note::
If you are on Google Compute Engine, you can't generate a signed URL.
Follow `Issue 922`_ for updates on this. If you'd like to be able to
generate a signed URL from GCE, you can use a standard service account
from a JSON file rather than a GCE service account.
If you'd like to be able to generate a signed URL from GCE, you can use a
standard service account from a JSON file rather than a GCE service account.
See headers `reference`_ for more details on optional arguments.
.. _Issue 922: https://github.com/GoogleCloudPlatform/\
google-cloud-python/issues/922
.. _reference: https://cloud.google.com/storage/docs/reference-headers
See headers [reference](https://cloud.google.com/storage/docs/reference-headers)
for more details on optional arguments.
:type credentials: :class:`google.auth.credentials.Signing`
:param credentials: Credentials object with an associated private key to
Expand Down Expand Up @@ -382,6 +378,8 @@ def generate_signed_url_v2(
elements_to_sign.append(canonical.resource)
string_to_sign = "\n".join(elements_to_sign)

# If you are on Google Compute Engine, you can't generate a signed URL.
# See https://github.com/googleapis/google-cloud-python/issues/922
# Set the right query parameters.
if access_token and service_account_email:
signature = _sign_message(string_to_sign, access_token, service_account_email)
Expand Down Expand Up @@ -446,16 +444,11 @@ def generate_signed_url_v4(
.. note::
If you are on Google Compute Engine, you can't generate a signed URL.
Follow `Issue 922`_ for updates on this. If you'd like to be able to
generate a signed URL from GCE, you can use a standard service account
from a JSON file rather than a GCE service account.
See headers `reference`_ for more details on optional arguments.
.. _Issue 922: https://github.com/GoogleCloudPlatform/\
google-cloud-python/issues/922
.. _reference: https://cloud.google.com/storage/docs/reference-headers
If you'd like to be able to generate a signed URL from GCE,you can use a
standard service account from a JSON file rather than a GCE service account.
See headers [reference](https://cloud.google.com/storage/docs/reference-headers)
for more details on optional arguments.
:type credentials: :class:`google.auth.credentials.Signing`
:param credentials: Credentials object with an associated private key to
Expand Down Expand Up @@ -543,6 +536,8 @@ def generate_signed_url_v4(
request_timestamp = _request_timestamp
datestamp = _request_timestamp[:8]

# If you are on Google Compute Engine, you can't generate a signed URL.
# See https://github.com/googleapis/google-cloud-python/issues/922
client_email = service_account_email
if not access_token or not service_account_email:
ensure_signed_credentials(credentials)
Expand Down
Loading

0 comments on commit 7c8a178

Please sign in to comment.