Adding get port operation
diff --git a/openstack/networking/v2/apiversions/doc.go b/openstack/networking/v2/apiversions/doc.go
index 76bdb14..9ec7ea2 100644
--- a/openstack/networking/v2/apiversions/doc.go
+++ b/openstack/networking/v2/apiversions/doc.go
@@ -1 +1,3 @@
+// Package apiversions provides information and interaction with the different
+// API versions for the Neutron OpenStack service.
package apiversions
diff --git a/openstack/networking/v2/apiversions/requests.go b/openstack/networking/v2/apiversions/requests.go
index 31e07fd..570b9e8 100644
--- a/openstack/networking/v2/apiversions/requests.go
+++ b/openstack/networking/v2/apiversions/requests.go
@@ -5,12 +5,15 @@
"github.com/rackspace/gophercloud/pagination"
)
+// ListVersions lists all the Neutron API versions available to end-users
func ListVersions(c *gophercloud.ServiceClient) pagination.Pager {
return pagination.NewPager(c, APIVersionsURL(c), func(r pagination.LastHTTPResponse) pagination.Page {
return APIVersionPage{pagination.SinglePageBase(r)}
})
}
+// ListVersionResources lists all of the different API resources for a particular
+// API versions. Typical resources for Neutron might be: networks, subnets, etc.
func ListVersionResources(c *gophercloud.ServiceClient, v string) pagination.Pager {
return pagination.NewPager(c, APIInfoURL(c, v), func(r pagination.LastHTTPResponse) pagination.Page {
return APIVersionResourcePage{pagination.SinglePageBase(r)}
diff --git a/openstack/networking/v2/apiversions/results.go b/openstack/networking/v2/apiversions/results.go
index 9181e7e..0ab3b41 100644
--- a/openstack/networking/v2/apiversions/results.go
+++ b/openstack/networking/v2/apiversions/results.go
@@ -5,15 +5,20 @@
"github.com/rackspace/gophercloud/pagination"
)
+// APIVersion represents an API version for Neutron. It contains the status of
+// the API, and its unique ID.
type APIVersion struct {
Status string `mapstructure:"status" json:"status"`
ID string `mapstructure:"id" json:"id"`
}
+// APIVersionPage is the page returned by a pager when traversing over a
+// collection of API versions.
type APIVersionPage struct {
pagination.SinglePageBase
}
+// IsEmpty checks whether the page is empty.
func (r APIVersionPage) IsEmpty() (bool, error) {
is, err := ExtractAPIVersions(r)
if err != nil {
@@ -22,6 +27,8 @@
return len(is) == 0, nil
}
+// ExtractAPIVersion takes a collection page, extracts all of the elements,
+// and returns them a slice of APIVersion structs. It is effectively a cast.
func ExtractAPIVersions(page pagination.Page) ([]APIVersion, error) {
var resp struct {
Versions []APIVersion `mapstructure:"versions"`
@@ -35,6 +42,8 @@
return resp.Versions, nil
}
+// APIVersionResource represents a generic API resource. It contains the name
+// of the resource and its plural collection name.
type APIVersionResource struct {
Name string `mapstructure:"name" json:"name"`
Collection string `mapstructure:"collection" json:"collection"`