示例#1
0
    def __init__(self, name, start, id=None, actions=None, branches=None):
        """Initializes a Workflow object. A Workflow falls under a Playbook, and has many associated Actions
            within it that get executed.
        Args:
            name (str): The name of the Workflow object.
            start (int): ID of the starting Action.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            actions (list[Action]): Optional Action objects. Defaults to None.
            branches (list[Branch], optional): A list of Branch objects for the Workflow object. Defaults to None.
        """
        ExecutionElement.__init__(self, id)
        self.name = name
        self.actions = actions if actions else []
        self.branches = branches if branches else []

        self.start = start

        self._is_paused = False
        self._abort = False
        self._accumulator = {}
        self._execution_id = 'default'
        self._instance_repo = None

        self.validate()
示例#2
0
    def __init__(self,
                 name,
                 start,
                 id=None,
                 actions=None,
                 branches=None,
                 environment_variables=None):
        """Initializes a Workflow object. A Workflow falls under a Playbook, and has many associated Actions
            within it that get executed.

        Args:
            name (str): The name of the Workflow object.
            start (int): ID of the starting Action.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            actions (list[Action]): Optional Action objects. Defaults to None.
            branches (list[Branch], optional): A list of Branch objects for the Workflow object. Defaults to None.
            environment_variables (list[EnvironmentVariable], optional): A list of environment variables for the
                Workflow. Defaults to None.
        """
        ExecutionElement.__init__(self, id)
        self.name = name
        self.actions = actions if actions else []
        self.branches = branches if branches else []
        self.environment_variables = environment_variables if environment_variables else []

        self.start = start

        self.validate()
示例#3
0
    def __init__(self,
                 source_id,
                 destination_id,
                 id=None,
                 status='Success',
                 condition=None,
                 priority=999):
        """Initializes a new Branch object.
        
        Args:
            source_id (int): The ID of the source action that will be sending inputs to this Branch.
            destination_id (int): The ID of the destination action that will be returned if the conditions for this
                Branch are met.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            status (str, optional): Optional field to keep track of the status of the Branch. Defaults to
                "Success".
            condition (ConditionalExpression, optional): The condition which must be fulfilled for this branch.
                Defaults to None.
            priority (int, optional): Optional priority parameter to specify which Branch in the Workflow's
                list of Branches should be executed if multiple have conditions resulting to True.
                Defaults to 999 (lowest priority).
        """
        ExecutionElement.__init__(self, id)
        self.source_id = source_id
        self.destination_id = destination_id
        self.status = status
        self.priority = priority
        self.condition = condition

        self.validate()
示例#4
0
    def __init__(self, app_name, action_name, id=None, is_negated=False, arguments=None, transforms=None, errors=None):
        """Initializes a new Condition object.

        Args:
            app_name (str): The name of the app which contains this condition
            action_name (str): The action name for the Condition. Defaults to an empty string.
            id (str|UUID, optional): Optional UUID to pass into the Condition. Must be UUID object or valid UUID string.
                Defaults to None.
            is_negated (bool, optional): Should the result of the condition be inverted? Defaults to False.
            arguments (list[Argument], optional): Dictionary of Argument keys to Argument values.
                This dictionary will be converted to a dictionary of str:Argument. Defaults to None.
            transforms(list[Transform], optional): A list of Transform objects for the Condition object.
                Defaults to None.
        """
        ExecutionElement.__init__(self, id, errors)
        self.app_name = app_name
        self.action_name = action_name
        self.is_negated = is_negated

        self.arguments = []
        if arguments:
            self.arguments = arguments

        self.transforms = []
        if transforms:
            self.transforms = transforms

        self._data_param_name = None
        self._api = None
        self._condition_executable = None

        self.validate()
示例#5
0
    def __init__(self,
                 operator='and',
                 id=None,
                 is_negated=False,
                 child_expressions=None,
                 conditions=None,
                 errors=None):
        """Initializes a new ConditionalExpression object

        Args:
            operator (and|or|xor, optional): The operator to be used between the conditions. Defaults to 'and'.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            is_negated(bool, optional): Whether or not the expression should be negated. Defaults to False.
            child_expressions (list[ConditionalExpression], optional): Child ConditionalExpression objects for this
                object. Defaults to None.
            conditions (list[Condition], optional): Condition objects for this object. Defaults to None.
        """
        ExecutionElement.__init__(self, id, errors)
        self.operator = operator
        self.is_negated = is_negated
        if child_expressions:
            self._construct_children(child_expressions)
        self.child_expressions = child_expressions if child_expressions is not None else []
        self.conditions = conditions if conditions is not None else []
        self.__operator_lookup = {
            'and': self._and,
            'or': self._or,
            'xor': self._xor
        }

        self.validate()
