3030
3131from googleapiclient import version as googleapiclient_version
3232from googleapiclient .errors import HttpError
33+ from google .api_core .gapic_v1 .version_header import API_VERSION_METADATA_KEY
3334
3435_LIBRARY_VERSION = googleapiclient_version .__version__
3536_PY_VERSION = platform .python_version ()
@@ -121,15 +122,18 @@ def _log_request(self, headers, path_params, query, body):
121122 LOGGER .info ("query: %s" , query )
122123 LOGGER .info ("--request-end--" )
123124
124- def request (self , headers , path_params , query_params , body_value ):
125+ def request (self , headers , path_params , query_params , body_value , api_version = None ):
125126 """Updates outgoing requests with a serialized body.
126127
127128 Args:
128129 headers: dict, request headers
129130 path_params: dict, parameters that appear in the request path
130131 query_params: dict, parameters that appear in the query
131132 body_value: object, the request body as a Python object, which must be
132- serializable by json.
133+ serializable by json.
134+ api_version: str, The precise API version represented by this request,
135+ which will result in an API Version header being sent along with the
136+ HTTP request.
133137 Returns:
134138 A tuple of (headers, path_params, query, body)
135139
@@ -154,6 +158,8 @@ def request(self, headers, path_params, query_params, body_value):
154158 _LIBRARY_VERSION ,
155159 _PY_VERSION ,
156160 )
161+ if api_version :
162+ headers [API_VERSION_METADATA_KEY ] = api_version
157163
158164 if body_value is not None :
159165 headers ["content-type" ] = self .content_type
0 commit comments