@@ -282,6 +282,7 @@ def _make_request(
282282 headers = None ,
283283 target_object = None ,
284284 timeout = _DEFAULT_TIMEOUT ,
285+ extra_api_info = None ,
285286 ):
286287 """A low level method to send a request to the API.
287288
@@ -317,6 +318,10 @@ def _make_request(
317318 Can also be passed as a tuple (connect_timeout, read_timeout).
318319 See :meth:`requests.Session.request` documentation for details.
319320
321+ :type extra_api_info: string
322+ :param extra_api_info: (optional) Extra api info to be appended to
323+ the X-Goog-API-Client header
324+
320325 :rtype: :class:`requests.Response`
321326 :returns: The HTTP response.
322327 """
@@ -327,7 +332,10 @@ def _make_request(
327332 if content_type :
328333 headers ["Content-Type" ] = content_type
329334
330- headers [CLIENT_INFO_HEADER ] = self .user_agent
335+ if extra_api_info :
336+ headers [CLIENT_INFO_HEADER ] = f"{ self .user_agent } { extra_api_info } "
337+ else :
338+ headers [CLIENT_INFO_HEADER ] = self .user_agent
331339 headers ["User-Agent" ] = self .user_agent
332340
333341 return self ._do_request (
@@ -385,6 +393,7 @@ def api_request(
385393 expect_json = True ,
386394 _target_object = None ,
387395 timeout = _DEFAULT_TIMEOUT ,
396+ extra_api_info = None ,
388397 ):
389398 """Make a request over the HTTP transport to the API.
390399
@@ -446,6 +455,10 @@ def api_request(
446455 Can also be passed as a tuple (connect_timeout, read_timeout).
447456 See :meth:`requests.Session.request` documentation for details.
448457
458+ :type extra_api_info: string
459+ :param extra_api_info: (optional) Extra api info to be appended to
460+ the X-Goog-API-Client header
461+
449462 :raises ~google.cloud.exceptions.GoogleCloudError: if the response code
450463 is not 200 OK.
451464 :raises ValueError: if the response content type is not JSON.
@@ -474,6 +487,7 @@ def api_request(
474487 headers = headers ,
475488 target_object = _target_object ,
476489 timeout = timeout ,
490+ extra_api_info = extra_api_info ,
477491 )
478492
479493 if not 200 <= response .status_code < 300 :
0 commit comments