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

Function update_query_params

googleapiclient/_helpers.py:166–188  ·  view source on GitHub ↗

Updates a URI with new query parameters. If a given key from ``params`` is repeated in the ``uri``, then the URI will be considered invalid and an error will occur. If the URI is valid, then each value from ``params`` will replace the corresponding value in the query parameters (if

(uri, params)

Source from the content-addressed store, hash-verified

164
165
166def update_query_params(uri, params):
167 """Updates a URI with new query parameters.
168
169 If a given key from ``params`` is repeated in the ``uri``, then
170 the URI will be considered invalid and an error will occur.
171
172 If the URI is valid, then each value from ``params`` will
173 replace the corresponding value in the query parameters (if
174 it exists).
175
176 Args:
177 uri: string, A valid URI, with potential existing query parameters.
178 params: dict, A dictionary of query parameters.
179
180 Returns:
181 The same URI but with the new query parameters added.
182 """
183 parts = urllib.parse.urlparse(uri)
184 query_params = parse_unique_urlencoded(parts.query)
185 query_params.update(params)
186 new_query = urllib.parse.urlencode(query_params)
187 new_parts = parts._replace(query=new_query)
188 return urllib.parse.urlunparse(new_parts)
189
190
191def _add_query_parameter(url, name, value):

Callers 1

_add_query_parameterFunction · 0.85

Calls 2

parse_unique_urlencodedFunction · 0.85
updateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…