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