Skip to main content

๐Ÿง‘โ€๐Ÿ’ผ 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โ€‹

POST
https://api.greencloud.dev/v1/task/[functionId]
https://api.greencloud.dev/v1/task/[functionId]

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue
Content-Typeapplication/jsonoptional

Request Parametersโ€‹

ValueExampleRequired
function id6404b3da46551827c611ffe5true
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โ€‹

GET
https://api.greencloud.dev/v1/task/[taskId]
https://api.greencloud.dev/v1/task/[taskId]

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue

Request Parametersโ€‹

ValueExampleRequired
task id6405942c9956fae80d7e0e91true

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โ€‹

GET
https://api.greencloud.dev/v1/task/list
https://api.greencloud.dev/v1/task/list

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue

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]/result
https://api.greencloud.dev/v1/task/[taskId]/result

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue

Request Parametersโ€‹

ValueExampleRequired
task id6405942c9956fae80d7e0e91true

Example Requestโ€‹

Empty body
tip

Response could be any valid HTTP response returned by the underlying function.

Example Responsesโ€‹

Status: 200 OK
"Hello from GreenCloud!"