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.
Name | Type | Required | Description | Default Value |
---|---|---|---|---|
namespace_id |
string | True | The ID of the namespace to be managed. | |
body |
JSON or IO[bytes] | True |
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"name": "my trigger",
"function": "hello",
"type": "SCHEDULED",
"is_enabled": True,
"scheduled_details": {
"cron": "* * * * *",
"body": {
"name": "Welcome to DO!"
}
}
}
resp = client.functions.create_trigger(namespace_id="aff93af3", body=req)
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.