blob: 134e30907687f3e127af839a4ffdaa3b825671c0 [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.
Jon Perritt3860b512016-03-29 12:01:48 -050016func Get(client *gophercloud.ServiceClient, datastoreID string) (r GetResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060017 _, r.Err = client.Get(resourceURL(client, datastoreID), &r.Body, nil)
jrperritt29ae6b32016-04-13 12:59:37 -050018 return
Jamie Hannaford82523522015-02-17 16:53:29 +010019}
20
Jamie Hannafordb0d267b2015-02-19 11:59:53 +010021// ListVersions will list all of the available versions for a specified
22// datastore type.
Jamie Hannaford82523522015-02-17 16:53:29 +010023func ListVersions(client *gophercloud.ServiceClient, datastoreID string) pagination.Pager {
Jon Perrittdb0ae142016-03-13 00:33:41 -060024 return pagination.NewPager(client, versionsURL(client, datastoreID), func(r pagination.PageResult) pagination.Page {
Jamie Hannaford82523522015-02-17 16:53:29 +010025 return VersionPage{pagination.SinglePageBase(r)}
Jon Perrittdb0ae142016-03-13 00:33:41 -060026 })
Jamie Hannaford82523522015-02-17 16:53:29 +010027}
28
Jamie Hannafordb0d267b2015-02-19 11:59:53 +010029// GetVersion will retrieve the details of a specified datastore version.
Jon Perritt3860b512016-03-29 12:01:48 -050030func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) (r GetVersionResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060031 _, r.Err = client.Get(versionURL(client, datastoreID, versionID), &r.Body, nil)
jrperritt29ae6b32016-04-13 12:59:37 -050032 return
Jamie Hannaford82523522015-02-17 16:53:29 +010033}