github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/iec/v1/sites/results.go (about)

     1  package sites
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk/openstack/iec/v1/common"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  // Sites 站点集合
     9  type Sites struct {
    10  	// 数量
    11  	Count int32 `json:"count"`
    12  
    13  	Sites []common.Site `json:"sites"`
    14  }
    15  
    16  // SitePage is the page returned by a pager when traversing over a collection
    17  // of sites.
    18  type SitePage struct {
    19  	pagination.LinkedPageBase
    20  }
    21  
    22  // IsEmpty returns true if a page contains no site results.
    23  func (r SitePage) IsEmpty() (bool, error) {
    24  	s, err := ExtractSites(r)
    25  	return s.Count == 0, err
    26  }
    27  
    28  // ExtractSites interprets the results of a single page from a List() call,
    29  // producing a slice of site entities.
    30  func ExtractSites(r pagination.Page) (Sites, error) {
    31  	var s Sites
    32  	err := r.(SitePage).ExtractInto(&s)
    33  	return s, err
    34  }