Skip to main content

triggers

Creates, updates, deletes, gets or lists a triggers resource.

Overview

Nametriggers
TypeResource
Iddigitalocean.serverless.triggers

Fields

The following fields are returned by SELECT queries:

A JSON response object with a key called trigger. The object contains the properties associated
with the trigger.

NameDatatypeDescription
namestringThe trigger's unique name within the namespace. (example: my trigger)
created_atstringUTC time string. (example: 2022-11-11T04:16:45Z)
functionstringName of function(action) that exists in the given namespace. (example: hello)
is_enabledbooleanIndicates weather the trigger is paused or unpaused.
namespacestringA unique string format of UUID with a prefix fn-. (example: fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
scheduled_detailsobjectTrigger details for SCHEDULED type, where body is optional.
scheduled_runsobject
typestringString which indicates the type of trigger source like SCHEDULED. (example: SCHEDULED)
updated_atstringUTC time string. (example: 2022-11-11T04:16:45Z)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
functions_get_triggerselectnamespace_id, trigger_nameGets the trigger details. To get the trigger details, send a GET request to /v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME.
functions_list_triggersselectnamespace_idReturns a list of triggers associated with the current user and namespace. To get all triggers, send a GET request to /v2/functions/namespaces/$NAMESPACE_ID/triggers.
functions_create_triggerinsertnamespace_id, data__name, data__function, data__type, data__is_enabled, data__scheduled_detailsCreates a new trigger for a given function in a namespace. To create a trigger, send a POST request to /v2/functions/namespaces/$NAMESPACE_ID/triggers with the name, function, type, is_enabled and scheduled_details properties.
functions_update_triggerreplacenamespace_id, trigger_nameUpdates the details of the given trigger. To update a trigger, send a PUT request to /v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME with new values for the is_enabled or scheduled_details properties.
functions_delete_triggerdeletenamespace_id, trigger_nameDeletes the given trigger.
To delete trigger, send a DELETE request to /v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME.
A successful deletion returns a 204 response.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
namespace_idstringThe ID of the namespace to be managed. (example: fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
trigger_namestringThe name of the trigger to be managed. (example: my trigger)

SELECT examples

Gets the trigger details. To get the trigger details, send a GET request to /v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME.

SELECT
name,
created_at,
function,
is_enabled,
namespace,
scheduled_details,
scheduled_runs,
type,
updated_at
FROM digitalocean.serverless.triggers
WHERE namespace_id = '{{ namespace_id }}' -- required
AND trigger_name = '{{ trigger_name }}' -- required;

INSERT examples

Creates a new trigger for a given function in a namespace. To create a trigger, send a POST request to /v2/functions/namespaces/$NAMESPACE_ID/triggers with the name, function, type, is_enabled and scheduled_details properties.

INSERT INTO digitalocean.serverless.triggers (
data__name,
data__function,
data__type,
data__is_enabled,
data__scheduled_details,
namespace_id
)
SELECT
'{{ name }}' --required,
'{{ function }}' --required,
'{{ type }}' --required,
{{ is_enabled }} --required,
'{{ scheduled_details }}' --required,
'{{ namespace_id }}'
RETURNING
trigger
;

REPLACE examples

Updates the details of the given trigger. To update a trigger, send a PUT request to /v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME with new values for the is_enabled or scheduled_details properties.

REPLACE digitalocean.serverless.triggers
SET
data__is_enabled = {{ is_enabled }},
data__scheduled_details = '{{ scheduled_details }}'
WHERE
namespace_id = '{{ namespace_id }}' --required
AND trigger_name = '{{ trigger_name }}' --required
RETURNING
trigger;

DELETE examples

Deletes the given trigger.
To delete trigger, send a DELETE request to /v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME.
A successful deletion returns a 204 response.

DELETE FROM digitalocean.serverless.triggers
WHERE namespace_id = '{{ namespace_id }}' --required
AND trigger_name = '{{ trigger_name }}' --required;