Feature/filestorage securityservices list (#134)
* sfs: Add support for security services List
* sfs: Add acceptance tests for security service List
* sfs: Remove extra parameters for security service list
After taking a closer look at the code, some parameters
seem to be filtered out during the list request. They
have now been filtered out.
* sfs: Fix unit tests
* sfs: Use SecurityServiceType for ListOpts Type
diff --git a/openstack/sharedfilesystems/v2/securityservices/results.go b/openstack/sharedfilesystems/v2/securityservices/results.go
index 6874208..ab9da7d 100644
--- a/openstack/sharedfilesystems/v2/securityservices/results.go
+++ b/openstack/sharedfilesystems/v2/securityservices/results.go
@@ -5,6 +5,7 @@
"time"
"github.com/gophercloud/gophercloud"
+ "github.com/gophercloud/gophercloud/pagination"
)
// SecurityService contains all the information associated with an OpenStack
@@ -61,6 +62,27 @@
gophercloud.Result
}
+// SecurityServicePage is a pagination.pager that is returned from a call to the List function.
+type SecurityServicePage struct {
+ pagination.SinglePageBase
+}
+
+// IsEmpty returns true if a ListResult contains no SecurityServices.
+func (r SecurityServicePage) IsEmpty() (bool, error) {
+ securityServices, err := ExtractSecurityServices(r)
+ return len(securityServices) == 0, err
+}
+
+// ExtractSecurityServices extracts and returns SecurityServices. It is used while
+// iterating over a securityservices.List call.
+func ExtractSecurityServices(r pagination.Page) ([]SecurityService, error) {
+ var s struct {
+ SecurityServices []SecurityService `json:"security_services"`
+ }
+ err := (r.(SecurityServicePage)).ExtractInto(&s)
+ return s.SecurityServices, err
+}
+
// Extract will get the SecurityService object out of the commonResult object.
func (r commonResult) Extract() (*SecurityService, error) {
var s struct {