Skip to main content

โžก๏ธ Trigger (function chain)

When you run a function in GreenCloud you may wish for it to cause another function to run afterwards automatically. You can do this by creating a trigger. Triggers have the option to allow you to pass the result from one function into the function which is automatically called afterwards.

Createโ€‹

info

Use this endpoint to create a trigger which causes a function to execute automatically after another function has been called. You have the option to include tags and a description.

Endpointโ€‹

POST
https://api.greencloud.dev/v1/trigger
https://api.greencloud.dev/v1/trigger

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue
Content-Typeapplication/jsontrue

Request Bodyโ€‹

KeyExampleRequirements
functionId664f8feb91f33bfb994dcfd2required string functionId
nextId664f8feb91f33bfb994dcfd3required string functionId
status200integer httpcode
tag[tag id, tag id, tag id]optional dive unique alphanum
includeResulttruerequired bool
descriptionsaveResultToStorageoptional printascii max=256

Example Requestโ€‹

{
"functionId": "664f8feb91f33bfb994dcfd2",
"nextId": "664f8feb91f33bfb994dcfd3",
"tag": ['63fe131f02975e4956238b39', '63fe131f02975e4956238b40'],
"status": 200,
"includeResult": true,
"description": "saveResultToStorage"
}

Example Responseโ€‹

Status: 201 Created
{
"id": "63f47d24dab5eb85451f3b61",
}

Getโ€‹

info

Use this endpoint to retrieve information about a trigger using it's Id. These include the initial function ID, the subsequent function ID, the tags attached to the trigger, its status result, whether the results of the initial function are fed to the subsequent function, its description and when it was created.

Endpointโ€‹

GET
https://api.greencloud.dev/v1/trigger/[triggerId]
https://api.greencloud.dev/v1/trigger/[triggerId]

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue
Content-Typeapplication/jsontrue

Request Parametersโ€‹

KeyExampleRequirements
trigger Id664f8feb91f33bfb994dcfd2triggerId

Example Requestโ€‹

Empty body

Example Responseโ€‹

Status: 200 OK
{
"functionId": "65cbc89aaa892059d49e06cf",
"nextId": "65cbc89aaa892059d49e06cf",
"tags": [{ "id": "65cbc88e41cbcffabfacefd4", "name": "greencloud", "color": "#00ff80" }],
"status": 200,
"includeResult": true,
"description": "saveResultToStorage",
"createdAt": "2024-05-24T00:13:08Z"
}

Listโ€‹

info

Use this endpoint to get a list of triggers in your GreenCloud account. You can include the function Id to find triggers for that specific function. If the list of triggers is larger than a single page of results you can choose which page of results to view using page. You can also limit the number of triggers listed using limit.

Endpointโ€‹

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

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue
Content-Typeapplication/jsontrue

Request Bodyโ€‹

KeyExampleRequirements
page1optional min=1 integer default 1
limit3optional min=3 max=20 integer default 10
functionId664f8feb91f33bfb994dcfd3optional

Example Requestโ€‹

{
"page": 1,
"limit": 2,
"functionId": "664f8feb91f33bfb994dcfd2",
}

Example Responseโ€‹

Status: 200 OK
{
"pageCount": 1,
"pageSize": 1,
"totalCount": 2,
"results": [{
"id": "65dd290735dd849401eacc8e",
"functionId": "664f8feb91f33bfb994dcfd2",
"nextId": "65cbc89aaa892059d49e06cf",
"tags": [{ "id": "65cbc88e41cbcfgibfacefd4", "name": "greencloud", "color": "#00ff80" }],
"status": 200,
"includeResult": true,
"createdAt": "2024-02-27T00:12:55Z"
}
{
"id": "65dd290735dd849401eacc8f",
"functionId": "664f8feb91f33bfb994dcgp4",
"nextId": "65cbc89aaa892059d49e09dz",
"tags": [{ "id": "65cbc88e41cbcfharfacefd4", "name": "webinars", "color": "#00dd80" }],
"status": 200,
"includeResult": false,
"createdAt": "2024-05-25T00:13:42Z"
}]
}

Editโ€‹

info

Use this endpoint to edit a trigger. You have the option to include tags and a description.

Endpointโ€‹

PATCH
https://api.greencloud.dev/v1/trigger/[triggerId]
https://api.greencloud.dev/v1/trigger/[triggerId]

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue
Content-Typeapplication/jsontrue

Request Bodyโ€‹

KeyExampleRequirements
tag[tag id, tag id, tag id]optional dive unique alphanum
status200integer httpcode
includeResulttruerequired bool
descriptionsaveResultToStorageoptional printascii max=256

Example Requestโ€‹

{
"tag": ['63fe131f02975e4956238b39', '63fe131f02975e4956238b40'],
"status": 200,
"includeResult": true,
"description": "saveResultToStorage"
}

Example Responseโ€‹

Status: 204 No Content
{
Empty body
}

Deleteโ€‹

info

Use this endpoint to delete a trigger from the GreenCloud system.

Endpointโ€‹

DELETE
https://api.greencloud.dev/v1/trigger/[triggerId]
https://api.greencloud.dev/v1/trigger/[triggerId]

Request Headersโ€‹

KeyValueRequired
AuthorizationValid Access Tokentrue

Request Parametersโ€‹

ValueExampleRequired
trigger id65dd290735dd849401eacc8ftrue

Example Requestโ€‹

Empty body

Example Responseโ€‹

Status: 204 No Content
Empty body