Database Connections API
- Table of Contents
- Overview
- Attributes
- Get a List of Database Connections
- Get Details on a Single Database Connection
- Create a Database Connection
- Update a Database Connection
- Delete a Database Connection
Overview
GreenArrow can connect to external MySQL, Microsoft SQL Server, and PostgreSQL databases to support remote mailing lists in Studio.
Engine’s Database Connections API is used to manage the connections to these external databases.
Attributes
The following attributes are defined for Database Connections:
database_connection
hash /required
|
Get a List of Database Connections
GET /ga/api/v3/eng/database_connections
Parameters
The following parameters are valid for the above endpoint.
page
integer /optional |
The page number from which to retrieve. Page numbering starts at |
page_token
string /optional |
The |
name
string /optional |
Filter the results to just a single Database Connection with this name (case-insensitive). |
Examples:
GET /ga/api/v3/eng/database_connections?page={page}
GET /ga/api/v3/eng/database_connections?page_token={page_token}
GET /ga/api/v3/eng/database_connections?name={name}
Response
The response will contain a list of Database Connections in the following format.
database_connections
array of hashes
|
|||||||||||
pagination
hash
|
Example 1: Get the First Page of Database Connections
GET /ga/api/v3/eng/database_connections
HTTP/1.1 200 OK
{
"success": true,
"data": {
"database_connections": [
{
"id": 1,
"name": "my_db_conn1"
},
{
"id": 2,
"name": "my_db_conn2"
},
{
"id": 3,
"name": "my_db_conn3"
}
],
"pagination": {
"page": 0,
"per_page": 100,
"num_pages": 1,
"num_records": 3,
"next_page_token": null
}
},
"error_code": null,
"error_messages": null
}
Example 2: Get a Specific Page of Database Connections with Per-Page Limits
GET /ga/api/v3/eng/database_connections?page=1&per_page=2
HTTP/1.1 200 OK
{
"success": true,
"data": {
"database_connections": [
{
"id": 3,
"name": "my_db_conn3"
}
],
"pagination": {
"page": 1,
"per_page": 2,
"num_pages": 2,
"num_records": 3,
"next_page_token": null
}
},
"error_code": null,
"error_messages": null
}
Example 3: Find a Database Connection by Name
GET /ga/api/v3/eng/database_connections?name=my_db_conn2
HTTP/1.1 200 OK
{
"success": true,
"data": {
"database_connections": [
{
"id": 2,
"name": "my_db_conn2"
}
],
"pagination": {
"page": 0,
"per_page": 100,
"num_pages": 1,
"num_records": 1,
"next_page_token": null
}
},
"error_code": null,
"error_messages": null
}
Get Details on a Single Database Connection
GET /ga/api/v3/eng/database_connections/{id}
Response
The response will contain details on the requested record:
database_connection
hash |
The attributes for this hash are defined in the Attributes section of this document. |
Example
GET /ga/api/v3/eng/database_connections/1
HTTP/1.1 200 OK
{
"success": true,
"data": {
"database_connection": {
"id": 1,
"name": "my_db_conn1",
"type": "mysql",
"database": "database_name_01",
"username": "root",
"password": "",
"remote_connection": null,
"extra": null,
"notes": null
}
},
"error_code": null,
"error_messages": null
}
Create a Database Connection
POST /ga/api/v3/eng/database_connections
Payload
database_connection
hash /required |
The content of this hash is described in the Attributes section of this page. The data may contain a mixture of required and optional fields. Do not specify read-only fields. |
Response
The response will include a database_connection
key containing the full Database Connection
record as defined in the Database Connection Attributes.
Example
POST /ga/api/v3/eng/database_connections
{
"database_connection": {
"name": "a_new_db_conn",
"type": "mysql",
"username": "root",
"database": "db_name",
"remote_connection": {
"port": 123,
"ssl": false,
"hostname": "example.com"
}
}
}
HTTP/1.1 200 OK
{
"success": true,
"data": {
"database_connection": {
"id": 4,
"name": "a_new_db_conn",
"type": "mysql",
"database": "db_name",
"username": "root",
"password": "",
"remote_connection": {
"hostname": "example.com",
"port": 123,
"ssl": false
},
"extra": null,
"notes": null
}
},
"error_code": null,
"error_messages": null
}
Update a Database Connection
PUT /ga/api/v3/eng/database_connections/{id}
Payload
database_connection
hash /required |
The content of this hash is described in the Attributes section of this page. The data may contain a mixture of required and optional fields. Do not specify read-only fields. |
Response
The response will include a data
key containing the full Database Connection
record as defined in the Database Connection Attributes.
Example
PUT /ga/api/v3/eng/database_connections/1
{
"database_connection": {
"name": "updated_name"
}
}
HTTP/1.1 200 OK
{
"success": true,
"data": {
"database_connection": {
"id": 1,
"name": "updated_name",
"type": "mysql",
"database": "database_name_01",
"username": "root",
"password": "",
"remote_connection": null,
"extra": null,
"notes": null
}
},
"error_code": null,
"error_messages": null
}
Delete a Database Connection
DELETE /ga/api/v3/eng/database_connections/{id}
Response
The response is a standard success or error response.
Example
DELETE /ga/api/v3/eng/database_connections/2
HTTP/1.1 200 OK
{
"success": true,
"data": {
},
"error_code": null,
"error_messages": null
}