Flatten arguments for one or more commands for a particular service from a given configuration which maps service call parameters to flattened names. Takes in a configuration dict of the form:: { "command-cli-name": { "argument-cli-name": {
| 97 | |
| 98 | |
| 99 | class FlattenArguments: |
| 100 | """ |
| 101 | Flatten arguments for one or more commands for a particular service from |
| 102 | a given configuration which maps service call parameters to flattened |
| 103 | names. Takes in a configuration dict of the form:: |
| 104 | |
| 105 | { |
| 106 | "command-cli-name": { |
| 107 | "argument-cli-name": { |
| 108 | "keep": False, |
| 109 | "flatten": { |
| 110 | "XmlName": { |
| 111 | "name": "flattened-cli-name", |
| 112 | "type": "Optional custom type", |
| 113 | "required": "Optional custom required", |
| 114 | "help_text": "Optional custom docs", |
| 115 | "hydrate_value": Optional function to hydrate value, |
| 116 | "hydrate": Optional function to hydrate |
| 117 | }, |
| 118 | ... |
| 119 | } |
| 120 | }, |
| 121 | ... |
| 122 | }, |
| 123 | ... |
| 124 | } |
| 125 | |
| 126 | The ``type``, ``required`` and ``help_text`` arguments are entirely |
| 127 | optional and by default are pulled from the model. You should only set them |
| 128 | if you wish to override the default values in the model. |
| 129 | |
| 130 | The ``keep`` argument determines whether the original command is still |
| 131 | accessible vs. whether it is removed. It defaults to ``False`` if not |
| 132 | present, which removes the original argument. |
| 133 | |
| 134 | The keys inside of ``flatten`` (e.g. ``XmlName`` above) can include nested |
| 135 | references to structures via a colon. For example, ``XmlName1:XmlName2`` |
| 136 | for the following structure:: |
| 137 | |
| 138 | { |
| 139 | "XmlName1": { |
| 140 | "XmlName2": ... |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | The ``hydrate_value`` function takes in a value and should return a value. |
| 145 | It is only called when the value is not ``None``. Example:: |
| 146 | |
| 147 | "hydrate_value": lambda (value): value.upper() |
| 148 | |
| 149 | The ``hydrate`` function takes in a list of existing parameters, the name |
| 150 | of the container, its type, the name of the container key and its set |
| 151 | value. For the example above, the container would be |
| 152 | ``'argument-cli-name'``, the key would be ``'XmlName'`` and the value |
| 153 | whatever the user passed in. Example:: |
| 154 | |
| 155 | def my_hydrate(params, container, cli_type, key, value): |
| 156 | if container not in params: |
no outgoing calls