Sha256: 79d44eb7621f52ee05edda1adcf12078e58e5e4315ac6cb9cc8bd2dcb0483fad

Contents?: true

Size: 1.36 KB

Versions: 133

Compression:

Stored size: 1.36 KB

Contents

module Aws
  module Rest
    module Request
      class Builder

        def apply(context)
          populate_http_method(context)
          populate_endpoint(context)
          populate_headers(context)
          populate_body(context)
        end

        private

        def populate_http_method(context)
          context.http_request.http_method = context.operation.http_method
        end

        def populate_endpoint(context)
          context.http_request.endpoint = Endpoint.new(
            context.operation.input,
            context.operation.http_request_uri,
          ).uri(context.http_request.endpoint, context.params)
        end

        def populate_headers(context)
          headers = Headers.new(context.operation.input)
          headers.apply(context.http_request, context.params)
        end

        def populate_body(context)
          Body.new(
            serializer_class(context),
            context.operation.input
          ).apply(context.http_request, context.params)
        end

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

      end
    end
  end
end

Version data entries

133 entries across 133 versions & 1 rubygems

Version Path
aws-sdk-core-3.100.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.99.2 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.99.1 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.99.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.98.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.97.1 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.97.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.96.1 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.96.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.95.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.94.1 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.94.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.93.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.92.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.91.1 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.91.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.90.1 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.90.0 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.89.1 lib/aws-sdk-core/rest/request/builder.rb
aws-sdk-core-3.89.0 lib/aws-sdk-core/rest/request/builder.rb