pydo.functions.update_trigger()

Description

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.

Parameters

Name Type Required Description Default Value
namespace_id string True The ID of the namespace to be managed.
trigger_name string True The name of the trigger to be managed.
body JSON or IO[bytes] True

Request Sample

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "is_enabled": true,
  "scheduled_details": {
    "cron": "* * * * *",
    "body": {
      "name": "Welcome to DO!"
    }
  }
}

resp = client.functions.update_trigger(namespace_id="39f3ca", trigger_name="trig_name", body=req)

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

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

Click to expand an example response.
{
  "trigger": {
    "namespace": "fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "name": "my trigger",
    "function": "hello",
    "type": "SCHEDULED",
    "is_enabled": true,
    "created_at": "2022-11-11T04:16:45Z",
    "updated_at": "2022-11-11T04:16:45Z",
    "scheduled_details": {
      "cron": "* * * * *",
      "body": {
        "name": "Welcome to DO!"
      }
    },
    "scheduled_runs": {
      "last_run_at": "2022-11-11T04:16:45Z",
      "next_run_at": "2022-11-11T04:16:45Z"
    }
  }
}

Bad Request.

Click to expand an example response.
{
  "id": "bad_request",
  "message": "validating create trigger: validation error: missing trigger name, missing function name, missing source details",
  "request_id": "4851a473-1621-42ea-b2f9-5071c0ea8414"
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

Bad Request.

Click to expand an example response for namespace not found.
{
  "value": {
    "id": "not_found",
    "message": "namespace not found",
    "request_id": "88d17b7a-630b-4083-99ce-5b91045efdb4"
  }
}
Click to expand an example response for trigger not found.
{
  "value": {
    "id": "not_found",
    "message": "trigger not found",
    "request_id": "88d17b7a-630b-4083-99ce-5b91045efdb4"
  }
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}