API v2 Changelog

< Back to Changelog

Managed Databases: Firewall and SQL Mode Management

Date: November 20, 2019

Tagged In: API v2

Author Andrew Starr-Bochicchio

DigitalOcean’s API now supports managing a database cluster’s firewall rules (known as “trusted sources” in the control panel) as well as the ability to configure the SQL mode used by MySQL clusters.

Using the /v2/databases/$DATABASE_ID/firewall endpoint, you can specify which resources should be able to open connections to your database. You may limit connections to specific Droplets, Kubernetes clusters, or external IP addresses. When a tag is provided, any Droplet or Kubernetes node with that tag applied to it will have access. For example, the body a PUT request might look like:

{
  "rules": [
    {"type": "ip_addr", "value": "192.168.1.1"},
    {"type": "droplet", "value": "163973392"},
    {"type": "k8s", "value": "ff2a6c52-5a44-4b63-b99c-0e98e7a63d61"},
    {"type": "tag", "value": "backend"}
  ]
}

To configure the SQL modes for a MySQL cluster, use the /v2/databases/$DATABASE_ID/sql_mode endpoint. For example, the body a PUT request might look like:

{
  "sql_mode": "ANSI,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE"
}

For more information, see the full API reference documentation for managed databases.