示例#6
0
    def __init__(self, app_name, action_name, id=None, arguments=None):
        """Initializes a new Transform object. A Transform is used to transform input into a workflow.

        Args:
            app_name (str): The app name associated with this transform
            action_name (str): The action name for the transform.
            id (str|UUID, optional): Optional UUID to pass into the Transform. Must be UUID object or valid UUID string.
                Defaults to None.
            arguments (list[Argument], optional): Dictionary of Argument keys to Argument values.
                This dictionary will be converted to a dictionary of str:Argument. Defaults to None.
        """
        ExecutionElement.__init__(self, id)
        self.app_name = app_name
        self.action_name = action_name

        self._data_param_name = None
        self._run = None
        self._api = None

        self.arguments = []
        if arguments:
            self.arguments = arguments

        self.validate()
        self._transform_executable = get_transform(self.app_name, self._run)
示例#7
0
    def __init__(self,
                 app_name,
                 action_name,
                 name,
                 device_id=None,
                 id=None,
                 arguments=None,
                 trigger=None,
                 position=None):
        """Initializes a new Action object. A Workflow has one or more actions that it executes.
        Args:
            app_name (str): The name of the app associated with the Action
            action_name (str): The name of the action associated with a Action
            name (str): The name of the Action object.
            device_id (Argument, optional): The device_id for the Action. This device_id is specified in the Argument
                object. If the device_id should be static, then device_id.value should be set to the static device_id.
                If the device_id should be fetched from a previous Action, then the reference and optional selection
                fields of the Argument object should be filled. Defaults to None.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            arguments (list[Argument], optional): A list of Argument objects that are parameters to the action.
                Defaults to None.
            trigger (ConditionalExpression, optional): A ConditionalExpression which causes an Action to wait until the
                data is sent fulfilling the condition. Defaults to None.
            position (Position, optional): Position object for the Action. Defaults to None.
        """
        ExecutionElement.__init__(self, id)

        self.trigger = trigger

        self.name = name
        self.device_id = device_id
        self.app_name = app_name
        self.action_name = action_name

        self.arguments = []
        if arguments:
            self.arguments = arguments

        self.position = position

        self._run = None
        self._arguments_api = None
        self._output = None
        self._execution_id = 'default'
        self._action_executable = None
        self._resolved_device_id = -1
        self.validate()
示例#8
0
    def __init__(self, name, workflows=None, id=None):
        """Creates a Playbook object.

        Args:
            name (str): The name of the Playbook
            workflows (list[Workflow], optional): An optional list of Workflows associated with this Playbook.
                Defaults to None.
            id (str|UUID, optional): Optional UUID to pass into the Playbook. Must be UUID object or valid UUID string.
                Defaults to None.
        """
        ExecutionElement.__init__(self, id)
        self.name = name
        if workflows:
            self.workflows = workflows

        self.validate()
示例#9
0
    def __init__(self, name, workflows=None, id=None, errors=None):
        """Creates a Playbook object.

        Args:
            name (str): The name of the Playbook
            workflows (list[Workflow], optional): An optional list of Workflows associated with this Playbook.
                Defaults to None.
            id (str|UUID, optional): Optional UUID to pass into the Playbook. Must be UUID object or valid UUID string.
                Defaults to None.
        """
        ExecutionElement.__init__(self, id, errors)
        self.name = name
        if workflows:
            self.workflows = workflows

        self.validate()
示例#10
0
    def __init__(self,
                 app_name,
                 action_name,
                 name,
                 device_id=None,
                 id=None,
                 arguments=None,
                 trigger=None,
                 position=None):
        """Initializes a new Action object. A Workflow has one or more actions that it executes.
        Args:
            app_name (str): The name of the app associated with the Action
            action_name (str): The name of the action associated with a Action
            name (str): The name of the Action object.
            device_id (int, optional): The id of the device associated with the app associated with the Action. Defaults
                to None.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            arguments (list[Argument], optional): A list of Argument objects that are parameters to the action.
                Defaults to None.
            trigger (ConditionalExpression, optional): A ConditionalExpression which causes an Action to wait until the
                data is sent fulfilling the condition. Defaults to None.
            position (Position, optional): Position object for the Action. Defaults to None.
        """
        ExecutionElement.__init__(self, id)

        self.trigger = trigger

        self.name = name
        self.device_id = device_id
        self.app_name = app_name
        self.action_name = action_name

        self.arguments = []
        if arguments:
            self.arguments = arguments

        self.position = position

        self._run = None
        self._arguments_api = None
        self._output = None
        self._execution_id = 'default'

        self.validate()
        self._action_executable = get_app_action(self.app_name, self._run)
