Skip to content

Commit 14a1909

Browse files
authored
feat: add gccl-gcs-cmd field to X-Goog-API-Client header for Transfer Manager calls (#1119)
1 parent 56aeb87 commit 14a1909

File tree

8 files changed

+860
-426
lines changed

8 files changed

+860
-426
lines changed

google/cloud/storage/_helpers.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,19 +599,32 @@ def _get_default_headers(
599599
user_agent,
600600
content_type="application/json; charset=UTF-8",
601601
x_upload_content_type=None,
602+
command=None,
602603
):
603604
"""Get the headers for a request.
604605
605-
Args:
606-
user_agent (str): The user-agent for requests.
607-
Returns:
608-
Dict: The headers to be used for the request.
606+
:type user_agent: str
607+
:param user_agent: The user-agent for requests.
608+
609+
:type command: str
610+
:param command:
611+
(Optional) Information about which interface for the operation was
612+
used, to be included in the X-Goog-API-Client header. Please leave
613+
as None unless otherwise directed.
614+
615+
:rtype: dict
616+
:returns: The headers to be used for the request.
609617
"""
618+
x_goog_api_client = f"{user_agent} {_get_invocation_id()}"
619+
620+
if command:
621+
x_goog_api_client += f" gccl-gcs-cmd/{command}"
622+
610623
return {
611624
"Accept": "application/json",
612625
"Accept-Encoding": "gzip, deflate",
613626
"User-Agent": user_agent,
614-
"X-Goog-API-Client": f"{user_agent} {_get_invocation_id()}",
627+
"X-Goog-API-Client": x_goog_api_client,
615628
"content-type": content_type,
616629
"x-upload-content-type": x_upload_content_type or content_type,
617630
}

0 commit comments

Comments
 (0)