add delegates for rackspace configurations
diff --git a/rackspace/db/v1/configurations/delegate.go b/rackspace/db/v1/configurations/delegate.go
new file mode 100644
index 0000000..d8cb48a
--- /dev/null
+++ b/rackspace/db/v1/configurations/delegate.go
@@ -0,0 +1,79 @@
+package configurations
+
+import (
+ "github.com/rackspace/gophercloud"
+ os "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
+ "github.com/rackspace/gophercloud/pagination"
+)
+
+// List will list all of the available configurations.
+func List(client *gophercloud.ServiceClient) pagination.Pager {
+ return os.List(client)
+}
+
+// Create will create a new configuration group.
+func Create(client *gophercloud.ServiceClient, opts os.CreateOptsBuilder) os.CreateResult {
+ return os.Create(client, opts)
+}
+
+// Get will retrieve the details for a specified configuration group.
+func Get(client *gophercloud.ServiceClient, configID string) os.GetResult {
+ return os.Get(client, configID)
+}
+
+// Update will modify an existing configuration group by performing a merge
+// between new and existing values. If the key already exists, the new value
+// will overwrite. All other keys will remain unaffected.
+func Update(client *gophercloud.ServiceClient, configID string, opts os.UpdateOptsBuilder) os.UpdateResult {
+ return os.Update(client, configID, opts)
+}
+
+// Replace will modify an existing configuration group by overwriting the
+// entire parameter group with the new values provided. Any existing keys not
+// included in UpdateOptsBuilder will be deleted.
+func Replace(client *gophercloud.ServiceClient, configID string, opts os.UpdateOptsBuilder) os.ReplaceResult {
+ return os.Replace(client, configID, opts)
+}
+
+// Delete will permanently delete a configuration group. Please note that
+// config groups cannot be deleted whilst still attached to running instances -
+// you must detach and then delete them.
+func Delete(client *gophercloud.ServiceClient, configID string) os.DeleteResult {
+ return os.Delete(client, configID)
+}
+
+// ListInstances will list all the instances associated with a particular
+// configuration group.
+func ListInstances(client *gophercloud.ServiceClient, configID string) pagination.Pager {
+ return os.ListInstances(client, configID)
+}
+
+// ListDatastoreParams will list all the available and supported parameters
+// that can be used for a particular datastore ID and a particular version.
+// For example, if you are wondering how you can configure a MySQL 5.6 instance,
+// you can use this operation (you will need to retrieve the MySQL datastore ID
+// by using the datastores API).
+func ListDatastoreParams(client *gophercloud.ServiceClient, datastoreID, versionID string) pagination.Pager {
+ return os.ListDatastoreParams(client, datastoreID, versionID)
+}
+
+// GetDatastoreParam will retrieve information about a specific configuration
+// parameter. For example, you can use this operation to understand more about
+// "innodb_file_per_table" configuration param for MySQL datastores. You will
+// need the param's ID first, which can be attained by using the ListDatastoreParams
+// operation.
+func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID, paramID string) os.ParamResult {
+ return os.GetDatastoreParam(client, datastoreID, versionID, paramID)
+}
+
+// ListGlobalParams is similar to ListDatastoreParams but does not require a
+// DatastoreID.
+func ListGlobalParams(client *gophercloud.ServiceClient, versionID string) pagination.Pager {
+ return os.ListGlobalParams(client, versionID)
+}
+
+// GetGlobalParam is similar to GetDatastoreParam but does not require a
+// DatastoreID.
+func GetGlobalParam(client *gophercloud.ServiceClient, versionID, paramID string) os.ParamResult {
+ return os.GetGlobalParam(client, versionID, paramID)
+}
diff --git a/rackspace/db/v1/configurations/delegate_test.go b/rackspace/db/v1/configurations/delegate_test.go
new file mode 100644
index 0000000..af5e8aa
--- /dev/null
+++ b/rackspace/db/v1/configurations/delegate_test.go
@@ -0,0 +1,237 @@
+package configurations
+
+import (
+ "testing"
+
+ os "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
+ "github.com/rackspace/gophercloud/pagination"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/instances"
+ th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
+ "github.com/rackspace/gophercloud/testhelper/fixture"
+)
+
+var (
+ configID = "{configID}"
+ _baseURL = "/configurations"
+ resURL = _baseURL + "/" + configID
+
+ dsID = "{datastoreID}"
+ versionID = "{versionID}"
+ paramID = "{paramID}"
+ dsParamListURL = "/datastores/" + dsID + "/versions/" + versionID + "/parameters"
+ dsParamGetURL = "/datastores/" + dsID + "/versions/" + versionID + "/parameters/" + paramID
+ globalParamListURL = "/datastores/versions/" + versionID + "/parameters"
+ globalParamGetURL = "/datastores/versions/" + versionID + "/parameters/" + paramID
+)
+
+func TestList(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, _baseURL, "GET", "", os.ListConfigsJSON, 200)
+
+ count := 0
+ err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
+ count++
+ actual, err := os.ExtractConfigs(page)
+ th.AssertNoErr(t, err)
+
+ expected := []os.Config{os.ExampleConfig}
+ th.AssertDeepEquals(t, expected, actual)
+
+ return true, nil
+ })
+
+ th.AssertEquals(t, 1, count)
+ th.AssertNoErr(t, err)
+}
+
+func TestGet(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, resURL, "GET", "", os.GetConfigJSON, 200)
+
+ config, err := Get(fake.ServiceClient(), configID).Extract()
+ th.AssertNoErr(t, err)
+ th.AssertDeepEquals(t, &os.ExampleConfig, config)
+}
+
+func TestCreate(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, _baseURL, "POST", os.CreateReq, os.CreateConfigJSON, 200)
+
+ opts := os.CreateOpts{
+ Datastore: &os.DatastoreOpts{
+ Type: "a00000a0-00a0-0a00-00a0-000a000000aa",
+ Version: "b00000b0-00b0-0b00-00b0-000b000000bb",
+ },
+ Description: "example description",
+ Name: "example-configuration-name",
+ Values: map[string]interface{}{
+ "collation_server": "latin1_swedish_ci",
+ "connect_timeout": 120,
+ },
+ }
+
+ config, err := Create(fake.ServiceClient(), opts).Extract()
+ th.AssertNoErr(t, err)
+ th.AssertDeepEquals(t, &os.ExampleConfigWithValues, config)
+}
+
+func TestUpdate(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, resURL, "PATCH", os.UpdateReq, "", 200)
+
+ opts := os.UpdateOpts{
+ Values: map[string]interface{}{
+ "connect_timeout": 300,
+ },
+ }
+
+ err := Update(fake.ServiceClient(), configID, opts).ExtractErr()
+ th.AssertNoErr(t, err)
+}
+
+func TestReplace(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, resURL, "PUT", os.UpdateReq, "", 202)
+
+ opts := os.UpdateOpts{
+ Values: map[string]interface{}{
+ "connect_timeout": 300,
+ },
+ }
+
+ err := Replace(fake.ServiceClient(), configID, opts).ExtractErr()
+ th.AssertNoErr(t, err)
+}
+
+func TestDelete(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, resURL, "DELETE", "", "", 202)
+
+ err := Delete(fake.ServiceClient(), configID).ExtractErr()
+ th.AssertNoErr(t, err)
+}
+
+func TestListInstances(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, resURL+"/instances", "GET", "", os.ListInstancesJSON, 200)
+
+ expectedInstance := instances.Instance{
+ ID: "d4603f69-ec7e-4e9b-803f-600b9205576f",
+ Name: "json_rack_instance",
+ }
+
+ pages := 0
+ err := ListInstances(fake.ServiceClient(), configID).EachPage(func(page pagination.Page) (bool, error) {
+ pages++
+
+ actual, err := instances.ExtractInstances(page)
+ if err != nil {
+ return false, err
+ }
+
+ th.AssertDeepEquals(t, actual, []instances.Instance{expectedInstance})
+
+ return true, nil
+ })
+
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, 1, pages)
+}
+
+func TestListDSParams(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, dsParamListURL, "GET", "", os.ListParamsJSON, 200)
+
+ pages := 0
+ err := ListDatastoreParams(fake.ServiceClient(), dsID, versionID).EachPage(func(page pagination.Page) (bool, error) {
+ pages++
+
+ actual, err := os.ExtractParams(page)
+ if err != nil {
+ return false, err
+ }
+
+ expected := []os.Param{
+ os.Param{Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer"},
+ os.Param{Max: 4294967296, Min: 0, Name: "key_buffer_size", RestartRequired: false, Type: "integer"},
+ os.Param{Max: 65535, Min: 2, Name: "connect_timeout", RestartRequired: false, Type: "integer"},
+ os.Param{Max: 4294967296, Min: 0, Name: "join_buffer_size", RestartRequired: false, Type: "integer"},
+ }
+
+ th.AssertDeepEquals(t, actual, expected)
+
+ return true, nil
+ })
+
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, 1, pages)
+}
+
+func TestGetDSParam(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, dsParamGetURL, "GET", "", os.GetParamJSON, 200)
+
+ param, err := GetDatastoreParam(fake.ServiceClient(), dsID, versionID, paramID).Extract()
+ th.AssertNoErr(t, err)
+
+ expected := &os.Param{
+ Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer",
+ }
+
+ th.AssertDeepEquals(t, expected, param)
+}
+
+func TestListGlobalParams(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, globalParamListURL, "GET", "", os.ListParamsJSON, 200)
+
+ pages := 0
+ err := ListGlobalParams(fake.ServiceClient(), versionID).EachPage(func(page pagination.Page) (bool, error) {
+ pages++
+
+ actual, err := os.ExtractParams(page)
+ if err != nil {
+ return false, err
+ }
+
+ expected := []os.Param{
+ os.Param{Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer"},
+ os.Param{Max: 4294967296, Min: 0, Name: "key_buffer_size", RestartRequired: false, Type: "integer"},
+ os.Param{Max: 65535, Min: 2, Name: "connect_timeout", RestartRequired: false, Type: "integer"},
+ os.Param{Max: 4294967296, Min: 0, Name: "join_buffer_size", RestartRequired: false, Type: "integer"},
+ }
+
+ th.AssertDeepEquals(t, actual, expected)
+
+ return true, nil
+ })
+
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, 1, pages)
+}
+
+func TestGetGlobalParam(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ fixture.SetupHandler(t, globalParamGetURL, "GET", "", os.GetParamJSON, 200)
+
+ param, err := GetGlobalParam(fake.ServiceClient(), versionID, paramID).Extract()
+ th.AssertNoErr(t, err)
+
+ expected := &os.Param{
+ Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer",
+ }
+
+ th.AssertDeepEquals(t, expected, param)
+}
diff --git a/rackspace/db/v1/configurations/doc.go b/rackspace/db/v1/configurations/doc.go
new file mode 100644
index 0000000..48c51d6
--- /dev/null
+++ b/rackspace/db/v1/configurations/doc.go
@@ -0,0 +1 @@
+package configurations