blob: d8209157e33c690a450c281691801fea836d7cff [file] [log] [blame]
Jamie Hannaford82523522015-02-17 16:53:29 +01001package datastores
2
3import (
Jon Perritt27249f42016-02-18 10:35:59 -06004 "github.com/gophercloud/gophercloud"
5 "github.com/gophercloud/gophercloud/pagination"
Jamie Hannaford82523522015-02-17 16:53:29 +01006)
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 {
Jon Perrittdb0ae142016-03-13 00:33:41 -060010 return pagination.NewPager(client, baseURL(client), func(r pagination.PageResult) pagination.Page {
Jamie Hannaford82523522015-02-17 16:53:29 +010011 return DatastorePage{pagination.SinglePageBase(r)}
Jon Perrittdb0ae142016-03-13 00:33:41 -060012 })
Jamie Hannaford82523522015-02-17 16:53:29 +010013}
14
Jamie Hannafordb0d267b2015-02-19 11:59:53 +010015// Get will retrieve the details of a specified datastore type.
Jamie Hannaford82523522015-02-17 16:53:29 +010016func Get(client *gophercloud.ServiceClient, datastoreID string) GetResult {
Jon Perrittdb0ae142016-03-13 00:33:41 -060017 var r GetResult
18 _, r.Err = client.Get(resourceURL(client, datastoreID), &r.Body, nil)
19 return r
Jamie Hannaford82523522015-02-17 16:53:29 +010020}
21
Jamie Hannafordb0d267b2015-02-19 11:59:53 +010022// ListVersions will list all of the available versions for a specified
23// datastore type.
Jamie Hannaford82523522015-02-17 16:53:29 +010024func ListVersions(client *gophercloud.ServiceClient, datastoreID string) pagination.Pager {
Jon Perrittdb0ae142016-03-13 00:33:41 -060025 return pagination.NewPager(client, versionsURL(client, datastoreID), func(r pagination.PageResult) pagination.Page {
Jamie Hannaford82523522015-02-17 16:53:29 +010026 return VersionPage{pagination.SinglePageBase(r)}
Jon Perrittdb0ae142016-03-13 00:33:41 -060027 })
Jamie Hannaford82523522015-02-17 16:53:29 +010028}
29
Jamie Hannafordb0d267b2015-02-19 11:59:53 +010030// GetVersion will retrieve the details of a specified datastore version.
Jamie Hannaford82523522015-02-17 16:53:29 +010031func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) GetVersionResult {
Jon Perrittdb0ae142016-03-13 00:33:41 -060032 var r GetVersionResult
33 _, r.Err = client.Get(versionURL(client, datastoreID, versionID), &r.Body, nil)
34 return r
Jamie Hannaford82523522015-02-17 16:53:29 +010035}