Struct: request.Pagination

import "../ibm-cos-sdk-go/aws/request"

Overview

A Pagination provides paginating of SDK API operations which are paginatable. Generally you should not use this type directly, but use the “Pages” API operations method to automatically perform pagination for you. Such as, “S3.ListObjectsPages”, and “S3.ListObjectsPagesWithContext” methods.

Pagination differs from a Paginator type in that pagination is the type that does the pagination between API operations, and Paginator defines the configuration that will be used per page request.

for p.Next() { data := p.Page().(*s3.ListObjectsOutput) // process the page's data // ... // break out of loop to stop fetching additional pages } return p.Err()

See service client API operation Pages methods for examples how the SDK will use the Pagination type.

Implemented Interfaces

s3crypto.Cipher, s3manager.ReadSeekerWriteTo, s3manager.WriterReadFrom

Structure Field Summary collapse

Method Summary collapse

Structure Field Details

EndPageOnSameToken bool

EndPageOnSameToken, when enabled, will allow the paginator to stop on token that are the same as its previous tokens.

Method Details

func (p *Pagination) Err() error

Err returns the error Pagination encountered when retrieving the next page.



69
70
71
// File 'aws/request/request_pagination.go', line 69

func (p *Pagination) Err() error { return p.err }

func (p *Pagination) HasNextPage() bool

HasNextPage will return true if Pagination is able to determine that the API operation has additional pages. False will be returned if there are no more pages remaining.

Will always return true if Next has not been called yet.



56
57
58
59
60
61
62
63
64
65
66
// File 'aws/request/request_pagination.go', line 56

func (p *Pagination) HasNextPage() bool { if !p.started { return true } hasNextPage := len(p.nextTokens) != 0 if p.EndPageOnSameToken { return hasNextPage && !awsutil.DeepEqual(p.nextTokens, p.prevTokens) } return hasNextPage }

func (p *Pagination) Next() bool

Next will attempt to retrieve the next page for the API operation. When a page is retrieved true will be returned. If the page cannot be retrieved, or there are no more pages false will be returned.

Use the Page method to retrieve the current page data. The data will need to be cast to the API operation's output type.

Use the Err method to determine if an error occurred if Page returns false.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// File 'aws/request/request_pagination.go', line 88

func (p *Pagination) Next() bool { if !p.HasNextPage() { return false } req, err := p.NewRequest() if err != nil { p.err = err return false } if p.started { for i, intok := range req.Operation.InputTokens { awsutil.SetValueAtPath(req.Params, intok, p.nextTokens[i]) } } p.started = true err = req.Send() if err != nil { p.err = err return false } p.prevTokens = p.nextTokens p.nextTokens = req.nextPageTokens() p.curPage = req.Data return true }

func (p *Pagination) Page() interface{}

Page returns the current page. Page should only be called after a successful call to Next. It is undefined what Page will return if Page is called after Next returns false.



76
77
78
// File 'aws/request/request_pagination.go', line 76

func (p *Pagination) Page() interface{} { return p.curPage }