MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / request

Method request

googleapiclient/model.py:132–182  ·  view source on GitHub ↗

Updates outgoing requests with a serialized body. Args: headers: dict, request headers path_params: dict, parameters that appear in the request path query_params: dict, parameters that appear in the query body_value: object, the request body as a Pyth

(self, headers, path_params, query_params, body_value, api_version=None)

Source from the content-addressed store, hash-verified

130 LOGGER.info("--request-end--")
131
132 def request(self, headers, path_params, query_params, body_value, api_version=None):
133 """Updates outgoing requests with a serialized body.
134
135 Args:
136 headers: dict, request headers
137 path_params: dict, parameters that appear in the request path
138 query_params: dict, parameters that appear in the query
139 body_value: object, the request body as a Python object, which must be
140 serializable by json.
141 api_version: str, The precise API version represented by this request,
142 which will result in an API Version header being sent along with the
143 HTTP request.
144 Returns:
145 A tuple of (headers, path_params, query, body)
146
147 headers: dict, request headers
148 path_params: dict, parameters that appear in the request path
149 query: string, query part of the request URI
150 body: string, the body serialized as JSON
151 """
152 query = self._build_query(query_params)
153 headers["accept"] = self.accept
154 headers["accept-encoding"] = "gzip, deflate"
155 if "user-agent" in headers:
156 headers["user-agent"] += " "
157 else:
158 headers["user-agent"] = ""
159 headers["user-agent"] += "(gzip)"
160 if "x-goog-api-client" in headers:
161 headers["x-goog-api-client"] += " "
162 else:
163 headers["x-goog-api-client"] = ""
164 headers["x-goog-api-client"] += "gdcl/%s gl-python/%s" % (
165 _LIBRARY_VERSION,
166 _PY_VERSION,
167 )
168
169 if api_version and HAS_API_VERSION:
170 headers[API_VERSION_METADATA_KEY] = api_version
171 elif api_version:
172 warnings.warn(
173 "The `api_version` argument is ignored as a newer version of "
174 "`google-api-core` is required to use this feature."
175 "Please upgrade `google-api-core` to 2.19.0 or newer."
176 )
177
178 if body_value is not None:
179 headers["content-type"] = self.content_type
180 body_value = self.serialize(body_value)
181 self._log_request(headers, path_params, query, body_value)
182 return (headers, path_params, query, body_value)
183
184 def _build_query(self, params):
185 """Builds a query string.

Callers

nothing calls this directly

Calls 3

_build_queryMethod · 0.95
serializeMethod · 0.95
_log_requestMethod · 0.95

Tested by

no test coverage detected