class Aws::PageableResponse


incompatible changes.
paging rules, then you should not worry about backwards
and subject to change. If you are not providing custom
The structure of ‘:paging_rules` should be considered unstable
PageableResponse public methods should be considered stable.
@stability Unstable
unless the configured member is `true`.
When `truncated_if` is configured, the tokens will not be checked,<br><br>paging_rules = ’is_truncated’
You can configure this via ‘truncated_if`:
response data value that indicates if the response is truncated.
When this is the case, they will typically provide some boolean
extract the final value from some list to request the next page.
Some services do not specify a token, but rather expect you to
### Truncation Indicator
is assumed to be the last page of results.
If all of the configured tokens return `nil` values, the response
it will be sent to the next page request as `:input_param`.
inspected for a `response_key` member. If it is present,
response data member names as values. The `response.data` is
Tokens should be a hash of request parameter names as keys, and
}
}
’input_param’ => ‘response_key’,
‘tokens’ => {
paging_rules = {
the ‘tokens` entry:
If you want to configure paging you must specify at least
### Tokens
#=> true
page.last_page?
page = PageableResponse.new(response, paging_rules: {})
# disables pagigng
will be disabled.
hash to the constructor. If the hash is empty, then paging
You can configure paging behavior by passing a `:paging_rules`
## Paging Rules
PageableResponse.new(response).data
response.data
# same
wrapped response.
You can still access all of the attributes and methods of the
#=> raises PageableResponse::LastPageError
page.next_page
page.last_page?(true)
page = page.next_page
# sends a request to receive the next response page
page.last_page?(false)
page = PageableResponse.new(response)
discover if there are additional response pages to be requested.
The pager becomes a delegate to the response that allows you to
the response context.
Typically, the paging configuration will already be present in
A pager is constructed with a response and a paging configuration.
## Basic Usage
A simple response pager.

def each_page(&block)

Returns:
  • (Enumerable, nil) - Returns a new Enumerable if no block is given.

Other tags:
    Yieldparam: response -
def each_page(&block)
  if block_given?
    response = self
    yield(response)
    until response.last_page?
      response = response.next_page
      yield(response)
    end
  else
    to_enum(__method__)
  end
end

def eql?(other)

Other tags:
    Api: - private
def eql?(other)
  other.is_a?(Seahorse::Client::Response) &&
  other.context == context &&
  other.data == data &&
  other.error == error
end

def initialize(response, options = {})

Options Hash: (**options)
  • :paging_rules (Hash) -- Defaults to the `paging`

Parameters:
  • response (Seahorse::Client::Response) --
def initialize(response, options = {})
  super(context:response.context, data:response.data, error:response.error)
  @paging_rules = options[:paging_rules]
end

def last_page?

Returns:
  • (Boolean) -
def last_page?
  !next_page?
end

def next_page(params = {})

Returns:
  • (Seahorse::Client::Response) -
def next_page(params = {})
  if last_page?
    raise LastPageError.new(self)
  else
    PageableResponse.new(next_response(params), paging_rules: paging_rules)
  end
end

def next_page?

Returns:
  • (Boolean) -
def next_page?
  @next_page = !!(pageable? && truncated?) if @next_page.nil?
  @next_page
end

def next_page_params(params)

Returns:
  • (Hash) - Returns the hash of request parameters for the

Parameters:
  • params (Hash) -- A hash of additional request params to
def next_page_params(params)
  context.params.merge(next_tokens.merge(params))
end

def next_response(params)

Returns:
  • (Seahorse::Client::Response) - Returns the next page of

Parameters:
  • params (Hash) -- A hash of additional request params to
def next_response(params)
  c = context
  req = c.client.build_request(c.operation_name, next_page_params(params))
  req.send_request
end

def next_tokens

Returns:
  • (Hash) - Extracts a hash of request parameters from
def next_tokens
  @next_tokens ||= begin
    paging_rules['tokens'].inject({}) do |tokens, (param, jamespath)|
      value = Jamespath.search(jamespath, data)
      tokens[param.to_sym] = value unless value.nil?
      tokens
    end
  end
end

def pageable?

Returns:
  • (Boolean) - Returns `true` if the API operation is pageable.
def pageable?
  paging_rules.key?('tokens')
end

def paging_rules

Returns:
  • (Hash, nil) - Returns the rules for paging this response.
def paging_rules
  @paging_rules ||= context.operation.metadata['paging'] || {}
end

def truncated?

Returns:
  • (Boolean) - Returns `true` if the response is truncated and
def truncated?
  if condition = paging_rules['truncated_if']
    Jamespath.search(condition, data)
  else
    !next_tokens.empty?
  end
end