Endpoints

Modified on Wed, 13 Apr 2022 at 09:35 AM

This article is outdated, you can access the most current version here:   https://doc.onedata.de/apps/apps-docs/odml-documentation/AppBuilder/endpoints/Endpoints.html


Endpoints are interfaces to executable ONE DATA resources - such as Workflows, Production Lines or Functions. They can be invoked based on an event, such as a button click. 

These resources are defined in the Processing Library and can afterwards be used in Apps. This article provides information about the different Endpoint types that are available and shows their usage.


PropertyTypeDescriptionExample Value
idstringThe unique id assigned to the Endpoint.
  "id": "TestEndpoint"
typestringType of the Endpoint
  "type": "workflow" || "productionLine"
asyncbooleanDefines the way the data will be updated. The data update callback is currently available only for FRT's
  "async": true
config
(workflow)
object

Configuration of your Endpoint for Workflows.

Version must be set to your current version (can be found in the URL "...versionNumber=3...")

If you don't provide a version property, the latest version will be executed.


Usage of target project ID for workflow execution:

Workflow Endpoint configuration allows setting the projectId. This may be necessary in some cases. More information on when and why it should be set can be found here.


 "config": {
    // Workflow ID
    "workflowId": "",
    // Project ID
    "projectId": "",
    // (Optional) Version of the 
    // Workflow to execute 
    "version": 0,
    // List of variable assignments
    "variableAssignments": [
      {
        // Name of the variable
        "variableName": "variable_27S",
        // Type of the variable
        "variableType": "STRING",
        // Value of the variable
        "variableValue": "Test Value"
      }
    ]
  }
config
(productionLine)

object
Configuration of your Endpoint for Production Line
  "config": {
     "productionLineId": "",
     // (Optional) Version of the
     // Production Line to execute
      "version": 0,
      // List of variable assignments
     "variableAssignments": [
          {
            // (Technical) Name of 
            // the variable 
            "variableName": "pl_var",
            // Type of the variable
            "variableType": "STRING",
            // Value of the variable
            "variableValue": "Test" 
          }
        ]
    }
config
(function)
object
Configuration of your Endpoint for Functions. (more information below)
  "config": {
      "functionId": "some_ID",
      "payload": {
        "input": {
          "name": "",
          "$name": {
            "value": "{{user_name}}"
          }
        }
      }
    }


Function Endpoints

With functions it is possible to implement complex logic in simple, single-purpose units that can be invoked by your app. They can be for example used to communicate with external services or execute short-lived, logically complex computations. Functions can be created in the Processing Library or Use Cases module of ONE DATA and can be currently written in Python. This section shows how functions can be defined as an Endpoint in Apps. For information on how to trigger a Function Endpoint and use it to customize user-facing messages, read on here.

 

In order to define an Endpoint for a Function, create an Endpoint with "type": "function". Its config can look like this:


  "config": {
      "functionId": "f7969880-70e9-4a76-8216-9f2ba05b09e8",
      "payload": {
        "input": {
          "name": "",
          "$name": {
            "value": "{{user_name}}"
          }
        }
      }
    }


The payload.input defines the argument that should be passed to the function as argument. Parts of the input can be parameterized with Variables to make the invocation dynamic based on the app state. In the above example the variable user_name is used as value of the field name of the Functions input object. The Function can be called with the resulting object by calling it via an Execute Button.

 

The configuration options relevant in this example are:

Property
Type
Description
functionId
string

The ID of the Function that should be invoked via the Endpoint.


payload.input
any

The argument that should be passed to the Function. It can be of any type (objects, strings, numbers, ...) and may be omitted if the Function does not expect parameters.



Example

  "endpoints": [
    {
      "id": "TestEndpoint",
      "type": "workflow",
      "async": true,
      "config": {
        "workflowId": "275405f6-9371-4829-8049-3d64751021eb",
        "projectId": "2b8398b6-8489-464a-b9cb-97919ea127f2",
        "version": 1,
        "variableAssignments": [
          {
            "variableName": "variable_27S",
            "variableType": "STRING",
            "variableValue": "Test Value"
          }
        ]
      }
    }
  ]

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article