Skip to content
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

feat: add support for custom headers #1121

Merged
merged 14 commits into from
Oct 19, 2023
Merged

Conversation

cojenco
Copy link
Contributor

@cojenco cojenco commented Sep 19, 2023

Add support for custom headers on a per-client basis
Reference - https://cloud.google.com/storage/docs/troubleshooting#custom-headers

The following sample adds a custom header to the requests made by the client

from google.cloud import storage

client = storage.Client(
    extra_headers={
        "custom-header": "custom-value"
    }
)

Fixes internal b/294091512 🦕

MiaCY and others added 8 commits June 13, 2023 16:27
* Refactor client.download_blob_to_file

* Chore: clean up code

* refactor blob and client unit tests

* lint reformat

* Rename _prep_and_do_download
* Refactor client.download_blob_to_file

* Chore: clean up code

* refactor blob and client unit tests

* lint reformat

* Rename _prep_and_do_download

* Refactor blob.upload_from_file

* Lint reformat
…oogleapis#1082)

* Refactor client.download_blob_to_file

* Chore: clean up code

* refactor blob and client unit tests

* lint reformat

* Rename _prep_and_do_download

* Refactor blob.upload_from_file

* Lint reformat

* feature: add 'command' argument to private upload/download interface

* lint reformat

* reduce duplication and edit docstring
@cojenco cojenco requested review from a team as code owners September 19, 2023 20:26
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/python-storage API. labels Sep 19, 2023
@cojenco cojenco added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 19, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 19, 2023
@cojenco cojenco added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 20, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 20, 2023
Copy link
Contributor

@andrewsg andrewsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have integration tests as well but since we don't typically snoop on outbound requests in our integration tests, and since custom headers don't usually have an impact on API behavior that is easily observable at the level our tests run, it may be difficult. Consider creative ways to implement an integration test if any come to mind; otherwise, good to go. Thanks.

@cojenco cojenco added the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 18, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 18, 2023
@cojenco cojenco merged commit 2f92c3a into googleapis:main Oct 19, 2023
13 checks passed
shunping added a commit to shunping/beam that referenced this pull request Nov 9, 2023
The customized headers in client are supported starting from this
version (googleapis/python-storage#1121).
This feature is needed to set the user-agent during storage client
initialization.
@cojenco cojenco deleted the custom-headers1 branch November 16, 2023 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants