Finish DB docs for Rackspace
diff --git a/rackspace/db/v1/datastores/doc.go b/rackspace/db/v1/datastores/doc.go
index f36997a..ae14026 100644
--- a/rackspace/db/v1/datastores/doc.go
+++ b/rackspace/db/v1/datastores/doc.go
@@ -1 +1,3 @@
+// Package datastores provides information and interaction with the datastore
+// API resource in the Rackspace Database service.
package datastores
diff --git a/rackspace/db/v1/datastores/requests.go b/rackspace/db/v1/datastores/requests.go
index 767bdc3..9e147ab 100644
--- a/rackspace/db/v1/datastores/requests.go
+++ b/rackspace/db/v1/datastores/requests.go
@@ -5,6 +5,7 @@
"github.com/rackspace/gophercloud/pagination"
)
+// List will list all available datastore types that instances can use.
func List(client *gophercloud.ServiceClient) pagination.Pager {
pageFn := func(r pagination.PageResult) pagination.Page {
return DatastorePage{pagination.SinglePageBase(r)}
@@ -12,6 +13,7 @@
return pagination.NewPager(client, baseURL(client), pageFn)
}
+// Get will retrieve the details of a specified datastore type.
func Get(client *gophercloud.ServiceClient, datastoreID string) GetResult {
var res GetResult
@@ -23,6 +25,8 @@
return res
}
+// ListVersions will list all of the available versions for a specified
+// datastore type.
func ListVersions(client *gophercloud.ServiceClient, datastoreID string) pagination.Pager {
pageFn := func(r pagination.PageResult) pagination.Page {
return VersionPage{pagination.SinglePageBase(r)}
@@ -30,6 +34,7 @@
return pagination.NewPager(client, versionsURL(client, datastoreID), pageFn)
}
+// GetVersion will retrieve the details of a specified datastore version.
func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) GetVersionResult {
var res GetVersionResult
diff --git a/rackspace/db/v1/datastores/results.go b/rackspace/db/v1/datastores/results.go
index 31fd838..a86a3cc 100644
--- a/rackspace/db/v1/datastores/results.go
+++ b/rackspace/db/v1/datastores/results.go
@@ -6,12 +6,14 @@
"github.com/rackspace/gophercloud/pagination"
)
+// Version represents a version API resource. Multiple versions belong to a Datastore.
type Version struct {
ID string
Links []gophercloud.Link
Name string
}
+// Datastore represents a Datastore API resource.
type Datastore struct {
DefaultVersion string `json:"default_version" mapstructure:"default_version"`
ID string
@@ -20,24 +22,31 @@
Versions []Version
}
+// DatastorePartial is a meta structure which is used in various API responses.
+// It is a lightweight and truncated version of a full Datastore resource,
+// offering details of the Version, Type and VersionID only.
type DatastorePartial struct {
Version string
Type string
VersionID string `json:"version_id" mapstructure:"version_id"`
}
+// GetResult represents the result of a Get operation.
type GetResult struct {
gophercloud.Result
}
+// GetVersionResult represents the result of getting a version.
type GetVersionResult struct {
gophercloud.Result
}
+// DatastorePage represents a page of datastore resources.
type DatastorePage struct {
pagination.SinglePageBase
}
+// IsEmpty indicates whether a Datastore collection is empty.
func (r DatastorePage) IsEmpty() (bool, error) {
is, err := ExtractDatastores(r)
if err != nil {
@@ -46,6 +55,8 @@
return len(is) == 0, nil
}
+// ExtractDatastores retrieves a slice of datastore structs from a paginated
+// collection.
func ExtractDatastores(page pagination.Page) ([]Datastore, error) {
casted := page.(DatastorePage).Body
@@ -57,6 +68,7 @@
return resp.Datastores, err
}
+// Extract retrieves a single Datastore struct from an operation result.
func (r GetResult) Extract() (*Datastore, error) {
if r.Err != nil {
return nil, r.Err
@@ -70,10 +82,12 @@
return &response.Datastore, err
}
+// DatastorePage represents a page of version resources.
type VersionPage struct {
pagination.SinglePageBase
}
+// IsEmpty indicates whether a collection of version resources is empty.
func (r VersionPage) IsEmpty() (bool, error) {
is, err := ExtractVersions(r)
if err != nil {
@@ -82,6 +96,7 @@
return len(is) == 0, nil
}
+// ExtractVersions retrieves a slice of versions from a paginated collection.
func ExtractVersions(page pagination.Page) ([]Version, error) {
casted := page.(VersionPage).Body
@@ -93,6 +108,7 @@
return resp.Versions, err
}
+// Extract retrieves a single Version struct from an operation result.
func (r GetVersionResult) Extract() (*Version, error) {
if r.Err != nil {
return nil, r.Err