示例#11
0
文件: action.py 项目: iadgov/WALKOFF
    def __init__(self, app_name, action_name, name, device_id=None, id=None, arguments=None, trigger=None,
                 position=None, errors=None):
        """Initializes a new Action object. A Workflow has one or more actions that it executes.
        Args:
            app_name (str): The name of the app associated with the Action
            action_name (str): The name of the action associated with a Action
            name (str): The name of the Action object.
            device_id (Argument, optional): The device_id for the Action. This device_id is specified in the Argument
                object. If the device_id should be static, then device_id.value should be set to the static device_id.
                If the device_id should be fetched from a previous Action, then the reference and optional selection
                fields of the Argument object should be filled. Defaults to None.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            arguments (list[Argument], optional): A list of Argument objects that are parameters to the action.
                Defaults to None.
            trigger (ConditionalExpression, optional): A ConditionalExpression which causes an Action to wait until the
                data is sent fulfilling the condition. Defaults to None.
            position (Position, optional): Position object for the Action. Defaults to None.
        """
        ExecutionElement.__init__(self, id, errors)

        self.trigger = trigger

        self.name = name
        self.device_id = device_id
        self.app_name = app_name
        self.action_name = action_name

        self.arguments = []
        if arguments:
            self.arguments = arguments

        self.position = position

        self._run = None
        self._arguments_api = None
        self._last_status = None
        self._execution_id = 'default'
        self._resolved_device_id = -1
        self.validate()
示例#12
0
    def __init__(self, app_name, action_name, id=None, arguments=None, errors=None):
        """Initializes a new Transform object. A Transform is used to transform input into a workflow.

        Args:
            app_name (str): The app name associated with this transform
            action_name (str): The action name for the transform.
            id (str|UUID, optional): Optional UUID to pass into the Transform. Must be UUID object or valid UUID string.
                Defaults to None.
            arguments (list[Argument], optional): Dictionary of Argument keys to Argument values.
                This dictionary will be converted to a dictionary of str:Argument. Defaults to None.
        """
        ExecutionElement.__init__(self, id, errors)
        self.app_name = app_name
        self.action_name = action_name

        self._data_param_name = None
        self._api = None

        self.arguments = []
        if arguments:
            self.arguments = arguments
        self.validate()
示例#13
0
    def __init__(self, name, start, id=None, actions=None, branches=None, environment_variables=None, errors=None):
        """Initializes a Workflow object. A Workflow falls under a Playbook, and has many associated Actions
            within it that get executed.

        Args:
            name (str): The name of the Workflow object.
            start (int): ID of the starting Action.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            actions (list[Action]): Optional Action objects. Defaults to None.
            branches (list[Branch], optional): A list of Branch objects for the Workflow object. Defaults to None.
            environment_variables (list[EnvironmentVariable], optional): A list of environment variables for the
                Workflow. Defaults to None.
        """
        ExecutionElement.__init__(self, id, errors)
        self.name = name
        self.actions = actions if actions else []
        self.branches = branches if branches else []
        self.environment_variables = environment_variables if environment_variables else []

        self.start = start

        self.validate()
示例#14
0
    def __init__(self, operator='and', id=None, is_negated=False, child_expressions=None, conditions=None, errors=None):
        """Initializes a new ConditionalExpression object

        Args:
            operator (and|or|xor, optional): The operator to be used between the conditions. Defaults to 'and'.
            id (str|UUID, optional): Optional UUID to pass into the Action. Must be UUID object or valid UUID string.
                Defaults to None.
            is_negated(bool, optional): Whether or not the expression should be negated. Defaults to False.
            child_expressions (list[ConditionalExpression], optional): Child ConditionalExpression objects for this
                object. Defaults to None.
            conditions (list[Condition], optional): Condition objects for this object. Defaults to None.
        """
        ExecutionElement.__init__(self, id, errors)
        self.operator = operator
        self.is_negated = is_negated
        if child_expressions:
            self._construct_children(child_expressions)
        self.child_expressions = child_expressions if child_expressions is not None else []
        self.conditions = conditions if conditions is not None else []
        self.__operator_lookup = {'and': self._and,
                                  'or': self._or,
                                  'xor': self._xor}

        self.validate()