From b2b4b6db4515b7757021bacd84c6879d8286b601 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 16 Jul 2019 13:10:49 -0700 Subject: [PATCH 1/2] Databases: support for custom VPC UUID on migrate --- databases.go | 10 ++++++---- databases_test.go | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/databases.go b/databases.go index 81c4ecc8..f9cdce9e 100644 --- a/databases.go +++ b/databases.go @@ -139,7 +139,8 @@ type DatabaseResizeRequest struct { // DatabaseMigrateRequest can be used to initiate a database migrate operation. type DatabaseMigrateRequest struct { - Region string `json:"region,omitempty"` + Region string `json:"region,omitempty"` + PrivateNetworkUUID string `json:"private_network_uuid"` } // DatabaseUpdateMaintenanceRequest can be used to update the database's maintenance window. @@ -199,9 +200,10 @@ type DatabaseCreateDBRequest struct { // DatabaseCreateReplicaRequest is used to create a new read-only replica type DatabaseCreateReplicaRequest struct { - Name string `json:"name"` - Region string `json:"region"` - Size string `json:"size"` + Name string `json:"name"` + Region string `json:"region"` + Size string `json:"size"` + PrivateNetworkUUID string `json:"private_network_uuid"` } type databaseUserRoot struct { diff --git a/databases_test.go b/databases_test.go index 3091949b..9e48bd83 100644 --- a/databases_test.go +++ b/databases_test.go @@ -10,6 +10,8 @@ import ( "github.com/stretchr/testify/require" ) +var privateNetworkUUID = "880b7f98-f062-404d-b33c-458d545696f6" + var db = Database{ ID: "da4e0206-d019-41d7-b51f-deadbeefbb8f", Name: "dbtest", @@ -312,6 +314,27 @@ func TestDatabases_Migrate(t *testing.T) { require.NoError(t, err) } +func TestDatabases_Migrate_WithPrivateNet(t *testing.T) { + setup() + defer teardown() + + migrateRequest := &DatabaseMigrateRequest{ + Region: "lon1", + PrivateNetworkUUID: privateNetworkUUID, + } + + dbID := "deadbeef-dead-4aa5-beef-deadbeef347d" + + path := fmt.Sprintf("/v2/databases/%s/migrate", dbID) + + mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodPut) + }) + + _, err := client.Databases.Migrate(ctx, "deadbeef-dead-4aa5-beef-deadbeef347d", migrateRequest) + require.NoError(t, err) +} + func TestDatabases_UpdateMaintenance(t *testing.T) { setup() defer teardown() From be42896989fcb8ca3e60d5615acf687fbee30219 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 16 Jul 2019 13:27:40 -0700 Subject: [PATCH 2/2] Adds vpc uuid to replica test --- databases_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/databases_test.go b/databases_test.go index 9e48bd83..2bd38e4d 100644 --- a/databases_test.go +++ b/databases_test.go @@ -1109,9 +1109,10 @@ func TestDatabases_CreateReplica(t *testing.T) { }) got, _, err := client.Databases.CreateReplica(ctx, dbID, &DatabaseCreateReplicaRequest{ - Name: "replica", - Region: "nyc1", - Size: "db-s-2vcpu-4gb", + Name: "replica", + Region: "nyc1", + Size: "db-s-2vcpu-4gb", + PrivateNetworkUUID: privateNetworkUUID, }) require.NoError(t, err) require.Equal(t, want, got)