Sha256: 44b925ce0f32415004c6b138dd64349f41fcfb5369b2233e4aa658a7ac8ab3ce

Contents?: true

Size: 1.34 KB

Versions: 997

Compression:

Stored size: 1.34 KB

Contents

module Aws
  module Rest
    module Response
      class Parser

        def apply(response)
          # TODO : remove this unless check once response stubbing is fixed
          unless response.data
            response.data = response.context.operation.output[:struct_class].new
          end
          extract_status_code(response)
          extract_headers(response)
          extract_body(response)
        end

        private

        def extract_status_code(response)
          status_code = StatusCode.new(response.context.operation.output)
          status_code.apply(response.context.http_response, response.data)
        end

        def extract_headers(response)
          headers = Headers.new(response.context.operation.output)
          headers.apply(response.context.http_response, response.data)
        end

        def extract_body(response)
          Body.new(
            parser_class(response),
            response.context.operation.output,
          ).apply(response.context.http_response.body, response.data)
        end

        def parser_class(response)
          protocol = response.context.config.api.metadata['protocol']
          case protocol
          when 'rest-xml' then Xml::Parser
          when 'rest-json' then Json::Parser
          else raise "unsupported protocol #{protocol}"
          end
        end

      end
    end
  end
end

Version data entries

997 entries across 997 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.631 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.630 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.629 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.628 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.627 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.626 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.625 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.624 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.623 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.622 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.621 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.620 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.619 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.618 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.617 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.616 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.615 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.614 lib/aws-sdk-core/rest/response/parser.rb
aws-sdk-core-2.11.613 lib/aws-sdk-core/rest/response/parser.rb