Custom Actions¶
Custom Action Data Messages¶
You can use Custom Actions to enable communication between two Applications on either the same cluster or across different clusters.
Note
To understand the purpose of Custom Actions or view the overall structure of how they work, check out the documentation in the overview page here.
As a consumer of Custom Action Messages, this Application is defined as Consumer (Executor) Application.
Note
The Publisher Application which outputs Custom Actions to a Consumer (Executor) Application, is discussed in detail in the Produce Custom Action section here.
To ensure the Custom Action Messages are handled properly, the app.yaml inputs needs to be declared:
Warning
Only ONE Consumer (Executor) Application can be deployed on the Kelvin Platform to receive each Type name.
Multiple Consumer (Executor) Applications with the same TYPE name is not supported.
The Custom Action Object in the main.py script supports the following attributes :
| Attribute | Required | Default Value | Description |
|---|---|---|---|
resource |
required | N/A | The KRNAsset that this Custom Action is meant for. |
type |
required | N/A | The name of Custom Action. |
title |
required | N/A | Title of the Custom Action |
description |
required | N/A | Description details of the Custom Action |
expiration_date |
required | N/A | Absolute datetime or a timedelta (from now) when the Control Change will expire. |
payload |
required | N/A | The custom information of the Custom Action that will be required by the Consumer Application |
trace_id |
optional | N/A | A custom id for tracking the Custom Action status |
The Custom Action Result Object supports the following attributes :
| Attribute | Required | Default Value | Description |
|---|---|---|---|
success |
required | N/A | Whether the Custom Actions were completed successfully. Boolean True or False. |
message |
optional | N/A | Any message to return to the Publishing Application. |
metadata |
optional | N/A | Any additional metadata that needs to be returned to the Publishing Application |
action_id |
optional | N/A | The id of the Custom Action Object |
resource |
optional | N/A | The KRNAsset that this Custom Action is meant for. |
Custom Action UI Schemas¶
You can define a UI schema for each Custom Action type your Application consumes. This creates an input form in the Kelvin UI's Applications section where users can configure global settings for the executor -- settings that apply across all invocations of that action type.
Example
An email executor might expose fields for the SMTP server address and port. These are set once on the executor application and apply to every email action it processes.
Declare the schemas in the ui_schemas.custom_actions section of your app.yaml, keyed by action type name:
| app.yaml Example | |
|---|---|
Each file is a JSON Schema that defines the configuration fields presented to users in the Kelvin UI for the executor application:
Note
Custom Action payload schemas are optional. If not provided, the payload field is treated as free-form JSON with no UI validation.
Consumer App Example¶
In this example we will create a Consumer (Executor) Application that will;
- Listen and receive any new Custom Action objects with the type
email. - Extract the relevant email information from the
payload - Connect to an SMTP and send the email (This function is defined but not fully coded)
- Return the status of the Custom Action (
TrueorFalse)
Check out the Produce Custom Actions documentation here to see how to send this Custom Action from the Publisher Application.
app.yaml
| app.yaml Example | |
|---|---|
Consumer (Executor) Application