๐งโ๐ผ Task
A task represents a single execution of a function. Task commands allow you to create, list and view the results of your tasks.
Create Taskโ
info
Create a task to call an execution of a single function.
Endpointโ
Request Headersโ
| Key | Value | Required |
|---|---|---|
Authorization | Valid Access Token | true |
Content-Type | application/json | optional |
Request Parametersโ
| Value | Example | Required |
|---|---|---|
| function id | 6404b3da46551827c611ffe5 | true |
tip
You may pass multiple query parameters to be consumed by the function.
Example: /v1/task/[functionId]?myParam1=100&myParam2=Green&myParam3=true
Request Bodyโ
tip
You may pass any valid json in the request body to be consumed by the function.
Example Requestโ
{
"name": "John Doe",
"age": 30,
"admin": true,
}
Example Responseโ
Status: 201 Created
{
"id": "63f47d24dab5eb85451f3b61",
}
Get Taskโ
info
Calling task with your task ID will return more detailed information about that task.
Endpointโ
Request Headersโ
| Key | Value | Required |
|---|---|---|
Authorization | Valid Access Token | true |
Request Parametersโ
| Value | Example | Required |
|---|---|---|
| task id | 6405942c9956fae80d7e0e91 | true |
Example Requestโ
Empty body
Example Responseโ
Status: 200 OK
{
"functionId": "6405848581b16f7a07cd4c48",
"issued": "1678087212",
"assigned": "1678088212",
"finished": "1678089212",
"progress": 0,
"node": "1a061cfd-df01-4b02-a067-5122c5941e15",
"timeout": 10,
"capabilities": {
"cpuCount": 0,
"memSize": 0,
"networkLatency": 0,
"privileged": true
}
}
List Tasksโ
info
List will list all your tasks with their progress and their HTTP Status.
Endpointโ
Request Headersโ
| Key | Value | Required |
|---|---|---|
Authorization | Valid Access Token | true |
Example Requestโ
Empty body
Example Responseโ
Status: 200 OK
[
{
id: "64057f3c9956fae80d7e0e84",
issued: "1680786622",
progress: 0,
status: 0
},
{
id: "640581c89956fae80d7e0e85",
issued: "1680786622",
progress: 100,
status: 200
},
{
id: "6405942c9956fae80d7e0e91",
issued: "1680786622",
progress: 75,
status: 0
},
]
Result Tasksโ
info
Calling your task result with the task ID will return the result of the task function.
Endpointโ
GET
https://api.greencloud.dev/v1/task/[taskId]/resulthttps://api.greencloud.dev/v1/task/[taskId]/result
Request Headersโ
| Key | Value | Required |
|---|---|---|
Authorization | Valid Access Token | true |
Request Parametersโ
| Value | Example | Required |
|---|---|---|
| task id | 6405942c9956fae80d7e0e91 | true |
Example Requestโ
Empty body
tip
Response could be any valid HTTP response returned by the underlying function.
Example Responsesโ
- Text
- JSON
Status: 200 OK
"Hello from GreenCloud!"
Status: 200 OK
{
"Status": "OK",
"Active": true,
"Nodes":["west", "south"],
"Count":40
}