blob: 767bdc373c2334c5287f1cd4830ba4ce57dd1e2e [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
8func 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
15func 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
26func 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
33func 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}