Class: Aws::Plugins::JsonvalueConverter::Handler Private

Inherits:
Seahorse::Client::Handler show all
Defined in:
lib/aws-sdk-core/plugins/jsonvalue_converter.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Handler

#handler

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Handler

#initialize, #inspect

Constructor Details

This class inherits a constructor from Seahorse::Client::Handler

Instance Method Details

#call(context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
# File 'lib/aws-sdk-core/plugins/jsonvalue_converter.rb', line 12

def call(context)
  context.operation.input.shape.members.each do |m, ref|
    convert_jsonvalue(m, ref, context.params, 'params')
  end
  @handler.call(context)
end

#convert_jsonvalue(m, ref, params, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/aws-sdk-core/plugins/jsonvalue_converter.rb', line 19

def convert_jsonvalue(m, ref, params, context)
  return if params.nil? || !params.key?(m)

  if ref['jsonvalue']
    params[m] = serialize_jsonvalue(params[m], "#{context}[#{m}]")
  else
    case ref.shape
    when Seahorse::Model::Shapes::StructureShape
      ref.shape.members.each do |member_m, ref|
        convert_jsonvalue(member_m, ref, params[m], "#{context}[#{m}]")
      end
    when Seahorse::Model::Shapes::ListShape
      if ref.shape.member['jsonvalue']
        params[m] = params[m].each_with_index.map do |v, i|
          serialize_jsonvalue(v, "#{context}[#{m}][#{i}]")
        end
      end
    when Seahorse::Model::Shapes::MapShape
      if ref.shape.value['jsonvalue']
        params[m].each do |k, v|
          params[m][k] = serialize_jsonvalue(v, "#{context}[#{m}][#{k}]")
        end
      end
    end
  end
end

#serialize_jsonvalue(v, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
50
51
# File 'lib/aws-sdk-core/plugins/jsonvalue_converter.rb', line 46

def serialize_jsonvalue(v, context)
  unless v.respond_to?(:to_json)
    raise ArgumentError, "The value of #{context} is not JSON serializable."
  end
  v.to_json
end