Anatomy of an Action
When You create (and save) a new Action in unSkript, a directory will be created with a number of files. In this document, we describe each file, and how they work.
Each Action is in a directory. The directory is a descriptive name of the Action, with "_" replacing spaces. Inside this directory are the files that make up the Action:
init.py
This is an empty file that is required to distinguish the module/sub-module.
README.md
The README.md explains what the Action is supposed to do. When you create a new action - a skeleton README is created, but you will need to fill in a few details to create a full README.
It should contain:
Action Title
Description: explains what the Action is intended to do.
Action Details: here we explain the Action signature, what are the different input fields to the Action. It's also nice to add an example of how the Action might be used:
Example Usage:
Action Input: explains how many parameters are needed for the Lego. Which of them are Mandatory, which of them are optional.
Lego Output A sample output from the Lego/Action upon completion. Ensure to remove sensitive values.
JSON File
The JSON file lists Example:
All of these fields are Mandatory.
Action Title: The human readable title of your Action
Action Description: a text description of what the Action does
Action Type: Format is "LEGO_TYPE_[CONNECTOR_TYPE]" where CONNECTOR_TYPE is AWS, GCP, Slack, etc.
Action Entry Function: This is a Python function name that executes the Action Step by Step
Action Needs Credential: Boolean - are the credentials for this connector required?
Action Output Type: one of:
ACTION_OUTPUT_TYPE_STR
ACTION_OUTPUT_TYPE_INT
ACTION_OUTPUT_TYPE_BOOL
ACTION_OUTPUT_TYPE_LIST
ACTION_OUTPUT_TYPE_DICT
ACTION_OUTPUT_TYPE_BYTES
ACTION_OUTPUT_TYPE_NONE
Action Supports Poll: Can this Action be polled?
Action Supports Iteration: Can the Action be used to iterate over a list of values?
Action Categories: List of categories that fit the Action - used for discoverability.
py file
This is the Python file that runs the Action in the xRunBook.
The python code has several Classes and Functions that are required to run in unSkript:
InputSchema
The InputSchema lists all of the input parameters for the Action.
Printer
The Printer Function defines what is printed into the Jupyter Notebook as output of the Action
Function
The function is what "does the work" for the action. The example above has the following inputs:
handle: The Credentials used to make calls to the Connector. handle does the authentication for you.
region - a String input parameter
warning_percentage: a float input parameter.
The output of this function will be a List.
Last updated