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

Method _partition_parameters

awscli/botocore/serialize.py:876–925  ·  view source on GitHub ↗
(
        self, partitioned, param_name, param_value, shape_members
    )

Source from the content-addressed store, hash-verified

874 return body
875
876 def _partition_parameters(
877 self, partitioned, param_name, param_value, shape_members
878 ):
879 # This takes the user provided input parameter (``param``)
880 # and figures out where they go in the request dict.
881 # Some params are HTTP headers, some are used in the URI, some
882 # are in the request body. This method deals with this.
883 member = shape_members[param_name]
884 location = member.serialization.get('location')
885 key_name = member.serialization.get('name', param_name)
886 if location == 'uri':
887 uri_path_value = self._get_uri_and_query_string_value(
888 param_value, member
889 )
890 partitioned['uri_path_kwargs'][key_name] = uri_path_value
891 elif location == 'querystring':
892 if isinstance(param_value, dict):
893 partitioned['query_string_kwargs'].update(param_value)
894 elif member.type_name == 'list':
895 new_param = [
896 self._get_uri_and_query_string_value(value, member.member)
897 for value in param_value
898 ]
899 partitioned['query_string_kwargs'][key_name] = new_param
900 else:
901 new_param = self._get_uri_and_query_string_value(
902 param_value, member
903 )
904 partitioned['query_string_kwargs'][key_name] = new_param
905 elif location == 'header':
906 shape = shape_members[param_name]
907 if not param_value and shape.type_name == 'list':
908 # Empty lists should not be set on the headers
909 return
910 partitioned['headers'][key_name] = self._convert_header_value(
911 shape, param_value
912 )
913 elif location == 'headers':
914 # 'headers' is a bit of an oddball. The ``key_name``
915 # is actually really a prefix for the header names:
916 header_prefix = key_name
917 # The value provided by the user is a dict so we'll be
918 # creating multiple header key/val pairs. The key
919 # name to use for each header is the header_prefix (``key_name``)
920 # plus the key provided by the user.
921 self._do_serialize_header_map(
922 header_prefix, partitioned['headers'], param_value
923 )
924 else:
925 partitioned['body_kwargs'][param_name] = param_value
926
927 def _get_uri_and_query_string_value(self, param_value, member):
928 if member.type_name == 'boolean':

Callers 1

serialize_to_requestMethod · 0.95

Calls 4

_convert_header_valueMethod · 0.95
updateMethod · 0.45

Tested by

no test coverage detected