Skip to content

Commit

Permalink
Merge pull request #241 from digitalocean/databases-custom-vpc-migrate
Browse files Browse the repository at this point in the history
Databases: support for custom VPC UUID on migrate and replica create
  • Loading branch information
hilary authored Jul 17, 2019
2 parents 3ec0b9c + be42896 commit 165c77f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
10 changes: 6 additions & 4 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
30 changes: 27 additions & 3 deletions databases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -1086,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)
Expand Down

0 comments on commit 165c77f

Please sign in to comment.