Jamie Hannaford | 8252352 | 2015-02-17 16:53:29 +0100 | [diff] [blame] | 1 | package datastores |
| 2 | |
| 3 | import ( |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame^] | 4 | "github.com/gophercloud/gophercloud" |
| 5 | "github.com/gophercloud/gophercloud/pagination" |
Jamie Hannaford | 8252352 | 2015-02-17 16:53:29 +0100 | [diff] [blame] | 6 | ) |
| 7 | |
Jamie Hannaford | b0d267b | 2015-02-19 11:59:53 +0100 | [diff] [blame] | 8 | // List will list all available datastore types that instances can use. |
Jamie Hannaford | 8252352 | 2015-02-17 16:53:29 +0100 | [diff] [blame] | 9 | func List(client *gophercloud.ServiceClient) pagination.Pager { |
| 10 | pageFn := func(r pagination.PageResult) pagination.Page { |
| 11 | return DatastorePage{pagination.SinglePageBase(r)} |
| 12 | } |
| 13 | return pagination.NewPager(client, baseURL(client), pageFn) |
| 14 | } |
| 15 | |
Jamie Hannaford | b0d267b | 2015-02-19 11:59:53 +0100 | [diff] [blame] | 16 | // Get will retrieve the details of a specified datastore type. |
Jamie Hannaford | 8252352 | 2015-02-17 16:53:29 +0100 | [diff] [blame] | 17 | func Get(client *gophercloud.ServiceClient, datastoreID string) GetResult { |
| 18 | var res GetResult |
| 19 | |
| 20 | _, res.Err = client.Request("GET", resourceURL(client, datastoreID), gophercloud.RequestOpts{ |
| 21 | OkCodes: []int{200}, |
| 22 | JSONResponse: &res.Body, |
| 23 | }) |
| 24 | |
| 25 | return res |
| 26 | } |
| 27 | |
Jamie Hannaford | b0d267b | 2015-02-19 11:59:53 +0100 | [diff] [blame] | 28 | // ListVersions will list all of the available versions for a specified |
| 29 | // datastore type. |
Jamie Hannaford | 8252352 | 2015-02-17 16:53:29 +0100 | [diff] [blame] | 30 | func ListVersions(client *gophercloud.ServiceClient, datastoreID string) pagination.Pager { |
| 31 | pageFn := func(r pagination.PageResult) pagination.Page { |
| 32 | return VersionPage{pagination.SinglePageBase(r)} |
| 33 | } |
| 34 | return pagination.NewPager(client, versionsURL(client, datastoreID), pageFn) |
| 35 | } |
| 36 | |
Jamie Hannaford | b0d267b | 2015-02-19 11:59:53 +0100 | [diff] [blame] | 37 | // GetVersion will retrieve the details of a specified datastore version. |
Jamie Hannaford | 8252352 | 2015-02-17 16:53:29 +0100 | [diff] [blame] | 38 | func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) GetVersionResult { |
| 39 | var res GetVersionResult |
| 40 | |
| 41 | _, res.Err = client.Request("GET", versionURL(client, datastoreID, versionID), gophercloud.RequestOpts{ |
| 42 | OkCodes: []int{200}, |
| 43 | JSONResponse: &res.Body, |
| 44 | }) |
| 45 | |
| 46 | return res |
| 47 | } |