Skip to content

🐍🐳🐘 A python command line interface for DigitalOcean postgres clusters (5+ integrations).

License

Notifications You must be signed in to change notification settings

jim-schwoebel/dopg_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DOpg CLI

logo

logo

Python Dependencies GitHub Issues Contributions welcome License Tweet Follow me Β 

🐍🐳🐘 A python command line interface for DigitalOcean postgres clusters (5+ integrations).

Uses click, pgcli, and rich to create beautiful command line interactions for postgres databases.

You can easily extend this framework to fit your particular use case.

Some things that DOpg can do include:

MacOS setup (<3 minutes)

This first version has only been tested on MacOS.

First, install python3 and doctl using homebrew:

brew install python@3.9, postgresql, doctl

Now that doctl is installed, initialize it with an auth token:

doctl auth init

Next, install python dependencies within a virtual environment:

git clone https://github.com/jim-schwoebel/dopg_cli.git
cd dopg_cli
virtualenv env 
source env/bin/activate
pip3 install -r requirements.txt

Next, you can setup the cli (you will need your api key and must have already created a managed database postgres instance):

python3 cli.py

After this, you will see settings.json and databases.json in your dopg_cli directory used to configure all the commands that follow.

commands

There are many ways to use the DOpg CLI client, sectioned out below.

query databases

python3 cli.py --command query

Connects with pgcli, a really nice interface to connect to postgres and query postgres databases (e.g. with autocompletion).

api commands

The DigitalOcean API is a great way to get json responses from common routes related to databases.

To get a tabular list of possible commands, follow:

python3 cli.py --command api --route help

