# File lib/aws-sdk-core/api/docs/shared_example.rb, line 9 def initialize(params, method_name, operation, comments) @params = params @method_name = method_name @operation = operation @comments = comments @params ||= {} end
# File lib/aws-sdk-core/api/docs/shared_example.rb, line 17 def to_str_input lines = structure(@params, @operation.input, "", []) params = lines.join("\n") "resp = client.#{@method_name}(#{params})" end
# File lib/aws-sdk-core/api/docs/shared_example.rb, line 23 def to_str_output lines = structure(@params, @operation.output, "", []) params = lines.join("\n") "#{params}" end
# File lib/aws-sdk-core/api/docs/shared_example.rb, line 88 def apply_comments(path) key = path.join().sub(/^\./, '') if @comments && @comments[key] "# #{@comments[key]}" else "" end end
# File lib/aws-sdk-core/api/docs/shared_example.rb, line 31 def entry(json, ref, indent, path) case ref.shape when StructureShape then structure(json, ref, indent, path) when MapShape then map(json, ref, indent, path) when ListShape then list(json, ref, indent, path) when TimestampShape then "Time.parse(#{json.inspect})" when StringShape, BlobShape then json.inspect else json end end
# File lib/aws-sdk-core/api/docs/shared_example.rb, line 73 def list(json, ref, indent, path) lines = ["["] json.each_with_index do |member, index| path << "[#{index}]" shape_val = entry(member, ref.shape.member, "#{indent} ", path) if shape_val.is_a?(Array) shape_val = shape_val.join("\n") end lines << "#{indent} #{shape_val}, #{apply_comments(path)}" path.pop end lines << "#{indent}]" lines end
# File lib/aws-sdk-core/api/docs/shared_example.rb, line 58 def map(json, ref, indent, path) lines = ["{"] json.each do |key, val| path << ".#{key}" shape_val = entry(val, ref.shape.value, "#{indent} ", path) if shape_val.is_a?(Array) shape_val = shape_val.join("\n") end lines << "#{indent} \"#{key}\" => #{shape_val}, #{apply_comments(path)}" path.pop end lines << "#{indent}}" lines end
# File lib/aws-sdk-core/api/docs/shared_example.rb, line 42 def structure(json, ref, indent, path) lines = ["{"] json.each do |key, val| path << ".#{key}" sc_key = Seahorse::Util.underscore(key) shape_val = entry(val, ref.shape.member(sc_key), "#{indent} ", path) if shape_val.is_a?(Array) shape_val = shape_val.join("\n") end lines << "#{indent} #{sc_key}: #{shape_val}, #{apply_comments(path)}" path.pop end lines << "#{indent}}" lines end