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

Function index_hydrate

awscli/customizations/cloudsearch.py:31–68  ·  view source on GitHub ↗

Hydrate an index-field option value to construct something like:: { 'index_field': { 'DoubleOptions': { 'DefaultValue': 0.0 } } }

(params, container, cli_type, key, value)

Source from the content-addressed store, hash-verified

29
30
31def index_hydrate(params, container, cli_type, key, value):
32 """
33 Hydrate an index-field option value to construct something like::
34
35 {
36 'index_field': {
37 'DoubleOptions': {
38 'DefaultValue': 0.0
39 }
40 }
41 }
42 """
43 if 'IndexField' not in params:
44 params['IndexField'] = {}
45
46 if 'IndexFieldType' not in params['IndexField']:
47 raise ParamValidationError('You must pass the --type option.')
48
49 # Find the type and transform it for the type options field name
50 # E.g: int-array => IntArray
51 _type = params['IndexField']['IndexFieldType']
52 _type = ''.join([i.capitalize() for i in _type.split('-')])
53
54 # ``index_field`` of type ``latlon`` is mapped to ``Latlon``.
55 # However, it is defined as ``LatLon`` in the model so it needs to
56 # be changed.
57 if _type == 'Latlon':
58 _type = 'LatLon'
59
60 # Transform string value to the correct type?
61 if key.split(SEP)[-1] == 'DefaultValue':
62 value = DEFAULT_VALUE_TYPE_MAP.get(_type, lambda x: x)(value)
63
64 # Set the proper options field
65 if _type + 'Options' not in params['IndexField']:
66 params['IndexField'][_type + 'Options'] = {}
67
68 params['IndexField'][_type + 'Options'][key.split(SEP)[-1]] = value
69
70
71FLATTEN_CONFIG = {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected