(self, parameters, operation_model)
| 733 | KNOWN_LOCATIONS = ['uri', 'querystring', 'header', 'headers'] |
| 734 | |
| 735 | def serialize_to_request(self, parameters, operation_model): |
| 736 | serialized = self._create_default_request() |
| 737 | serialized['method'] = operation_model.http.get( |
| 738 | 'method', self.DEFAULT_METHOD |
| 739 | ) |
| 740 | shape = operation_model.input_shape |
| 741 | |
| 742 | host_prefix = self._expand_host_prefix(parameters, operation_model) |
| 743 | if host_prefix is not None: |
| 744 | serialized['host_prefix'] = host_prefix |
| 745 | |
| 746 | if shape is None: |
| 747 | serialized['url_path'] = operation_model.http['requestUri'] |
| 748 | return serialized |
| 749 | shape_members = shape.members |
| 750 | # While the ``serialized`` key holds the final serialized request |
| 751 | # data, we need interim dicts for the various locations of the |
| 752 | # request. We need this for the uri_path_kwargs and the |
| 753 | # query_string_kwargs because they are templated, so we need |
| 754 | # to gather all the needed data for the string template, |
| 755 | # then we render the template. The body_kwargs is needed |
| 756 | # because once we've collected them all, we run them through |
| 757 | # _serialize_body_params, which for rest-json, creates JSON, |
| 758 | # and for rest-xml, will create XML. This is what the |
| 759 | # ``partitioned`` dict below is for. |
| 760 | partitioned = { |
| 761 | 'uri_path_kwargs': self.MAP_TYPE(), |
| 762 | 'query_string_kwargs': self.MAP_TYPE(), |
| 763 | 'body_kwargs': self.MAP_TYPE(), |
| 764 | 'headers': self.MAP_TYPE(), |
| 765 | } |
| 766 | for param_name, param_value in parameters.items(): |
| 767 | if param_value is None: |
| 768 | # Don't serialize any parameter with a None value. |
| 769 | continue |
| 770 | self._partition_parameters( |
| 771 | partitioned, param_name, param_value, shape_members |
| 772 | ) |
| 773 | serialized['url_path'] = self._render_uri_template( |
| 774 | operation_model.http['requestUri'], partitioned['uri_path_kwargs'] |
| 775 | ) |
| 776 | |
| 777 | if 'authPath' in operation_model.http: |
| 778 | serialized['auth_path'] = self._render_uri_template( |
| 779 | operation_model.http['authPath'], |
| 780 | partitioned['uri_path_kwargs'], |
| 781 | ) |
| 782 | # Note that we lean on the http implementation to handle the case |
| 783 | # where the requestUri path already has query parameters. |
| 784 | # The bundled http client, requests, already supports this. |
| 785 | serialized['query_string'] = partitioned['query_string_kwargs'] |
| 786 | if partitioned['headers']: |
| 787 | serialized['headers'] = partitioned['headers'] |
| 788 | self._serialize_payload( |
| 789 | partitioned, parameters, serialized, shape, shape_members |
| 790 | ) |
| 791 | self._serialize_content_type(serialized, shape, shape_members) |
| 792 |
nothing calls this directly
no test coverage detected