And it should output api doc commands as of 2022-11-04 - something like:

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Route                                           ┃ Description                                         ┃ Method ┃ Sample                                              ┃ Payload                                             ┃
┑━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
β”‚ add_connection_pool                             β”‚ For PostgreSQL database clusters, connection pools  β”‚ POST   β”‚ curl -X POST -H 'Content-Type: application/json' -H β”‚ {'name': 'backend-pool', 'mode': 'transaction',     β”‚
β”‚                                                 β”‚ can be used to allow a database to share its idle   β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚ 'size': 10, 'db': 'defaultdb', 'user': 'doadmin'}   β”‚
β”‚                                                 β”‚ connections. The popular PostgreSQL connection      β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ pooling utility PgBouncer is used to provide this   β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ service. See here for more information about how    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ and why to use PgBouncer connection pooling         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ including details about the available transaction   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ modes. To add a new connection pool to a PostgreSQL β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ database cluster, send a POST request to            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/pools specifying a name  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ for the pool, the user to connect with, the         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ database to connect to, as well as its desired size β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ and transaction mode.                               β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ add_database_user                               β”‚ To add a new database user, send a POST request to  β”‚ POST   β”‚ curl -X POST -H 'Content-Type: application/json' -H β”‚ {'name': 'app-01'}                                  β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/users with the desired   β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚                                                     β”‚
β”‚                                                 β”‚ username. Note: User management is not supported    β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ for Redis clusters. When adding a user to a MySQL   β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ cluster, additional options can be configured in    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ the mysql_settings object. The response will be a   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ JSON object with a key called user. The value of    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ this will be an object that contains the standard   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ attributes associated with a database user          β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ including its randomly generated password.          β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ add_new_database                                β”‚ To add a new database to an existing cluster, send  β”‚ POST   β”‚ curl -X POST -H 'Content-Type: application/json' -H β”‚ {'name': 'alpha'}                                   β”‚
β”‚                                                 β”‚ a POST request to /v2/databases/$DATABASE_ID/dbs.   β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚                                                     β”‚
β”‚                                                 β”‚ Note: Database management is not supported for      β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ Redis clusters. The response will be a JSON object  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ with a key called db. The value of this will be an  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ object that contains the standard attributes        β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ associated with a database.                         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ configure_a_database_cluster_maintenance_window β”‚ To configure the window when automatic maintenance  β”‚ PUT    β”‚ curl -X PUT -H 'Content-Type: application/json' -H  β”‚ {'day': 'tuesday', 'hour': '14:00'}                 β”‚
β”‚                                                 β”‚ should be performed for a database cluster, send a  β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚                                                     β”‚
β”‚                                                 β”‚ PUT request to                                      β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/maintenance. A           β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ successful request will receive a 204 No Content    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ status code with no body in response.               β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ create_a_new_database_cluster                   β”‚ To create a database cluster, send a POST request   β”‚ POST   β”‚ curl -X POST -H 'Content-Type: application/json' -H β”‚ {'name': 'backend-test', 'engine': 'pg', 'version': β”‚
β”‚                                                 β”‚ to /v2/databases. The response will be a JSON       β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚ '14', 'region': 'nyc3', 'size': 'db-s-2vcpu-4gb',   β”‚
β”‚                                                 β”‚ object with a key called database. The value of     β”‚        β”‚ '$PAYLOAD'                                          β”‚ 'num_nodes': 2, 'tags': ['production']}             β”‚
β”‚                                                 β”‚ this will be an object that contains the standard   β”‚        β”‚ 'https://api.digitalocean.com/v2/databases'         β”‚                                                     β”‚
β”‚                                                 β”‚ attributes associated with a database cluster. The  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ initial value of the database cluster's status      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ attribute will be creating. When the cluster is     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ ready to receive traffic, this will transition to   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ online. The embedded connection and                 β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ private_connection objects will contain the         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ information needed to access the database cluster.  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ DigitalOcean managed PostgreSQL and MySQL database  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ clusters take automated daily backups. To create a  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ new database cluster based on a backup of an        β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ existing cluster, send a POST request to            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases. In addition to the standard database β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ cluster attributes, the JSON body must include a    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ key named backup_restore with the name of the       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ original database cluster and the timestamp of the  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ backup to be restored. Creating a database from a   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ backup is the same as forking a database in the     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ control panel. Note: Backups are not supported for  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ Redis clusters.                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ create_a_read_replica                           β”‚ To create a read-only replica for a PostgreSQL or   β”‚ POST   β”‚ curl -X POST -H 'Content-Type: application/json' -H β”‚ {'name': 'read-nyc3-01', 'region': 'nyc3', 'size':  β”‚
β”‚                                                 β”‚ MySQL database cluster, send a POST request to      β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚ 'db-s-2vcpu-4gb'}                                   β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/replicas specifying the  β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ name it should be given, the size of the node to be β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ used, and the region where it will be located.      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ Note: Read-only replicas are not supported for      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ Redis clusters. The response will be a JSON object  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ with a key called replica. The value of this will   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ be an object that contains the standard attributes  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ associated with a database replica. The initial     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ value of the read-only replica's status attribute   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ will be forking. When the replica is ready to       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ receive traffic, this will transition to active.    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ delete_connection_pool                          β”‚ To delete a specific connection pool for a          β”‚ DEL    β”‚ curl -X DELETE -H 'Content-Type: application/json'  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ PostgreSQL database cluster, send a DELETE request  β”‚        β”‚ -H 'Authorization: Bearer $DIGITALOCEAN_TOKEN'      β”‚                                                     β”‚
β”‚                                                 β”‚ to /v2/databases/$DATABASE_ID/pools/$POOL_NAME. A   β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ status of 204 will be given. This indicates that    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ the request was processed successfully, but that no β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ response body is needed.                            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ delete_database                                 β”‚ To delete a specific database, send a DELETE        β”‚ DEL    β”‚ curl -X DELETE -H 'Content-Type: application/json'  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ request to /v2/databases/$DATABASE_ID/dbs/$DB_NAME. β”‚        β”‚ -H 'Authorization: Bearer $DIGITALOCEAN_TOKEN'      β”‚                                                     β”‚
β”‚                                                 β”‚ A status of 204 will be given. This indicates that  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ the request was processed successfully, but that no β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ response body is needed. Note: Database management  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ is not supported for Redis clusters.                β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ destroy_a_database_cluster                      β”‚ To destroy a specific database, send a DELETE       β”‚ DEL    β”‚ curl -X DELETE -H 'Content-Type: application/json'  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ request to /v2/databases/$DATABASE_ID. A status of  β”‚        β”‚ -H 'Authorization: Bearer $DIGITALOCEAN_TOKEN'      β”‚                                                     β”‚
β”‚                                                 β”‚ 204 will be given. This indicates that the request  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ was processed successfully, but that no response    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ body is needed.                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ destroy_read_replica                            β”‚ To destroy a specific read-only replica, send a     β”‚ DEL    β”‚ curl -X DELETE -H 'Content-Type: application/json'  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ DELETE request to                                   β”‚        β”‚ -H 'Authorization: Bearer $DIGITALOCEAN_TOKEN'      β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/replicas/$REPLICA_NAME.  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ Note: Read-only replicas are not supported for      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ Redis clusters. A status of 204 will be given. This β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ indicates that the request was processed            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ successfully, but that no response body is needed.  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_all_database_clusters                      β”‚ To list all of the database clusters available on   β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ your account, send a GET request to /v2/databases.  β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ To limit the results to database clusters with a    β”‚        β”‚ 'https://api.digitalocean.com/v2/databases'         β”‚                                                     β”‚
β”‚                                                 β”‚ specific tag, include the tag_name query parameter  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ set to the name of the tag. For example,            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases?tag_name=$TAG_NAME. The result will   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ be a JSON object with a databases key. This will be β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ set to an array of database objects, each of which  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ will contain the standard database attributes. The  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ embedded connection and private_connection objects  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ will contain the information needed to access the   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ database cluster: The embedded maintenance_window   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ object will contain information about any scheduled β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ maintenance for the database cluster.               β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_all_databases                              β”‚ To list all of the databases in a clusters, send a  β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ GET request to /v2/databases/$DATABASE_ID/dbs. The  β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ result will be a JSON object with a dbs key. This   β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ will be set to an array of database objects, each   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ of which will contain the standard database         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ attributes. Note: Database management is not        β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ supported for Redis clusters.                       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_backups_for_a_database_cluster             β”‚ To list all of the available backups of a           β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ PostgreSQL or MySQL database cluster, send a GET    β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ request to /v2/databases/$DATABASE_ID/backups.      β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ Note: Backups are not supported for Redis clusters. β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ The result will be a JSON object with a backups     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ key. This will be set to an array of backup         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ objects, each of which will contain the size of the β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ backup and the timestamp at which it was created.   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_connection_pools                           β”‚ To list all of the connection pools available to a  β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ PostgreSQL database cluster, send a GET request to  β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/pools. The result will   β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ be a JSON object with a pools key. This will be set β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ to an array of connection pool objects.             β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_database_options                           β”‚ To list all of the options available for the        β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ offered database engines, send a GET request to     β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/options. The result will be a JSON    β”‚        β”‚ 'https://api.digitalocean.com/v2/databases'         β”‚                                                     β”‚
β”‚                                                 β”‚ object with an options key.                         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_database_users                             β”‚ To list all of the users for your database cluster, β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ send a GET request to                               β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/users. Note: User        β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ management is not supported for Redis clusters. The β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ result will be a JSON object with a users key. This β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ will be set to an array of database user objects,   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ each of which will contain the standard database    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ user attributes. For MySQL clusters, additional     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ options will be contained in the mysql_settings     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ object.                                             β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_firewall_rules_for_a_database              β”‚ To list all of a database cluster's firewall rules  β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ (known as trusted sources in the control panel),    β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ send a GET request to                               β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/firewall. The result     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ will be a JSON object with a rules key.             β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ list_read_replicas                              β”‚ To list all of the read-only replicas associated    β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ with a database cluster, send a GET request to      β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/replicas. Note:          β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ Read-only replicas are not supported for Redis      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ clusters. The result will be a JSON object with a   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ replicas key. This will be set to an array of       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ database replica objects, each of which will        β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ contain the standard database replica attributes.   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ migrate_a_database_cluster_to_a_new_region      β”‚ To migrate a database cluster to a new region, send β”‚ PUT    β”‚ curl -X PUT -H 'Content-Type: application/json' -H  β”‚ {'region': 'lon1'}                                  β”‚
β”‚                                                 β”‚ a PUT request to                                    β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/migrate. The body of the β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ request must specify a region attribute. A          β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ successful request will receive a 202 Accepted      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ status code with no body in response. Querying the  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ database cluster will show that its status          β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ attribute will now be set to migrating. This will   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ transition back to online when the migration has    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ completed.                                          β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ remove_database_user                            β”‚ To remove a specific database user, send a DELETE   β”‚ DEL    β”‚ curl -X DELETE -H 'Content-Type: application/json'  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ request to                                          β”‚        β”‚ -H 'Authorization: Bearer $DIGITALOCEAN_TOKEN'      β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/users/$USERNAME. A       β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ status of 204 will be given. This indicates that    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ the request was processed successfully, but that no β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ response body is needed. Note: User management is   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ not supported for Redis clusters.                   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ reset_database_user                             β”‚ To reset the password for a database user, send a   β”‚ POST   β”‚ curl -X POST -H 'Content-Type: application/json' -H β”‚ {}                                                  β”‚
β”‚                                                 β”‚ POST request to                                     β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/users/$USERNAME/reset_a… β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ For mysql databases, the authentication method can  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ be specifying by including a key in the JSON body   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ called mysql_settings with the auth_plugin value    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ specified. The response will be a JSON object with  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ a user key. This will be set to an object           β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ containing the standard database user attributes.   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ resize_a_database_cluster                       β”‚ To resize a database cluster, send a PUT request to β”‚ PUT    β”‚ curl -X PUT -H 'Content-Type: application/json' -H  β”‚ {'size': 'db-s-4vcpu-8gb', 'num_nodes': 3}          β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/resize. The body of the  β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚                                                     β”‚
β”‚                                                 β”‚ request must specify both the size and num_nodes    β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ attributes. A successful request will receive a 202 β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ Accepted status code with no body in response.      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ Querying the database cluster will show that its    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ status attribute will now be set to resizing. This  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ will transition back to online when the resize      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ operation has completed.                            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_an_existing_database_cluster           β”‚ To show information about an existing database      β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ cluster, send a GET request to                      β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID. The response will be a  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ JSON object with a database key. This will be set   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ to an object containing the standard database       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ cluster attributes. The embedded connection and     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ private_connection objects will contain the         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ information needed to access the database cluster.  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ The embedded maintenance_window object will contain β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ information about any scheduled maintenance for the β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ database cluster.                                   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_connection_pool                        β”‚ To show information about an existing connection    β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ pool for a PostgreSQL database cluster, send a GET  β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ request to                                          β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/pools/$POOL_NAME. The    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ response will be a JSON object with a pool key.     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_database                               β”‚ To show information about an existing database      β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ cluster, send a GET request to                      β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/dbs/$DB_NAME. Note:      β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ Database management is not supported for Redis      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ clusters. The response will be a JSON object with a β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ db key. This will be set to an object containing    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ the standard database attributes.                   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_database_cluster_configuration         β”‚ Shows configuration parameters for an existing      β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ database cluster by sending a GET request to        β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/config. The response is  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ a JSON object with a config key, which is set to an β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ object containing any database configuration        β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ parameters.                                         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_database_user                          β”‚ To show information about an existing database      β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ user, send a GET request to                         β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/users/$USERNAME. Note:   β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ User management is not supported for Redis          β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ clusters. The response will be a JSON object with a β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ user key. This will be set to an object containing  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ the standard database user attributes. For MySQL    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ clusters, additional options will be contained in   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ the mysql_settings object.                          β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_read_replica                           β”‚ To show information about an existing database      β”‚        β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ replica, send a GET request to                      β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/replicas/$REPLICA_NAME.  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ Note: Read-only replicas are not supported for      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ Redis clusters. The response will be a JSON object  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ with a replica key. This will be set to an object   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ containing the standard database replica            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ attributes.                                         β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_the_public_certificate                 β”‚ To retrieve the public certificate used to secure   β”‚ GET    β”‚ curl -X GET -H 'Content-Type: application/json' -H  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ the connection to the database cluster send a GET   β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN'         β”‚                                                     β”‚
β”‚                                                 β”‚ request to /v2/databases/$DATABASE_ID/ca. The       β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ response will be a JSON object with a ca key. This  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ will be set to an object containing the base64      β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ encoding of the public key certificate.             β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ retrieve_the_status_of_an_online_migration      β”‚ To retrieve the status of the most recent online    β”‚ GET    β”‚ curl -X PUT -H 'Content-Type: application/json' -H  β”‚ {'source': {}, 'disable_ssl': False}                β”‚
β”‚                                                 β”‚ migration, send a GET request to                    β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/online-migration.        β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ start_an_online_migration                       β”‚ To start an online migration, send a PUT request to β”‚ PUT    β”‚ curl -X PUT -H 'Content-Type: application/json' -H  β”‚ {'source': {'host':                                 β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/online-migration         β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚ 'source-do-user-6607903-0.b.db.ondigitalocean.com', β”‚
β”‚                                                 β”‚ endpoint. Migrating a cluster establishes a         β”‚        β”‚ '$PAYLOAD'                                          β”‚ 'dbname': 'defaultdb', 'port': 25060, 'username':   β”‚
β”‚                                                 β”‚ connection with an existing cluster and replicates  β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚ 'doadmin', 'password': 'paakjnfe10rsrsmf'},         β”‚
β”‚                                                 β”‚ its contents to the target cluster. Online          β”‚        β”‚                                                     β”‚ 'disable_ssl': False}                               β”‚
β”‚                                                 β”‚ migration is only available for MySQL, PostgreSQL,  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ and Redis clusters.                                 β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ stop_an_online_migration                        β”‚ To stop an online migration, send a DELETE request  β”‚ DEL    β”‚ curl -X DELETE -H 'Content-Type: application/json'  β”‚ {}                                                  β”‚
β”‚                                                 β”‚ to                                                  β”‚        β”‚ -H 'Authorization: Bearer $DIGITALOCEAN_TOKEN'      β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/online-migration/$MIGRA… β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ A status of 204 will be given. This indicates that  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ the request was processed successfully, but that no β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ response body is needed.                            β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚ update_database_cluster_configuration           β”‚ To update the configuration for an existing         β”‚ PATCH  β”‚ curl -X PATCH -H 'Content-Type: application/json'   β”‚ {'config': {'autovacuum_naptime': 60,               β”‚
β”‚                                                 β”‚ database cluster, send a PATCH request to           β”‚        β”‚ -H 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d   β”‚ 'autovacuum_vacuum_threshold': 50,                  β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/config.                  β”‚        β”‚ '$PAYLOAD'                                          β”‚ 'autovacuum_analyze_threshold': 50,                 β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚ 'autovacuum_vacuum_scale_factor': 0.2,              β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'autovacuum_analyze_scale_factor': 0.2,             β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'autovacuum_vacuum_cost_delay': 20,                 β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'autovacuum_vacuum_cost_limit': -1,                 β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'bgwriter_flush_after': 512,                        β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'bgwriter_lru_maxpages': 100,                       β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'bgwriter_lru_multiplier': 2,                       β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'idle_in_transaction_session_timeout': 0, 'jit':    β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ True, 'log_autovacuum_min_duration': -1,            β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'log_min_duration_statement': -1,                   β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'max_prepared_transactions': 0,                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'max_parallel_workers': 8,                          β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'max_parallel_workers_per_gather': 2,               β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'temp_file_limit': -1, 'wal_sender_timeout': 60000, β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'pgbouncer': {'server_reset_query_always': False,   β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'min_pool_size': 0, 'server_idle_timeout': 0,       β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'autodb_pool_size': 0, 'autodb_max_db_connections': β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 0, 'autodb_idle_timeout': 0}, 'backup_hour': 21,    β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'backup_minute': 40, 'timescaledb': {},             β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚ 'stat_monitor_enable': False}}                      β”‚
β”‚ update_firewall_rules_for_a_database            β”‚ To update a database cluster's firewall rules       β”‚ PUT    β”‚ curl -X PUT -H 'Content-Type: application/json' -H  β”‚ {'rules': []}                                       β”‚
β”‚                                                 β”‚ (known as trusted sources in the control panel),    β”‚        β”‚ 'Authorization: Bearer $DIGITALOCEAN_TOKEN' -d      β”‚                                                     β”‚
β”‚                                                 β”‚ send a PUT request to                               β”‚        β”‚ '$PAYLOAD'                                          β”‚                                                     β”‚
β”‚                                                 β”‚ /v2/databases/$DATABASE_ID/firewall specifying      β”‚        β”‚ 'https://api.digitalocean.com/v2/databases/$DATABA… β”‚                                                     β”‚
β”‚                                                 β”‚ which resources should be able to open connections  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ to the database. You may limit connections to       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ specific Droplets, Kubernetes clusters, or IP       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ addresses. When a tag is provided, any Droplet or   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ Kubernetes node with that tag applied to it will    β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ have access. The firewall is limited to 100 rules   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ (or trusted sources). When possible, we recommend   β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ placing your databases into a VPC network to limit  β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ access to them instead of using a firewall. A       β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚ successful                                          β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β”‚                                                 β”‚                                                     β”‚        β”‚                                                     β”‚                                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

