mistral.actions package¶
Subpackages¶
Submodules¶
mistral.actions.action_factory module¶
mistral.actions.action_generator module¶
-
class
mistral.actions.action_generator.
ActionGenerator
¶ Bases:
object
Action generator.
Action generator uses some data to build Action classes dynamically.
-
create_actions
(*args, **kwargs)¶ Constructs classes of needed action.
return: list of actions dicts containing name, class, description and parameter info.
-
mistral.actions.base module¶
-
class
mistral.actions.base.
Action
¶ Bases:
object
Action.
Action is a means in Mistral to perform some useful work associated with a workflow during its execution. Every workflow task is configured with an action and when the task runs it eventually delegates to the action. When it happens task parameters get evaluated (calculating expressions, if any) and are treated as action parameters. So in a regular general purpose languages terminology action is a method declaration and task is a method call.
Base action class initializer doesn’t have arguments. However, concrete action classes may have any number of parameters defining action behavior. These parameters must correspond to parameters declared in action specification (e.g. using DSL or others). Action initializer may have a conventional argument with name “action_context”. If it presents then action factory will fill it with a dictionary containing contextual information like execution identifier, workbook name and other that may be needed for some specific action implementations.
-
is_sync
()¶ Returns True if the action is synchronous, otherwise False.
Returns: True if the action is synchronous and method run() returns final action result. Otherwise returns False which means that a result of method run() should be ignored and a real action result is supposed to be delivered in an asynchronous manner using public API. By default, if a concrete implementation doesn’t override this method then the action is synchronous.
-
run
()¶ Run action logic.
Returns: Result of the action. Note that for asynchronous actions it should always be None, however, if even it’s not None it will be ignored by a caller.
Result can be of two types: 1) Any serializable value meaningful from a user perspective (such as string, number or dict). 2) Instance of {mistral.workflow.utils.Result} which has field “data” for success result and field “error” for keeping so called “error result” like HTTP error code and similar. Using the second type allows to communicate a result even in case of error and hence to have conditions in “on-error” clause of direct workflows. Depending on particular action semantics one or another option may be preferable. In case if action failed and there’s no need to communicate any error result this method should throw a ActionException.
-
test
()¶ Returns action test result.
This method runs in test mode as a test version of method run() to generate and return a representative test result. It’s basically a contract for action ‘dry-run’ behavior specifically useful for testing and workflow designing purposes.
Returns: Representative action result.
-
mistral.actions.generator_factory module¶
mistral.actions.std_actions module¶
-
class
mistral.actions.std_actions.
AsyncNoOpAction
¶ Bases:
mistral.actions.std_actions.NoOpAction
Asynchronous no-operation action.
-
is_sync
()¶
-
-
class
mistral.actions.std_actions.
EchoAction
(output)¶ Bases:
mistral.actions.base.Action
Echo action.
This action just returns a configured value as a result without doing anything else. The value of such action implementation is that it can be used in development (for testing), demonstration and designing of workflows themselves where echo action can play the role of temporary stub.
-
run
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
FailAction
¶ Bases:
mistral.actions.base.Action
‘Always fail’ action.
This action just always throws an instance of ActionException. This behavior is useful in a number of cases, especially if we need to test a scenario where some of workflow tasks fail.
-
run
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
HTTPAction
(url, method='GET', params=None, body=None, headers=None, cookies=None, auth=None, timeout=None, allow_redirects=None, proxies=None, verify=None)¶ Bases:
mistral.actions.base.Action
Constructs an HTTP action.
Parameters: - url – URL for the new HTTP request.
- method – (optional, ‘GET’ by default) method for the new HTTP request.
- params – (optional) Dictionary or bytes to be sent in the query string for the HTTP request.
- body – (optional) Dictionary, bytes, or file-like object to send in the body of the HTTP request.
- headers – (optional) Dictionary of HTTP Headers to send with the HTTP request.
- cookies – (optional) Dict or CookieJar object to send with the HTTP request.
- auth – (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
- timeout – (optional) Float describing the timeout of the request in seconds.
- allow_redirects – (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- verify – (optional) if
True
, the SSL cert will be verified. A CA_BUNDLE path can also be provided.
-
run
()¶
-
test
()¶
-
class
mistral.actions.std_actions.
JavaScriptAction
(script, context=None)¶ Bases:
mistral.actions.base.Action
Evaluates given JavaScript.
-
run
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
MistralHTTPAction
(action_context, url, method='GET', params=None, body=None, headers=None, cookies=None, auth=None, timeout=None, allow_redirects=None, proxies=None, verify=None)¶ Bases:
mistral.actions.std_actions.HTTPAction
-
is_sync
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
NoOpAction
¶ Bases:
mistral.actions.base.Action
No-operation action.
This action does nothing. It can be mostly useful for testing and debugging purposes.
-
run
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
SSHAction
(cmd, host, username, password=None, private_key_filename=None)¶ Bases:
mistral.actions.base.Action
Runs Secure Shell (SSH) command on provided single or multiple hosts.
It is allowed to provide either a single host or a list of hosts in action parameter ‘host’. In case of a single host the action result will be a single value, otherwise a list of results provided in the same order as provided hosts.
-
run
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
SSHProxiedAction
(cmd, host, username, private_key_filename, gateway_host, gateway_username=None, password=None, proxy_command=None)¶
-
class
mistral.actions.std_actions.
SendEmailAction
(from_addr, to_addrs, smtp_server, smtp_password=None, subject=None, body=None)¶ Bases:
mistral.actions.base.Action
-
run
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
SleepAction
(seconds=1)¶ Bases:
mistral.actions.base.Action
Sleep action.
This action sleeps for given amount of seconds. It can be mostly useful for testing and debugging purposes.
-
run
()¶
-
test
()¶
-
-
class
mistral.actions.std_actions.
TestDictAction
(size=0, key_prefix='', val='')¶ Bases:
mistral.actions.base.Action
Generates test dict.
-
run
()¶
-
test
()¶
-