triggers
Creates, updates, deletes, gets or lists a triggers
resource.
Overview
Name | triggers |
Type | Resource |
Id | digitalocean.serverless.triggers |
Fields
The following fields are returned by SELECT
queries:
- functions_get_trigger
- functions_list_triggers
A JSON response object with a key called trigger
. The object contains the properties associated
with the trigger.
Name | Datatype | Description |
---|---|---|
name | string | The trigger's unique name within the namespace. (example: my trigger) |
created_at | string | UTC time string. (example: 2022-11-11T04:16:45Z) |
function | string | Name of function(action) that exists in the given namespace. (example: hello) |
is_enabled | boolean | Indicates weather the trigger is paused or unpaused. |
namespace | string | A unique string format of UUID with a prefix fn-. (example: fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) |
scheduled_details | object | Trigger details for SCHEDULED type, where body is optional. |
scheduled_runs | object | |
type | string | String which indicates the type of trigger source like SCHEDULED. (example: SCHEDULED) |
updated_at | string | UTC time string. (example: 2022-11-11T04:16:45Z) |
An array of JSON objects with a key called namespaces
. Each object represents a namespace and contains
the properties associated with it.
Name | Datatype | Description |
---|---|---|
name | string | The trigger's unique name within the namespace. (example: my trigger) |
created_at | string | UTC time string. (example: 2022-11-11T04:16:45Z) |
function | string | Name of function(action) that exists in the given namespace. (example: hello) |
is_enabled | boolean | Indicates weather the trigger is paused or unpaused. |
namespace | string | A unique string format of UUID with a prefix fn-. (example: fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) |
scheduled_details | object | Trigger details for SCHEDULED type, where body is optional. |
scheduled_runs | object | |
type | string | String which indicates the type of trigger source like SCHEDULED. (example: SCHEDULED) |
updated_at | string | UTC time string. (example: 2022-11-11T04:16:45Z) |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
functions_get_trigger | select | namespace_id , trigger_name | Gets the trigger details. To get the trigger details, send a GET request to /v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME . | |
functions_list_triggers | select | namespace_id | Returns 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_trigger | insert | namespace_id , data__name , data__function , data__type , data__is_enabled , data__scheduled_details | 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. | |
functions_update_trigger | replace | namespace_id , trigger_name | 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. | |
functions_delete_trigger | delete | namespace_id , trigger_name | 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. |
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.
Name | Datatype | Description |
---|---|---|
namespace_id | string | The ID of the namespace to be managed. (example: fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) |
trigger_name | string | The name of the trigger to be managed. (example: my trigger) |
SELECT
examples
- functions_get_trigger
- functions_list_triggers
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;
Returns 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
.
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;
INSERT
examples
- functions_create_trigger
- Manifest
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
;
# Description fields are for documentation purposes
- name: triggers
props:
- name: namespace_id
value: string
description: Required parameter for the triggers resource.
- name: name
value: string
description: >
The trigger's unique name within the namespace.
- name: function
value: string
description: >
Name of function(action) that exists in the given namespace.
- name: type
value: string
description: >
One of different type of triggers. Currently only SCHEDULED is supported.
- name: is_enabled
value: boolean
description: >
Indicates weather the trigger is paused or unpaused.
- name: scheduled_details
value: object
description: >
Trigger details for SCHEDULED type, where body is optional.
REPLACE
examples
- functions_update_trigger
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
- functions_delete_trigger
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;