Skip to content

Commit

Permalink
feat: add gccl-gcs-cmd field to X-Goog-API-Client header for Transfer…
Browse files Browse the repository at this point in the history
… Manager calls (#1119)
  • Loading branch information
andrewsg committed Sep 19, 2023
1 parent 56aeb87 commit 14a1909
Show file tree
Hide file tree
Showing 8 changed files with 860 additions and 426 deletions.
23 changes: 18 additions & 5 deletions google/cloud/storage/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,19 +599,32 @@ def _get_default_headers(
user_agent,
content_type="application/json; charset=UTF-8",
x_upload_content_type=None,
command=None,
):
"""Get the headers for a request.
Args:
user_agent (str): The user-agent for requests.
Returns:
Dict: The headers to be used for the request.
:type user_agent: str
:param user_agent: The user-agent for requests.
:type command: str
:param command:
(Optional) Information about which interface for the operation was
used, to be included in the X-Goog-API-Client header. Please leave
as None unless otherwise directed.
:rtype: dict
:returns: The headers to be used for the request.
"""
x_goog_api_client = f"{user_agent} {_get_invocation_id()}"

if command:
x_goog_api_client += f" gccl-gcs-cmd/{command}"

return {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate",
"User-Agent": user_agent,
"X-Goog-API-Client": f"{user_agent} {_get_invocation_id()}",
"X-Goog-API-Client": x_goog_api_client,
"content-type": content_type,
"x-upload-content-type": x_upload_content_type or content_type,
}

0 comments on commit 14a1909

Please sign in to comment.