in awscli/customizations/cloudsearch.py [0:0]
def index_hydrate(params, container, cli_type, key, value):
"""
Hydrate an index-field option value to construct something like::
{
'index_field': {
'DoubleOptions': {
'DefaultValue': 0.0
}
}
}
"""
if 'IndexField' not in params:
params['IndexField'] = {}
if 'IndexFieldType' not in params['IndexField']:
raise RuntimeError('You must pass the --type option.')
# Find the type and transform it for the type options field name
# E.g: int-array => IntArray
_type = params['IndexField']['IndexFieldType']
_type = ''.join([i.capitalize() for i in _type.split('-')])
# ``index_field`` of type ``latlon`` is mapped to ``Latlon``.
# However, it is defined as ``LatLon`` in the model so it needs to
# be changed.
if _type == 'Latlon':
_type = 'LatLon'
# Transform string value to the correct type?
if key.split(SEP)[-1] == 'DefaultValue':
value = DEFAULT_VALUE_TYPE_MAP.get(_type, lambda x: x)(value)
# Set the proper options field
if _type + 'Options' not in params['IndexField']:
params['IndexField'][_type + 'Options'] = {}
params['IndexField'][_type + 'Options'][key.split(SEP)[-1]] = value