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