Jamie Hannaford | 8252352 | 2015-02-17 16:53:29 +0100 | [diff] [blame] | 1 | package datastores |
| 2 | |
| 3 | import ( |
| 4 | "github.com/rackspace/gophercloud" |
| 5 | "github.com/rackspace/gophercloud/pagination" |
| 6 | ) |
| 7 | |
| 8 | func List(client *gophercloud.ServiceClient) pagination.Pager { |
| 9 | pageFn := func(r pagination.PageResult) pagination.Page { |
| 10 | return DatastorePage{pagination.SinglePageBase(r)} |
| 11 | } |
| 12 | return pagination.NewPager(client, baseURL(client), pageFn) |
| 13 | } |
| 14 | |
| 15 | func Get(client *gophercloud.ServiceClient, datastoreID string) GetResult { |
| 16 | var res GetResult |
| 17 | |
| 18 | _, res.Err = client.Request("GET", resourceURL(client, datastoreID), gophercloud.RequestOpts{ |
| 19 | OkCodes: []int{200}, |
| 20 | JSONResponse: &res.Body, |
| 21 | }) |
| 22 | |
| 23 | return res |
| 24 | } |
| 25 | |
| 26 | func ListVersions(client *gophercloud.ServiceClient, datastoreID string) pagination.Pager { |
| 27 | pageFn := func(r pagination.PageResult) pagination.Page { |
| 28 | return VersionPage{pagination.SinglePageBase(r)} |
| 29 | } |
| 30 | return pagination.NewPager(client, versionsURL(client, datastoreID), pageFn) |
| 31 | } |
| 32 | |
| 33 | func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) GetVersionResult { |
| 34 | var res GetVersionResult |
| 35 | |
| 36 | _, res.Err = client.Request("GET", versionURL(client, datastoreID, versionID), gophercloud.RequestOpts{ |
| 37 | OkCodes: []int{200}, |
| 38 | JSONResponse: &res.Body, |
| 39 | }) |
| 40 | |
| 41 | return res |
| 42 | } |