github.com/gophercloud/gophercloud@v1.11.0/openstack/identity/v3/catalog/results.go (about) 1 package catalog 2 3 import ( 4 "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" 5 "github.com/gophercloud/gophercloud/pagination" 6 ) 7 8 // ServiceCatalogPage is a single page of Service results. 9 type ServiceCatalogPage struct { 10 pagination.LinkedPageBase 11 } 12 13 // IsEmpty returns true if the ServiceCatalogPage contains no results. 14 func (r ServiceCatalogPage) IsEmpty() (bool, error) { 15 if r.StatusCode == 204 { 16 return true, nil 17 } 18 19 services, err := ExtractServiceCatalog(r) 20 return len(services) == 0, err 21 } 22 23 // ExtractServiceCatalog extracts a slice of Catalog from a Collection acquired from List. 24 func ExtractServiceCatalog(r pagination.Page) ([]tokens.CatalogEntry, error) { 25 var s struct { 26 Entries []tokens.CatalogEntry `json:"catalog"` 27 } 28 err := (r.(ServiceCatalogPage)).ExtractInto(&s) 29 return s.Entries, err 30 }