class Aws::Stubbing::Protocols::Rest
Public Instance Methods
stub_data(api, operation, data)
click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/rest.rb, line 8 def stub_data(api, operation, data) resp = new_http_response apply_status_code(operation, resp, data) apply_headers(operation, resp, data) apply_body(api, operation, resp, data) resp end
Private Instance Methods
apply_body(api, operation, resp, data)
click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/rest.rb, line 37 def apply_body(api, operation, resp, data) resp.body = build_body(api, operation, data) end
apply_headers(operation, resp, data)
click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/rest.rb, line 33 def apply_headers(operation, resp, data) Aws::Rest::Request::Headers.new(operation.output).apply(resp, data) end
apply_status_code(operation, resp, data)
click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/rest.rb, line 25 def apply_status_code(operation, resp, data) operation.output.shape.members.each do |member_name, member_ref| if member_ref.location == 'statusCode' resp.status_code = data[member_name] if data.key?(member_name) end end end
build_body(api, operation, data)
click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/rest.rb, line 41 def build_body(api, operation, data) rules = operation.output if streaming?(rules) data[rules[:payload]] elsif rules[:payload] body_for(api, operation, rules[:payload_member], data[rules[:payload]]) else body_for(api, operation, rules, data) end end
new_http_response()
click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/rest.rb, line 18 def new_http_response resp = Seahorse::Client::Http::Response.new resp.status_code = 200 resp.headers["x-amzn-RequestId"] = "stubbed-request-id" resp end
streaming?(ref)
click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/rest.rb, line 52 def streaming?(ref) if ref[:payload] case ref[:payload_member].shape when StringShape then true when BlobShape then true else false end else false end end