def parse(self, request: HttpRequest) -> Tuple[OperationModel, Any]: body = request.get_data(as_text=True) instance = parse_qs(body, keep_blank_values=True) if not instance: # if the body does not contain any information, fallback to the actual query parameters instance = request.args # The query parsing returns a list for each entry in the dict (this is how HTTP handles lists in query params). # However, the AWS Query format does not have any duplicates. # Therefore we take the first element of each entry in the dict. instance = {k: self._get_first(v) for k, v in instance.items()} if "Action" not in instance: raise ProtocolParserError( f"Operation detection failed. " f"Missing Action in request for query-protocol service {self.service}." ) action = instance["Action"] try: operation: OperationModel = self.service.operation_model(action) except OperationNotFoundError as e: raise OperationNotFoundParserError( f"Operation detection failed." f"Operation {action} could not be found for service {self.service}." ) from e # There are no uri params in the query protocol (all ops are POST on "/") uri_params = {} input_shape: StructureShape = operation.input_shape parsed = self._parse_shape(request, input_shape, instance, uri_params) if parsed is None: return operation, {} return operation, parsed
def parse(self, request: HttpRequest) -> Tuple[OperationModel, Any]: body = request.get_data(as_text=True) instance = parse_qs(body, keep_blank_values=True) # The query parsing returns a list for each entry in the dict (this is how HTTP handles lists in query params). # However, the AWS Query format does not have any duplicates. # Therefore we take the first element of each entry in the dict. instance = {k: self._get_first(v) for k, v in instance.items()} operation: OperationModel = self.service.operation_model( instance["Action"]) input_shape: StructureShape = operation.input_shape return operation, self._parse_shape(request, input_shape, instance)