Jamie Hannaford | 936a547 | 2015-02-10 14:38:28 +0100 | [diff] [blame] | 1 | package instances |
| 2 | |
| 3 | import ( |
Jamie Hannaford | 936a547 | 2015-02-10 14:38:28 +0100 | [diff] [blame] | 4 | "github.com/rackspace/gophercloud" |
Jamie Hannaford | 302c0b6 | 2015-02-16 14:12:34 +0100 | [diff] [blame] | 5 | "github.com/rackspace/gophercloud/pagination" |
Jamie Hannaford | 2e81732 | 2015-02-16 15:29:17 +0100 | [diff] [blame] | 6 | "github.com/rackspace/gophercloud/rackspace/db/v1/backups" |
Jamie Hannaford | 936a547 | 2015-02-10 14:38:28 +0100 | [diff] [blame] | 7 | ) |
| 8 | |
| 9 | func GetDefaultConfig(client *gophercloud.ServiceClient, id string) ConfigResult { |
| 10 | var res ConfigResult |
| 11 | |
Jamie Hannaford | a50d135 | 2015-02-18 11:38:38 +0100 | [diff] [blame] | 12 | _, res.Err = client.Request("GET", configURL(client, id), gophercloud.RequestOpts{ |
| 13 | JSONResponse: &res.Body, |
| 14 | OkCodes: []int{200}, |
Jamie Hannaford | 936a547 | 2015-02-10 14:38:28 +0100 | [diff] [blame] | 15 | }) |
| 16 | |
Jamie Hannaford | 936a547 | 2015-02-10 14:38:28 +0100 | [diff] [blame] | 17 | return res |
| 18 | } |
Jamie Hannaford | f77fc10 | 2015-02-10 14:56:02 +0100 | [diff] [blame] | 19 | |
| 20 | func AssociateWithConfigGroup(client *gophercloud.ServiceClient, instanceID, configGroupID string) UpdateResult { |
| 21 | reqBody := map[string]string{ |
| 22 | "configuration": configGroupID, |
| 23 | } |
| 24 | |
| 25 | var res UpdateResult |
| 26 | |
Jamie Hannaford | a50d135 | 2015-02-18 11:38:38 +0100 | [diff] [blame] | 27 | _, res.Err = client.Request("PUT", resourceURL(client, instanceID), gophercloud.RequestOpts{ |
| 28 | JSONBody: map[string]map[string]string{"instance": reqBody}, |
| 29 | OkCodes: []int{202}, |
Jamie Hannaford | f77fc10 | 2015-02-10 14:56:02 +0100 | [diff] [blame] | 30 | }) |
| 31 | |
Jamie Hannaford | f77fc10 | 2015-02-10 14:56:02 +0100 | [diff] [blame] | 32 | return res |
| 33 | } |
Jamie Hannaford | 302c0b6 | 2015-02-16 14:12:34 +0100 | [diff] [blame] | 34 | |
| 35 | func ListBackups(client *gophercloud.ServiceClient, instanceID string) pagination.Pager { |
Jamie Hannaford | 2e81732 | 2015-02-16 15:29:17 +0100 | [diff] [blame] | 36 | pageFn := func(r pagination.PageResult) pagination.Page { |
| 37 | return backups.BackupPage{pagination.SinglePageBase(r)} |
| 38 | } |
| 39 | return pagination.NewPager(client, backupsURL(client, instanceID), pageFn) |
Jamie Hannaford | 302c0b6 | 2015-02-16 14:12:34 +0100 | [diff] [blame] | 40 | } |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 41 | |
| 42 | func DetachReplica(client *gophercloud.ServiceClient, replicaID string) DetachResult { |
| 43 | var res DetachResult |
| 44 | |
Jamie Hannaford | a50d135 | 2015-02-18 11:38:38 +0100 | [diff] [blame] | 45 | _, res.Err = client.Request("PATCH", resourceURL(client, replicaID), gophercloud.RequestOpts{ |
| 46 | JSONBody: map[string]interface{}{"instance": map[string]string{"replica_of": "", "slave_of": ""}}, |
| 47 | OkCodes: []int{202}, |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 48 | }) |
| 49 | |
| 50 | return res |
| 51 | } |