Esempio n. 1
0
 def _get_value_for_special_type(self, shape, special_type_map):
     if is_json_value_header(shape):
         return special_type_map['jsonvalue_header']
     for special_type, marked_shape in self._context[
             'special_shape_types'].items():
         if special_type in special_type_map:
             if shape == marked_shape:
                 return special_type_map[special_type]
     return None
Esempio n. 2
0
def _unpack_cli_arg(argument_model, value, cli_name):
    if is_json_value_header(argument_model):
        return _unpack_json_cli_arg(argument_model, value, cli_name)
    elif argument_model.type_name in SCALAR_TYPES:
        return unpack_scalar_cli_arg(argument_model, value, cli_name)
    elif argument_model.type_name in COMPLEX_TYPES:
        return _unpack_complex_cli_arg(argument_model, value, cli_name)
    else:
        return six.text_type(value)
Esempio n. 3
0
 def _get_value_for_special_type(self, shape, special_type_map):
     if is_json_value_header(shape):
         return special_type_map['jsonvalue_header']
     for special_type, marked_shape in self._context[
             'special_shape_types'].items():
         if special_type in special_type_map:
             if shape == marked_shape:
                 return special_type_map[special_type]
     return None
Esempio n. 4
0
 def _get_argument_type_name(self, shape, default):
     if is_json_value_header(shape):
         return 'JSON'
     if is_document_type(shape):
         return 'document'
     if is_streaming_blob_type(shape):
         return 'streaming blob'
     if is_tagged_union_type(shape):
         return 'tagged union structure'
     return default
Esempio n. 5
0
def _unpack_cli_arg(argument_model, value, cli_name):
    if is_json_value_header(argument_model):
        return _unpack_json_cli_arg(argument_model, value, cli_name)
    elif argument_model.type_name in SCALAR_TYPES:
        return unpack_scalar_cli_arg(
            argument_model, value, cli_name)
    elif argument_model.type_name in COMPLEX_TYPES:
        return _unpack_complex_cli_arg(
            argument_model, value, cli_name)
    else:
        return six.text_type(value)
Esempio n. 6
0
 def _convert_header_value(self, shape, value):
     if shape.type_name == 'timestamp':
         datetime_obj = parse_to_aware_datetime(value)
         timestamp = calendar.timegm(datetime_obj.utctimetuple())
         return self._timestamp_rfc822(timestamp)
     elif is_json_value_header(shape):
         # Serialize with no spaces after separators to save space in
         # the header.
         return self._get_base64(json.dumps(value, separators=(',', ':')))
     else:
         return value
Esempio n. 7
0
 def _convert_header_value(self, shape, value):
     if shape.type_name == 'timestamp':
         datetime_obj = parse_to_aware_datetime(value)
         timestamp = calendar.timegm(datetime_obj.utctimetuple())
         return self._timestamp_rfc822(timestamp)
     elif is_json_value_header(shape):
         # Serialize with no spaces after separators to save space in
         # the header.
         return self._get_base64(json.dumps(value, separators=(',', ':')))
     else:
         return value
 def _convert_header_value(self, shape, value):
     if shape.type_name == 'timestamp':
         datetime_obj = parse_to_aware_datetime(value)
         timestamp = calendar.timegm(datetime_obj.utctimetuple())
         timestamp_format = shape.serialization.get(
             'timestampFormat', self.HEADER_TIMESTAMP_FORMAT)
         return self._convert_timestamp_to_str(timestamp, timestamp_format)
     elif is_json_value_header(shape):
         # Serialize with no spaces after separators to save space in
         # the header.
         return self._get_base64(json.dumps(value, separators=(',', ':')))
     else:
         return value
Esempio n. 9
0
 def _convert_header_value(self, shape, value):
     if shape.type_name == 'timestamp':
         datetime_obj = parse_to_aware_datetime(value)
         timestamp = calendar.timegm(datetime_obj.utctimetuple())
         timestamp_format = shape.serialization.get(
             'timestampFormat', self.HEADER_TIMESTAMP_FORMAT)
         return self._convert_timestamp_to_str(timestamp, timestamp_format)
     elif is_json_value_header(shape):
         # Serialize with no spaces after separators to save space in
         # the header.
         return self._get_base64(json.dumps(value, separators=(',', ':')))
     else:
         return value
Esempio n. 10
0
 def _check_special_validation_cases(self, shape):
     if is_json_value_header(shape):
         return self._validate_jsonvalue_string
     if shape.type_name == 'structure' and shape.is_document_type:
         return self._validate_document
 def _get_argument_type_name(self, shape, default):
     if is_json_value_header(shape):
         return 'JSON'
     if is_document_type(shape):
         return 'document'
     return default
Esempio n. 12
0
 def _handle_string(self, shape, value):
     parsed = value
     if is_json_value_header(shape):
         decoded = base64.b64decode(value).decode(self.DEFAULT_ENCODING)
         parsed = json.loads(decoded)
     return parsed
 def _check_special_validation_cases(self, shape):
     if is_json_value_header(shape):
         return self._validate_jsonvalue_string
Esempio n. 14
0
 def _get_argument_type_name(self, shape, default):
     if is_json_value_header(shape):
         return 'JSON'
     return default
Esempio n. 15
0
 def _check_special_validation_cases(self, shape):
     if is_json_value_header(shape):
         return self._validate_jsonvalue_string