def _setup_action_parameters()

in source/code/builders/action_template_builder.py [0:0]


    def _setup_action_parameters(self):
        """
        Creates the action specific parameters from its metadata
        :return: 
        """

        def setup_action_parameter_groups():
            """
            Action parameter groups
            :return: 
            """
            for group in self.action_properties.get(actions.ACTION_PARAMETER_GROUPS, []):
                self._parameter_groups.append({
                    "Label": {
                        "default": group.get(actions.ACTION_PARAMETER_GROUP_TITLE, "")
                    },
                    "Parameters": group.get(actions.ACTION_PARAMETER_GROUP_LIST)
                })

        def setup_action_parameter(name, action_parameter):
            # single action parameter setup
            parameter_template = {}

            # parameter type
            parameter_type = action_parameter[actions.PARAM_TYPE]

            if action_parameter.get(actions.PARAM_TYPE_AWS, None):
                parameter_template["Type"] = action_parameter[actions.PARAM_TYPE_AWS]
            else:
                if parameter_type in [int, int, float, Decimal]:
                    parameter_template["Type"] = "Number"
                elif isinstance([], parameter_type):
                    parameter_template["Type"] = "CommaDelimitedList"
                else:
                    parameter_template["Type"] = "String"
                    if action_parameter.get(actions.PARAM_REQUIRED, False) and actions.PARAM_MIN_LEN not in action_parameter:
                        parameter_template[actions.PARAM_MIN_LEN] = 1
                    # default allowed values for booleans
                    if parameter_type == bool:
                        parameter_template["AllowedValues"] = YES_NO

            # for every parameter option...
            for p in PARAM_OPTIONS:
                if p in action_parameter:

                    if p == actions.PARAM_ALLOWED_VALUES and action_parameter[p] in [[], None, ""]:
                        continue

                    if p == actions.PARAM_DEFAULT and parameter_type in [bool]:
                        value = TaskConfiguration.as_boolean(action_parameter[actions.PARAM_DEFAULT])
                        parameter_template[p] = YES if value else NO
                    else:
                        if isinstance(action_parameter[p], type([])):
                            parameter_template[p] = action_parameter[p]
                        else:
                            parameter_template[p] = str(action_parameter[p])

                    if p == actions.PARAM_DESCRIPTION:
                        parameter_template[p] = parameter_template[p] \
                            .replace("{ops-automator-role}", self.ops_automator_role) \
                            .replace("{region}", self.region) \
                            .replace("{account}", self.aws_account) \
                            .replace("{config-bucket}", self.config_bucket)

            # add parameter to template
            self._template_parameters[name] = parameter_template

            # add label
            if actions.PARAM_LABEL in action_parameter:
                self._parameter_labels[name] = {"default": action_parameter[actions.PARAM_LABEL]}

        # setup all parameters for an action
        for parameter_name, parameter in self.action_properties.get(actions.ACTION_PARAMETERS, {}).items():
            # Parameters cab be marked as hidden, no UI is generated
            if parameter.get(actions.PARAM_HIDDEN, False):
                continue
            setup_action_parameter(parameter_name, parameter)

        setup_action_parameter_groups()