7 "github.com/gophercloud/gophercloud"
10 // MarkerPage is a stricter Page interface that describes additional functionality required for use with NewMarkerPager.
11 // For convenience, embed the MarkedPageBase struct.
12 type MarkerPage interface {
15 // LastMarker returns the last "marker" value on this page.
16 LastMarker() (string, error)
19 // MarkerPageBase is a page in a collection that's paginated by "limit" and "marker" query parameters.
20 type MarkerPageBase struct {
23 // Owner is a reference to the embedding struct.
27 // NextPageURL generates the URL for the page of results after this one.
28 func (current MarkerPageBase) NextPageURL() (string, error) {
29 currentURL := current.URL
31 mark, err := current.Owner.LastMarker()
36 q := currentURL.Query()
38 currentURL.RawQuery = q.Encode()
40 return currentURL.String(), nil
43 // IsEmpty satisifies the IsEmpty method of the Page interface
44 func (current MarkerPageBase) IsEmpty() (bool, error) {
45 if b, ok := current.Body.([]interface{}); ok {
46 return len(b) == 0, nil
48 err := gophercloud.ErrUnexpectedType{}
49 err.Expected = "[]interface{}"
50 err.Actual = fmt.Sprintf("%v", reflect.TypeOf(current.Body))
54 // GetBody returns the linked page's body. This method is needed to satisfy the
56 func (current MarkerPageBase) GetBody() interface{} {