robocorp-actions
module robocorp.actions
Functions
action
Decorator for actions (entry points) which can be executed by robocorp.actions
.
i.e.:
If a file such as actions.py has the contents below:
It'll be executable by robocorp actions as:
python -m robocorp.actions run actions.py -a enter_user
Args:
func
: A function which is a action torobocorp.actions
.is_consequential
: Whether the action is consequential or not. This will addx-openai-isConsequential: true
to the action metadata and shown in OpenApi spec.
action_cache
Provides decorator which caches return and clears it automatically when the current action has been run.
A decorator which automatically cache the result of the given function and will return it on any new invocation until robocorp-actions finishes running the current action.
The function may be either a generator with a single yield (so, the first yielded value will be returned and when the cache is released the generator will be resumed) or a function returning some value.
Args:
func
: wrapped function.
get_current_action
Provides the action which is being currently run or None if not currently running an action.
get_output_dir
Provide the output directory being used for the run or None if there's no output dir configured.
session_cache
Provides decorator which caches return and clears automatically when all actions have been run.
A decorator which automatically cache the result of the given function and will return it on any new invocation until robocorp-actions finishes running all actions.
The function may be either a generator with a single yield (so, the first yielded value will be returned and when the cache is released the generator will be resumed) or a function returning some value.
Args:
func
: wrapped function.
setup
Run code before any actions start, or before each separate action.
Receives as an argument the action or actions that will be run.
Can be used as a decorator without arguments:
Alternatively, can be called with a scope
argument to decide when the fixture is run:
By default, runs setups in action
scope.
The setup
fixture also allows running code after the execution, if it yield
s the execution to the action(s):
Note: If fixtures are defined in another file, they need to be imported in the main actions file to be taken into use
teardown
Run code after actions have been run, or after each separate action.
Receives as an argument the action or actions that were executed, which contain (among other things) the resulting status and possible error message.
Can be used as a decorator without arguments:
Alternatively, can be called with a scope
argument to decide when the fixture is run:
By default, runs teardowns in action
scope.
Note: If fixtures are defined in another file, they need to be imported in the main actions file to be taken into use
Class IAction
Properties
failed
Returns true if the task failed. (in which case usually exc_info is not None).
input_schema
The input schema from the function signature.
Example:
lineno
The line where the task is declared.
managed_params_schema
The schema for the managed parameters.
Example:
name
The name of the task.
output_schema
The output schema based on the function signature.
Example:
Class Request
Contains the information exposed in a request (such as headers and cookies).
May be extended in the future to provide more information.
Properties
cookies
Provides the cookies received in the request.
headers
Provides the headers received in the request (excluding cookies
which are available in cookies
).
Methods
model_validate
Class Secret
This class should be used to receive secrets.
The way to use it is by declaring a variable with the 'Secret' type in the @action.
Example:
Note: this class is abstract and is not meant to be instanced by clients. An instance can be created from one of the factory methods (model_validate
or from_action_context
).
Properties
value
Methods
from_action_context
Creates a secret given the action context (which may be encrypted in memory until the actual secret value is requested).
Args:
-
action_context
: The action context which has the secret. -
path
: The path inside of the action context for the secret datarequested (Example: 'secrets/my_secret_name').
Return: A Secret instance collected from the passed action context.
model_validate
Creates a secret given a string (expected when the user is passing the arguments using a json input).
Args:
value
: The raw-text value to be used in the secret.
Return: A Secret instance with the given value.
Note: the model_validate method is used for compatibility with the pydantic API.
Enums
Status
Task state
Values
- NOT_RUN = NOT_RUN
- PASS = PASS
- FAIL = FAIL