blob: 9e147ab2dbf168c518b9092cc915f79c11a32ca6 [file] [log] [blame]
Jamie Hannaford82523522015-02-17 16:53:29 +01001package datastores
2
3import (
4 "github.com/rackspace/gophercloud"
5 "github.com/rackspace/gophercloud/pagination"
6)
7
Jamie Hannafordb0d267b2015-02-19 11:59:53 +01008// List will list all available datastore types that instances can use.
Jamie Hannaford82523522015-02-17 16:53:29 +01009func 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 Hannafordb0d267b2015-02-19 11:59:53 +010016// Get will retrieve the details of a specified datastore type.
Jamie Hannaford82523522015-02-17 16:53:29 +010017func 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 Hannafordb0d267b2015-02-19 11:59:53 +010028// ListVersions will list all of the available versions for a specified
29// datastore type.
Jamie Hannaford82523522015-02-17 16:53:29 +010030func 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 Hannafordb0d267b2015-02-19 11:59:53 +010037// GetVersion will retrieve the details of a specified datastore version.
Jamie Hannaford82523522015-02-17 16:53:29 +010038func 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}