예제 #1
0
파일: condition.py 프로젝트: iadgov/WALKOFF
    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()
예제 #2
0
파일: playbook.py 프로젝트: iadgov/WALKOFF
    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()
예제 #3
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()
예제 #4
0
파일: transform.py 프로젝트: iadgov/WALKOFF
    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()
예제 #5
0
    def __init__(self,
                 app_name,
                 action_name,
                 id=None,
                 is_negated=False,
                 arguments=None,
                 transforms=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)
        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()
예제 #6
0
파일: workflow.py 프로젝트: iadgov/WALKOFF
    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()
예제 #7
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._transform_executable = None
        self.validate()
예제 #8
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()
    def __init__(self, operator='and', id=None, is_negated=False, child_expressions=None, conditions=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)
        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()