MCPcopy Create free account
hub / github.com/aws/aws-cli / prepare_request_dict

Function prepare_request_dict

awscli/botocore/awsrequest.py:251–289  ·  view source on GitHub ↗

This method prepares a request dict to be created into an AWSRequestObject. This prepares the request dict by adding the url and the user agent to the request dict. :type request_dict: dict :param request_dict: The request dict (created from the ``serialize`` module).

(
    request_dict, endpoint_url, context=None, user_agent=None
)

Source from the content-addressed store, hash-verified

249
250
251def prepare_request_dict(
252 request_dict, endpoint_url, context=None, user_agent=None
253):
254 """
255 This method prepares a request dict to be created into an
256 AWSRequestObject. This prepares the request dict by adding the
257 url and the user agent to the request dict.
258
259 :type request_dict: dict
260 :param request_dict: The request dict (created from the
261 ``serialize`` module).
262
263 :type user_agent: string
264 :param user_agent: The user agent to use for this request.
265
266 :type endpoint_url: string
267 :param endpoint_url: The full endpoint url, which contains at least
268 the scheme, the hostname, and optionally any path components.
269 """
270 r = request_dict
271 if user_agent is not None:
272 headers = r['headers']
273 headers['User-Agent'] = user_agent
274 host_prefix = r.get('host_prefix')
275 url = _urljoin(endpoint_url, r['url_path'], host_prefix)
276 if r['query_string']:
277 # NOTE: This is to avoid circular import with utils. This is being
278 # done to avoid moving classes to different modules as to not cause
279 # breaking chainges.
280 percent_encode_sequence = botocore.utils.percent_encode_sequence
281 encoded_query_string = percent_encode_sequence(r['query_string'])
282 if '?' not in url:
283 url += f'?{encoded_query_string}'
284 else:
285 url += f'&{encoded_query_string}'
286 r['url'] = url
287 r['context'] = context
288 if context is None:
289 r['context'] = {}
290
291
292def create_request_object(request_dict):

Callers 5

_assert_endpoints_equalFunction · 0.90
generate_db_auth_tokenFunction · 0.90

Calls 2

_urljoinFunction · 0.85
percent_encode_sequenceFunction · 0.85

Tested by 2

_assert_endpoints_equalFunction · 0.72