class Aws::RestBodyHandler
@api private
Public Instance Methods
call(context)
click to toggle source
@param [Seahorse::Client::RequestContext] context @return [Seahorse::Client::Response]
# File lib/aws-sdk-core/rest_body_handler.rb, line 7 def call(context) context.http_request.body = build_body(context) @handler.call(context).on_success do |response| response.data = extract_data(response.context) unless response.data end end
Private Instance Methods
body_contents(context)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 82 def body_contents(context) context.http_response.body_contents end
body_members_shape(shape)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 48 def body_members_shape(shape) if shape.payload shape.payload_member else members = shape.members.each.with_object({}) do |(name, member), hash| if member.location == 'body' hash[name.to_s] = member.definition end end definition = shape.definition.merge('members' => members) options = { shape_map: shape.shape_map } Seahorse::Model::Shapes::Shape.new(definition, options) end end
body_params(shape, params)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 63 def body_params(shape, params) shape.members.each.with_object({}) do |(member_name, member_shape), hash| if member_shape.location == 'body' hash[member_name] = params[member_name] if params.key?(member_name) end end end
build_body(context)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 16 def build_body(context) input = context.operation.input case when input.nil? nil when streaming?(input) context.params[input.payload] when input.payload params = context.params[input.payload] || {} serialize_params(input.payload_member, params) unless params.empty? else params = body_params(input, context.params) serialize_params(input, params) unless params.empty? end end
extract_data(context)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 32 def extract_data(context) if output = context.operation.output data = Structure.new(output.member_names) if streaming?(output) data[output.payload] = context.http_response.body elsif output.payload data[output.payload] = parse(context, output.payload_member) else parse(context, output, data) end data else EmptyStructure.new end end
parse(context, shape, target = nil)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 86 def parse(context, shape, target = nil) body = context.http_response.body_contents if body.bytesize == 0 nil else parse_body(body, shape, target) end end
parse_body(body, shape, target)
click to toggle source
@param [String] body @param [Seahorse::Model::Shapes::Structure] shape @param [Structure] target
# File lib/aws-sdk-core/rest_body_handler.rb, line 98 def parse_body(body, shape, target) raise NotImplementedError, 'must be defiend in sublcasses' end
serialize_params(shape, params)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 78 def serialize_params(shape, params) raise NotImplementedError, 'must be defiend in sublcasses' end
streaming?(shape)
click to toggle source
# File lib/aws-sdk-core/rest_body_handler.rb, line 71 def streaming?(shape) shape.payload && ( Seahorse::Model::Shapes::Blob === shape.payload_member || Seahorse::Model::Shapes::String === shape.payload_member ) end