And then you can run any of these commands in snake case (in the 'Route' column above); for example:

python3 cli.py --command api --route list_firewall_rules_for_a_database

Outputs pretty printed json:

{
  "rules": [
    {
      "uuid": "41f1b3b4-a481-4ca7-8d92-f643a3606ac6",
      "cluster_uuid": "e4f7e56e-2c29-4de1-b937-965bd2e20e9d",
      "type": "ip_addr",
      "value": "115.206.82.140",
      "created_at": "2022-11-04T19:24:43Z"
    }
  ]
}

doctl commands

You can also use doctl's database commands directly - with a nicely formatted output for tables and other types of data. Note that doctl is the python command line interface for digitalocean.

python3 cli.py --command doctl

docs

You can also get doctl docs and api docs with this command:

python3 cli.py --command docs

pricing

You can get pricing of managed databases within digitalocean using public links:

python3 cli.py --command pricing

references

🐍 Python modules that may help you as you build PostgreSQL applications, as a beginner or an expert:

  • asyncpg - a fast PostgreSQL Database Client Library for Python/asyncio
  • click - click CLI docs
  • cr8 - benchmarking postgres clusters
  • flask-migrate - database migrations in flask
  • marshmellow - schemas in python
  • psycopg2 module - for querying databases in python code
  • pgcli - command line interface for postgres
  • pgloader - migrate to PostgreSQL in a single command
  • python-digitalocean - a python command line client for digitalocean generally (mostly droplets)
  • rich - a Python library for rich text and beautiful formatting in the terminal
  • sqlalchemy - database toolkit for python
  • tpch-pgsql - implementing the tpch benchmark for postgres databases
  • unittest - unit testing in python

🐘 Standard postgres references that may help you:

🐳 DigitalOcean references that may help you as you use this CLI client: