Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gems/smithy-client/lib/smithy-client/api_key_signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def sign_request(context)
end
end

def presign_url(_context)
def presign_url(*args)
raise NotImplementedError
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def sign_request(context)
context.http_request.headers['Authorization'] = "Bearer #{provider.identity.token}"
end

def presign_url(_context)
def presign_url(*args)
raise NotImplementedError
end
end
Expand Down
2 changes: 1 addition & 1 deletion gems/smithy-client/lib/smithy-client/login_signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def sign_request(context)
sign_with_basic(context.http_request, context.config.login_provider)
end

def presign_url(_context)
def presign_url(*args)
raise NotImplementedError
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ module <%= module_name %>
<% param.docstrings.each do |docstring| -%>
# <%= docstring %>
<% end -%>
#
# @return [<%= param.documentation_type %>]
#
<% end -%>
EndpointParameters = Struct.new(
<% parameters.each do |param| -%>
Expand All @@ -24,7 +22,7 @@ module <%= module_name %>
self.<%= param.name %> = options.fetch(:<%= param.name %>, <%= param.default_value %>)
<% end -%>
<% parameters.select(&:validate_required?).each do |param| -%>
raise ArgumentError, "Missing required EndpointParameter: :<%= param.name %>" if <%= param.name %>.nil?
raise ArgumentError, "missing required parameter: :<%= param.name %>" if <%= param.name %>.nil?
<% end -%>
end

Expand Down
15 changes: 9 additions & 6 deletions gems/smithy/lib/smithy/templates/client/endpoint_plugin.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ module <%= module_name %>
module Plugins
# @api private
class Endpoint < Smithy::Client::Plugin
option(
:endpoint,
doc_type: 'String',
docstring: <<~DOCS
The endpoint to send requests to.
The endpoint should be a URI formatted like "http://example.com:123"'
DOCS
)

option(
:endpoint_provider,
doc_type: '#resolve(parameters)',
Expand All @@ -16,12 +25,6 @@ module <%= module_name %>
EndpointProvider.new
end

<% parameters.select(&:built_in?).each do |param| -%>
<% param.built_in_binding[:render_config].call(plan).split("\n").each do |line| -%>
<%= line %>
<% end -%>

<% end -%>
<% parameters.select(&:client_context?).each do |param| -%>
option(
:<%= param.name %>,
Expand Down
14 changes: 5 additions & 9 deletions gems/smithy/lib/smithy/views/client/endpoint_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ def module_name

def initialize_rules(service)
@endpoint_rules = service['traits']['smithy.rules#endpointRuleSet']

@parameters = @endpoint_rules['parameters']
.map { |id, data| EndpointParameter.new(id, data, @plan) }
@parameters = @endpoint_rules['parameters'].map { |id, data| EndpointParameter.new(id, data, @plan) }
end

def initialize_tests(service)
@endpoint_tests = service['traits']['smithy.rules#endpointTests'] || {}
@test_cases = @endpoint_tests['testCases']
&.map { |data| EndpointTestCase.new(data, @plan, @operations) } || []
@test_cases = @endpoint_tests.fetch('testCases', []).map do |data|
EndpointTestCase.new(data, @plan, @operations)
end
end

# @api private
Expand Down Expand Up @@ -100,10 +99,7 @@ def find_input(data, operations)
end

def built_in_bindings
@built_in_bindings ||=
@plan.welds
.map(&:endpoint_built_in_bindings)
.reduce({}, :merge)
@built_in_bindings ||= @plan.welds.map(&:endpoint_built_in_bindings).reduce({}, :merge)
end

def built_in_to_param(built_in, value)
Expand Down
7 changes: 5 additions & 2 deletions gems/smithy/lib/smithy/weld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ def remove_dependencies

# Called when constructing endpoint parameters. Any bindings defined here will
# be merged with other built-in bindings. The key is the name of the binding, and
# the value is the binding definition, which is a hash with keys :render_config,
# :render_build and :render_test_set.
# the value is the binding definition, which is a hash with keys :render_build and
# :render_test_set. :render_build is a proc that takes the plan as an argument and returns
# a string that is rendered in the endpoint parameters `.create` method. :render_test_set
# is a proc that takes the plan and the value of the built-in parameter as arguments,
# and returns a hash of parameters to be added to the test set.
# @return [Hash<String, Hash>] endpoint built in bindings for use in endpoint rules.
def endpoint_built_in_bindings
{}
Expand Down
9 changes: 0 additions & 9 deletions gems/smithy/lib/smithy/welds/transforms/endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ def pre_process(model)
def endpoint_built_in_bindings
{
'SDK::Endpoint' => {
render_config: proc do |_plan|
<<~ADD_OPTION
option(
:endpoint,
doc_type: String,
docstring: 'Custom Endpoint'
)
ADD_OPTION
end,
render_build: proc do |_plan|
'config.endpoint'
end,
Expand Down
3 changes: 2 additions & 1 deletion projections/shapes/lib/shapes/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class Client < Smithy::Client::Base
# @option options [Boolean] :disable_request_compression
# When `true`, the request body will not be compressed for supported operations.
# @option options [String] :endpoint
# Custom Endpoint
# The endpoint to send requests to.
# The endpoint should be a URI formatted like "http://example.com:123"'
# @option options [#resolve(parameters)] :endpoint_provider (ShapeService::EndpointProvider)
# An object that provides an endpoint to use for the request.
# @option options [String] :http_ca_file
Expand Down
2 changes: 0 additions & 2 deletions projections/shapes/lib/shapes/endpoint_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ module ShapeService
# Endpoint parameters used to resolve endpoints per request.
# @!attribute endpoint
# Endpoint used for making requests. Should be formatted as a URI.
#
# @return [String]
#
EndpointParameters = Struct.new(
:endpoint,
keyword_init: true
Expand Down
15 changes: 9 additions & 6 deletions projections/shapes/lib/shapes/plugins/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ module ShapeService
module Plugins
# @api private
class Endpoint < Smithy::Client::Plugin
option(
:endpoint,
doc_type: 'String',
docstring: <<~DOCS
The endpoint to send requests to.
The endpoint should be a URI formatted like "http://example.com:123"'
DOCS
)

option(
:endpoint_provider,
doc_type: '#resolve(parameters)',
Expand All @@ -16,12 +25,6 @@ class Endpoint < Smithy::Client::Plugin
EndpointProvider.new
end

option(
:endpoint,
doc_type: String,
docstring: 'Custom Endpoint'
)

option(:endpoint_auth_schemes) do
{"bearer" => "smithy.api#httpBearerAuth", "none" => "smithy.api#noAuth"}
end
Expand Down
3 changes: 2 additions & 1 deletion projections/weather/lib/weather/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class Client < Smithy::Client::Base
# @option options [Boolean] :disable_request_compression
# When `true`, the request body will not be compressed for supported operations.
# @option options [String] :endpoint
# Custom Endpoint
# The endpoint to send requests to.
# The endpoint should be a URI formatted like "http://example.com:123"'
# @option options [#resolve(parameters)] :endpoint_provider (Weather::EndpointProvider)
# An object that provides an endpoint to use for the request.
# @option options [String] :http_ca_file
Expand Down
2 changes: 0 additions & 2 deletions projections/weather/lib/weather/endpoint_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ module Weather
# Endpoint parameters used to resolve endpoints per request.
# @!attribute endpoint
# Endpoint used for making requests. Should be formatted as a URI.
#
# @return [String]
#
EndpointParameters = Struct.new(
:endpoint,
keyword_init: true
Expand Down
15 changes: 9 additions & 6 deletions projections/weather/lib/weather/plugins/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ module Weather
module Plugins
# @api private
class Endpoint < Smithy::Client::Plugin
option(
:endpoint,
doc_type: 'String',
docstring: <<~DOCS
The endpoint to send requests to.
The endpoint should be a URI formatted like "http://example.com:123"'
DOCS
)

option(
:endpoint_provider,
doc_type: '#resolve(parameters)',
Expand All @@ -16,12 +25,6 @@ class Endpoint < Smithy::Client::Plugin
EndpointProvider.new
end

option(
:endpoint,
doc_type: String,
docstring: 'Custom Endpoint'
)

option(:endpoint_auth_schemes) do
{"bearer" => "smithy.api#httpBearerAuth", "none" => "smithy.api#noAuth"}
end
Expand Down