class Aws::Rest::Request::Endpoint
def apply_path_params(uri, params)
def apply_path_params(uri, params) path = uri.path.sub(/\/$/, '') + @path_pattern.split('?')[0] uri.path = path.gsub(/{.+?}/) do |placeholder| param_value_for_placeholder(placeholder, params) end end
def apply_querystring_params(uri, params)
def apply_querystring_params(uri, params) # collect params that are supposed to be part of the query string parts = @rules.shape.members.inject([]) do |prts, (member_name, member_ref)| if member_ref.location == 'querystring' && !params[member_name].nil? prts << [member_ref, params[member_name]] end prts end querystring = QuerystringBuilder.new.build(parts) querystring = [@query_prefix, querystring == '' ? nil : querystring].compact.join('&') querystring = nil if querystring == '' uri.query = querystring end
def escape(string)
def escape(string) Seahorse::Util.uri_escape(string) end
def initialize(rules, request_uri_pattern)
-
request_uri_pattern
(String
) -- -
rules
(Seahorse::Model::Shapes::ShapeRef
) --
def initialize(rules, request_uri_pattern) @rules = rules request_uri_pattern.split('?').tap do |path_part, query_part| @path_pattern = path_part @query_prefix = query_part end end
def param_name(placeholder)
def param_name(placeholder) location_name = placeholder.gsub(/[{}+]/,'') param_name, _ = @rules.shape.member_by_location_name(location_name) param_name end
def param_value_for_placeholder(placeholder, params)
def param_value_for_placeholder(placeholder, params) name = param_name(placeholder) value = params[name].to_s raise ArgumentError, ":#{name} must not be blank" if value.empty? if placeholder.include?('+') value.gsub(/[^\/]+/) { |v| escape(v) } else escape(value) end end
def uri(base_uri, params)
-
(URI::HTTPS, URI::HTTP)
-
Parameters:
-
params
(Hash, Struct
) -- -
base_uri
(URI::HTTPS, URI::HTTP
) --
def uri(base_uri, params) uri = URI.parse(base_uri.to_s) apply_path_params(uri, params) apply_querystring_params(uri, params) uri end