Function API
Functions created with AFX can be executed, stopped, and status information can be obtained via the API, and API keys can be created in advance for use in applications and shell scripts.
Common Parameters
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"function", "action":"<action>" ... }' https://<endpoint url>
Parameters
accesskey : Access key
secet:Secret key
component : funciton
action : action to execute
endpoint url : URL to send API requests
% curl -X POST -d "{\"accesskey\":\"<accesskey>\", \"secret\":\"<secretkey>\", \"component\":\"function\", \"action\":\"<action>\" ...}" https://<endpoint url>
Note :
When using curl commands under Windows, use only double quotes and escape within JSON data, as in the example at left.
Executing Functions
Functions created from the ADP console can be executed via API.
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"function", "action":"request", "name":"linetest", "datasource":"ds1", "obj":"data1.csv"}' https://<endpoint url>
{"data":"Kxf9K3L9T83Ke0pwMIOn","status":"success"}
Parameters
action : request
name : name of the function
datasource : name of the Avgidea Storage data source
* not required for Standalone functions
File or Line function
obj : Name of the object on Avgidea Storage to be processed
Return value
data : Execution ID of the function
Stopping Functions
A running function can be stopped via the API. The execution of a function will transition from "running" to "terminated" status.
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"function", "action":"terminate", "id":"Kxf9K3L9T83Ke0pwMIOn"}' https://<endpoint url>
{"data":"Termination request sent","status":"success"}
Parameters
action : terminate
id : ID of function execution
Return value
data : message of sending stop request
Listing Function Executions
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"function", "action":"list", "status":"success"}' https://<endpoint url> | jq
{
"data": [
{
"name": "linetest",
"registeredAt": "2024-04-16T02:23:26.512039Z",
"id": "Kxf9K3L9T83Ke0pwMIOn",
"logs": [
{
"registeredAt": "2024-04-16T02:23:28.514009Z",
"text": "Start processing Kxf9K3L9T83Ke0pwMIOn"
},
{
"registeredAt": "2024-04-16T02:23:29.296281Z",
"text": "Finished processing Kxf9K3L9T83Ke0pwMIOn"
}
],
"status": "success",
"updatedAt": "2024-04-16T02:23:29.258Z"
},
...
}
Parameters
action : list
status : status of execution (starting, running, success, failed, timeout, terminated or unspecified to get all statuses of execution)
Return value
data : execution details including logs