class Aws::Waiters::Poller
@api private
for states matching one of its acceptors.
Polls a single API operation inspecting the response data and/or error
def acceptor_matches?(acceptor, response)
def acceptor_matches?(acceptor, response) send("matches_#{acceptor['matcher']}?", acceptor, response) end
def call(options = {})
-
(Array
-)
Options Hash:
(**options)
-
:params
(required, Hash
) -- -
:client
(required, Client
) --
Other tags:
- Example: A trival (bad) example of a waiter that polls indefinetly. -
def call(options = {}) response = send_request(options) @acceptors.each do |acceptor| if acceptor_matches?(acceptor, response) return [acceptor['state'].to_sym, response] end end [response.error ? :error : :retry, response] end
def initialize(options = {})
- Api: - private
def initialize(options = {}) @operation_name = underscore(options['operation']).to_sym @acceptors = options['acceptors'] || [] end
def matches_error?(acceptor, response)
def matches_error?(acceptor, response) Aws::Errors::ServiceError === response.error && response.error.code == acceptor['expected'].gsub('.', '') end
def matches_path?(acceptor, response)
def matches_path?(acceptor, response) if response.data JMESPath.search(path(acceptor), response.data) == acceptor['expected'] else false end end
def matches_pathAll?(acceptor, response)
def matches_pathAll?(acceptor, response) non_empty_array(acceptor, response) do |values| values.all? { |value| value == acceptor['expected'] } end end
def matches_pathAny?(acceptor, response)
def matches_pathAny?(acceptor, response) non_empty_array(acceptor, response) do |values| values.any? { |value| value == acceptor['expected'] } end end
def matches_status?(acceptor, response)
def matches_status?(acceptor, response) response.context.http_response.status_code == acceptor['expected'] end
def non_empty_array(acceptor, response, &block)
def non_empty_array(acceptor, response, &block) if response.data values = JMESPath.search(path(acceptor), response.data) Array === values && values.count > 0 ? yield(values) : false else false end end
def path(acceptor)
def path(acceptor) acceptor['argument'].gsub(/(?<![`'])\b\w+\b(?![`'])/) do |str| Seahorse::Util.underscore(str) end end
def send_request(options)
def send_request(options) req = options[:client].build_request(@operation_name, options[:params]) req.handlers.remove(RAISE_HANDLER) req.send_request end
def underscore(str)
def underscore(str) Seahorse::Util.underscore(str) end