Runtime Implementation of an Action Definition

The design of an action definition for design-time configuration can include all or some of the following:

  • The identity that shows the action on the user interface so that the user can choose.
  • The configuration fields that allow the scope of the action to be modified by the user on the user interface
  • The input and output schemas.

    The input and output schemas may be dynamically decided.

The design-time configuration drives the runtime execution that the adapter developer can design and drive using the execute property and by referencing a flow definition. The flow definition accesses:

  • The values selected in the configuration fields.
  • Connectivity properties.
  • The input data sent to the action.

    The input data must comply with the input schema.

For more information on how to author a flow, refer Introduction to Flow Definitions.

Sample code that shows how to invoke an external application Google Sheets API endpoint and execute using a flow definition:

"insertRowFlow": {
  "id": "insertRowFlow",
  "description": "insertRowFlow",
  "specVersion": "0.8",
  "version": "0.1",
  "start": "startState",
  "functions": [
    {
      "name": "generalRestFunc",
      "type": "custom",
      "operation": "connectivity::rest"
    }
  ],
  "states": [
    {
      "name": "startState",
      "type": "operation",
      "actions": [
        {
          "functionRef": {
            "refName": "generalRestFunc",
            "arguments": {
              "uri": "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:append",
              "method": "POST",
              "parameters": {
                "spreadsheetId": "${ .configuration.spreadsheetId }",
                "range": "${ .configuration.sheetId + \"!A1:Z1\" }",
                "insertDataOption": "INSERT_ROWS",
                "valueInputOption": "RAW"
              },
              "body": "${ {range: (.configuration.sheetId + \"!A1:Z1\"), majorDimension:\"ROWS\", values: .input | to_entries | [map(.value)] } }"
            }
          },
          "actionDataFilter": {
            "results": "${ .body }",
            "toStateData": "${ .output }"
          }
        }
      ],
      "end": true
    }
  ]
}