diff --git a/databases.go b/databases.go index c0a4510..14d5a04 100644 --- a/databases.go +++ b/databases.go @@ -170,24 +170,26 @@ var _ DatabasesService = &DatabasesServiceOp{} // "pg", "mysql" or "redis". A Database also includes connection information and other // properties of the service like region, size and current status. type Database struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - EngineSlug string `json:"engine,omitempty"` - VersionSlug string `json:"version,omitempty"` - Connection *DatabaseConnection `json:"connection,omitempty"` - PrivateConnection *DatabaseConnection `json:"private_connection,omitempty"` - Users []DatabaseUser `json:"users,omitempty"` - NumNodes int `json:"num_nodes,omitempty"` - SizeSlug string `json:"size,omitempty"` - DBNames []string `json:"db_names,omitempty"` - RegionSlug string `json:"region,omitempty"` - Status string `json:"status,omitempty"` - MaintenanceWindow *DatabaseMaintenanceWindow `json:"maintenance_window,omitempty"` - CreatedAt time.Time `json:"created_at,omitempty"` - PrivateNetworkUUID string `json:"private_network_uuid,omitempty"` - Tags []string `json:"tags,omitempty"` - ProjectID string `json:"project_id,omitempty"` - StorageSizeMib uint64 `json:"storage_size_mib,omitempty"` + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + EngineSlug string `json:"engine,omitempty"` + VersionSlug string `json:"version,omitempty"` + Connection *DatabaseConnection `json:"connection,omitempty"` + PrivateConnection *DatabaseConnection `json:"private_connection,omitempty"` + StandbyConnection *DatabaseConnection `json:"standby_connection,omitempty"` + StandbyPrivateConnection *DatabaseConnection `json:"standby_private_connection,omitempty"` + Users []DatabaseUser `json:"users,omitempty"` + NumNodes int `json:"num_nodes,omitempty"` + SizeSlug string `json:"size,omitempty"` + DBNames []string `json:"db_names,omitempty"` + RegionSlug string `json:"region,omitempty"` + Status string `json:"status,omitempty"` + MaintenanceWindow *DatabaseMaintenanceWindow `json:"maintenance_window,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` + PrivateNetworkUUID string `json:"private_network_uuid,omitempty"` + Tags []string `json:"tags,omitempty"` + ProjectID string `json:"project_id,omitempty"` + StorageSizeMib uint64 `json:"storage_size_mib,omitempty"` } // DatabaseCA represents a database ca. @@ -381,13 +383,15 @@ type DatabaseReplica struct { // DatabasePool represents a database connection pool type DatabasePool struct { - User string `json:"user"` - Name string `json:"name"` - Size int `json:"size"` - Database string `json:"db"` - Mode string `json:"mode"` - Connection *DatabaseConnection `json:"connection"` - PrivateConnection *DatabaseConnection `json:"private_connection,omitempty"` + User string `json:"user"` + Name string `json:"name"` + Size int `json:"size"` + Database string `json:"db"` + Mode string `json:"mode"` + Connection *DatabaseConnection `json:"connection"` + PrivateConnection *DatabaseConnection `json:"private_connection,omitempty"` + StandbyConnection *DatabaseConnection `json:"standby_connection,omitempty"` + StandbyPrivateConnection *DatabaseConnection `json:"standby_private_connection,omitempty"` } // DatabaseCreatePoolRequest is used to create a new database connection pool diff --git a/databases_test.go b/databases_test.go index e6ae02e..bd34803 100644 --- a/databases_test.go +++ b/databases_test.go @@ -27,6 +27,15 @@ var db = Database{ Password: "zt91mum075ofzyww", SSL: true, }, + StandbyConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, PrivateConnection: &DatabaseConnection{ URI: "postgres://doadmin:zt91mum075ofzyww@private-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", Database: "defaultdb", @@ -36,6 +45,15 @@ var db = Database{ Password: "zt91mum075ofzyww", SSL: true, }, + StandbyPrivateConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, Users: []DatabaseUser{ { Name: "doadmin", @@ -87,6 +105,24 @@ var dbJSON = ` "password": "zt91mum075ofzyww", "ssl": true }, + "standby_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, + "standby_private_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, "users": [ { "name": "doadmin", @@ -224,10 +260,28 @@ func TestDatabases_Create(t *testing.T) { Password: "zt91mum075ofzyww", SSL: true, }, + StandbyConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, PrivateConnection: &DatabaseConnection{ URI: "postgres://doadmin:zt91mum075ofzyww@private-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", Database: "defaultdb", - Host: "dbtest-do-user-3342561-0.db.ondigitalocean.com", + Host: "private-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, + StandbyPrivateConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", Port: 25060, User: "doadmin", Password: "zt91mum075ofzyww", @@ -264,7 +318,25 @@ func TestDatabases_Create(t *testing.T) { "private_connection": { "uri": "postgres://doadmin:zt91mum075ofzyww@private-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", "database": "defaultdb", - "host": "dbtest-do-user-3342561-0.db.ondigitalocean.com", + "host": "private-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, + "standby_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, + "standby_private_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", "port": 25060, "user": "doadmin", "password": "zt91mum075ofzyww", @@ -322,6 +394,24 @@ func TestDatabases_Create(t *testing.T) { Password: "zt91mum075ofzyww", SSL: true, }, + StandbyConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, + StandbyPrivateConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, Users: nil, DBNames: nil, NumNodes: 2, @@ -358,6 +448,24 @@ func TestDatabases_Create(t *testing.T) { "password": "zt91mum075ofzyww", "ssl": true }, + "standby_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, + "standby_private_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, "users": null, "db_names": null, "num_nodes": 2, @@ -407,6 +515,24 @@ func TestDatabases_Create(t *testing.T) { Password: "zt91mum075ofzyww", SSL: true, }, + StandbyConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, + StandbyPrivateConnection: &DatabaseConnection{ + URI: "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + Database: "defaultdb", + Host: "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + Port: 25060, + User: "doadmin", + Password: "zt91mum075ofzyww", + SSL: true, + }, Users: nil, DBNames: nil, NumNodes: 2, @@ -444,6 +570,24 @@ func TestDatabases_Create(t *testing.T) { "password": "zt91mum075ofzyww", "ssl": true }, + "standby_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, + "standby_private_connection": { + "uri": "postgres://doadmin:zt91mum075ofzyww@private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com:25060/defaultdb?sslmode=require", + "database": "defaultdb", + "host": "private-replica-dbtest-do-user-3342561-0.db.ondigitalocean.com", + "port": 25060, + "user": "doadmin", + "password": "zt91mum075ofzyww", + "ssl": true + }, "users": null, "db_names": null, "num_nodes": 2, @@ -1028,6 +1172,24 @@ func TestDatabases_ListPools(t *testing.T) { SSL: true, Database: "db", }, + StandbyConnection: &DatabaseConnection{ + URI: "postgresql://user:pass@replica-host.com/db", + Host: "replica-host.com", + Port: 1234, + User: "user", + Password: "pass", + SSL: true, + Database: "db", + }, + StandbyPrivateConnection: &DatabaseConnection{ + URI: "postgresql://user:pass@replica-private-host.com/db", + Host: "replica-private-host.com", + Port: 1234, + User: "user", + Password: "pass", + SSL: true, + Database: "db", + }, }, } @@ -1056,6 +1218,24 @@ func TestDatabases_ListPools(t *testing.T) { "password": "pass", "database": "db", "ssl": true + }, + "standby_connection": { + "uri": "postgresql://user:pass@replica-host.com/db", + "host": "replica-host.com", + "port": 1234, + "user": "user", + "password": "pass", + "database": "db", + "ssl": true + }, + "standby_private_connection": { + "uri": "postgresql://user:pass@replica-private-host.com/db", + "host": "replica-private-host.com", + "port": 1234, + "user": "user", + "password": "pass", + "database": "db", + "ssl": true } }] } @@ -1102,6 +1282,24 @@ func TestDatabases_CreatePool(t *testing.T) { SSL: true, Database: "db", }, + StandbyConnection: &DatabaseConnection{ + URI: "postgresql://user:pass@replica-host.com/db", + Host: "replica-host.com", + Port: 1234, + User: "user", + Password: "pass", + SSL: true, + Database: "db", + }, + StandbyPrivateConnection: &DatabaseConnection{ + URI: "postgresql://user:pass@replica-private-host.com/db", + Host: "replica-private-host.com", + Port: 1234, + User: "user", + Password: "pass", + SSL: true, + Database: "db", + }, } body := ` @@ -1129,6 +1327,24 @@ func TestDatabases_CreatePool(t *testing.T) { "password": "pass", "database": "db", "ssl": true + }, + "standby_connection": { + "uri": "postgresql://user:pass@replica-host.com/db", + "host": "replica-host.com", + "port": 1234, + "user": "user", + "password": "pass", + "database": "db", + "ssl": true + }, + "standby_private_connection": { + "uri": "postgresql://user:pass@replica-private-host.com/db", + "host": "replica-private-host.com", + "port": 1234, + "user": "user", + "password": "pass", + "database": "db", + "ssl": true } } } @@ -1181,6 +1397,24 @@ func TestDatabases_GetPool(t *testing.T) { SSL: true, Database: "db", }, + StandbyConnection: &DatabaseConnection{ + URI: "postgresql://user:pass@replica-host.com/db", + Host: "replica-host.com", + Port: 1234, + User: "user", + Password: "pass", + SSL: true, + Database: "db", + }, + StandbyPrivateConnection: &DatabaseConnection{ + URI: "postgresql://user:pass@replica-private-host.com/db", + Host: "replica-private-host.com", + Port: 1234, + User: "user", + Password: "pass", + SSL: true, + Database: "db", + }, } body := ` @@ -1208,6 +1442,24 @@ func TestDatabases_GetPool(t *testing.T) { "password": "pass", "database": "db", "ssl": true + }, + "standby_connection": { + "uri": "postgresql://user:pass@replica-host.com/db", + "host": "replica-host.com", + "port": 1234, + "user": "user", + "password": "pass", + "database": "db", + "ssl": true + }, + "standby_private_connection": { + "uri": "postgresql://user:pass@replica-private-host.com/db", + "host": "replica-private-host.com", + "port": 1234, + "user": "user", + "password": "pass", + "database": "db", + "ssl": true } } }