module Aws::PageableResponse::Extension

def each(&block)

def each(&block)
  return enum_for(:each_page) unless block_given?
  response = self
  yield(response)
  until response.last_page?
    response = response.next_page
    yield(response)
  end
end

def last_page?

def last_page?
  if @last_page.nil?
    @last_page = !@pager.truncated?(self)
  end
  @last_page
end

def next_page(params = {})

def next_page(params = {})
  if last_page?
    raise LastPageError.new(self)
  else
    next_response(params)
  end
end

def next_page?

def next_page?
  !last_page?
end

def next_page_params(params)

def next_page_params(params)
  # Remove all previous tokens from original params
  # Sometimes a token can be nil and merge would not include it.
  tokens = @pager.tokens.values.map(&:to_sym)
  params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) }
  params_without_tokens.merge!(@pager.next_tokens(self).merge(params))
  params_without_tokens
end

def next_response(params)

def next_response(params)
  params = next_page_params(params)
  request = context.client.build_request(context.operation_name, params)
  Aws::Plugins::UserAgent.feature('paginator') do
    request.send_request
  end
end