Class: Amazon::Coral::AwsQueryHandler
- Defined in:
- lib/amazon/coral/awsqueryhandler.rb
Instance Method Summary collapse
- #after(job) ⇒ Object
- #before(job) ⇒ Object
-
#initialize(args = {}) ⇒ AwsQueryHandler
constructor
A new instance of AwsQueryHandler.
Constructor Details
#initialize(args = {}) ⇒ AwsQueryHandler
Returns a new instance of AwsQueryHandler.
17 18 19 20 21 22 |
# File 'lib/amazon/coral/awsqueryhandler.rb', line 17 def initialize(args = {}) @api_version = args[:api_version] @content_type = args[:content_type] @log = LogFactory.getLog('Amazon::Coral::AwsQueryHandler') end |
Instance Method Details
#after(job) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/amazon/coral/awsqueryhandler.rb', line 44 def after(job) operation_name = job.request[:operation_name] reply = job.reply @log.info "Received response body: #{reply[:value]}" json_result = nil begin if @content_type == 'JSON' then json_result = JSON::Lexer.new(reply[:value]).nextvalue reply[:value] = get_value(operation_name, json_result) else reply[:value] = convert_to_json(reply[:value]) end rescue code = reply[:http_status_code] = reply[:http_status_message] raise "#{code} : #{}" unless code.to_i == 200 raise "Failed parsing response: #{$!}\n" end aws_error?(reply[:response], reply[:value]) if @content_type != 'JSON' end |
#before(job) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/amazon/coral/awsqueryhandler.rb', line 24 def before(job) request = job.request operation_name = request[:operation_name] query_string_map = QueryStringMap.new(request[:value]) query_string_map['Action'] = operation_name.to_s if @content_type then query_string_map['ContentType'] = @content_type end if @api_version then query_string_map['Version'] = @api_version end request[:query_string_map] = query_string_map request[:http_verb] = 'POST' @log.info "Making request to operation #{operation_name} with parameters #{query_string_map}" end |