Skip to content

Commit a99d010

Browse files
author
Matt Muller
committed
Make endpoint a built in and do not generate built ins
1 parent b89efc8 commit a99d010

14 files changed

Lines changed: 45 additions & 50 deletions

File tree

gems/smithy-client/lib/smithy-client/api_key_signer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def sign_request(context)
2424
end
2525
end
2626

27-
def presign_url(_context)
27+
def presign_url(*args)
2828
raise NotImplementedError
2929
end
3030

gems/smithy-client/lib/smithy-client/bearer_token_signer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def sign_request(context)
1010
context.http_request.headers['Authorization'] = "Bearer #{provider.identity.token}"
1111
end
1212

13-
def presign_url(_context)
13+
def presign_url(*args)
1414
raise NotImplementedError
1515
end
1616
end

gems/smithy-client/lib/smithy-client/login_signer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def sign_request(context)
1717
sign_with_basic(context.http_request, context.config.login_provider)
1818
end
1919

20-
def presign_url(_context)
20+
def presign_url(*args)
2121
raise NotImplementedError
2222
end
2323

gems/smithy/lib/smithy/templates/client/endpoint_parameters.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ module <%= module_name %>
99
<% param.docstrings.each do |docstring| -%>
1010
# <%= docstring %>
1111
<% end -%>
12-
#
1312
# @return [<%= param.documentation_type %>]
14-
#
1513
<% end -%>
1614
EndpointParameters = Struct.new(
1715
<% parameters.each do |param| -%>
@@ -24,7 +22,7 @@ module <%= module_name %>
2422
self.<%= param.name %> = options.fetch(:<%= param.name %>, <%= param.default_value %>)
2523
<% end -%>
2624
<% parameters.select(&:validate_required?).each do |param| -%>
27-
raise ArgumentError, "Missing required EndpointParameter: :<%= param.name %>" if <%= param.name %>.nil?
25+
raise ArgumentError, "missing required parameter: :<%= param.name %>" if <%= param.name %>.nil?
2826
<% end -%>
2927
end
3028

gems/smithy/lib/smithy/templates/client/endpoint_plugin.erb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ module <%= module_name %>
66
module Plugins
77
# @api private
88
class Endpoint < Smithy::Client::Plugin
9+
option(
10+
:endpoint,
11+
doc_type: 'String',
12+
docstring: <<~DOCS
13+
The endpoint to send requests to.
14+
The endpoint should be a URI formatted like "http://example.com:123"'
15+
DOCS
16+
)
17+
918
option(
1019
:endpoint_provider,
1120
doc_type: '#resolve(parameters)',
@@ -16,12 +25,6 @@ module <%= module_name %>
1625
EndpointProvider.new
1726
end
1827

19-
<% parameters.select(&:built_in?).each do |param| -%>
20-
<% param.built_in_binding[:render_config].call(plan).split("\n").each do |line| -%>
21-
<%= line %>
22-
<% end -%>
23-
24-
<% end -%>
2528
<% parameters.select(&:client_context?).each do |param| -%>
2629
option(
2730
:<%= param.name %>,

gems/smithy/lib/smithy/views/client/endpoint_provider_spec.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ def module_name
2525

2626
def initialize_rules(service)
2727
@endpoint_rules = service['traits']['smithy.rules#endpointRuleSet']
28-
29-
@parameters = @endpoint_rules['parameters']
30-
.map { |id, data| EndpointParameter.new(id, data, @plan) }
28+
@parameters = @endpoint_rules['parameters'].map { |id, data| EndpointParameter.new(id, data, @plan) }
3129
end
3230

3331
def initialize_tests(service)
3432
@endpoint_tests = service['traits']['smithy.rules#endpointTests'] || {}
35-
@test_cases = @endpoint_tests['testCases']
36-
&.map { |data| EndpointTestCase.new(data, @plan, @operations) } || []
33+
@test_cases = @endpoint_tests.fetch('testCases', []).map do |data|
34+
EndpointTestCase.new(data, @plan, @operations)
35+
end
3736
end
3837

3938
# @api private
@@ -100,10 +99,7 @@ def find_input(data, operations)
10099
end
101100

102101
def built_in_bindings
103-
@built_in_bindings ||=
104-
@plan.welds
105-
.map(&:endpoint_built_in_bindings)
106-
.reduce({}, :merge)
102+
@built_in_bindings ||= @plan.welds.map(&:endpoint_built_in_bindings).reduce({}, :merge)
107103
end
108104

109105
def built_in_to_param(built_in, value)

gems/smithy/lib/smithy/weld.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ def remove_dependencies
5050

5151
# Called when constructing endpoint parameters. Any bindings defined here will
5252
# be merged with other built-in bindings. The key is the name of the binding, and
53-
# the value is the binding definition, which is a hash with keys :render_config,
54-
# :render_build and :render_test_set.
53+
# the value is the binding definition, which is a hash with keys :render_build and
54+
# :render_test_set. :render_build is a proc that takes the plan as an argument and returns
55+
# a string that is rendered in the endpoint parameters `.create` method. :render_test_set
56+
# is a proc that takes the plan and the value of the built-in parameter as arguments,
57+
# and returns a hash of parameters to be added to the test set.
5558
# @return [Hash<String, Hash>] endpoint built in bindings for use in endpoint rules.
5659
def endpoint_built_in_bindings
5760
{}

gems/smithy/lib/smithy/welds/transforms/endpoints.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ def pre_process(model)
1515
def endpoint_built_in_bindings
1616
{
1717
'SDK::Endpoint' => {
18-
render_config: proc do |_plan|
19-
<<~ADD_OPTION
20-
option(
21-
:endpoint,
22-
doc_type: String,
23-
docstring: 'Custom Endpoint'
24-
)
25-
ADD_OPTION
26-
end,
2718
render_build: proc do |_plan|
2819
'config.endpoint'
2920
end,

projections/shapes/lib/shapes/client.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class Client < Smithy::Client::Base
6767
# @option options [Boolean] :disable_request_compression
6868
# When `true`, the request body will not be compressed for supported operations.
6969
# @option options [String] :endpoint
70-
# Custom Endpoint
70+
# The endpoint to send requests to.
71+
# The endpoint should be a URI formatted like "http://example.com:123"'
7172
# @option options [#resolve(parameters)] :endpoint_provider (ShapeService::EndpointProvider)
7273
# An object that provides an endpoint to use for the request.
7374
# @option options [String] :http_ca_file

projections/shapes/lib/shapes/endpoint_parameters.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ module ShapeService
66
# Endpoint parameters used to resolve endpoints per request.
77
# @!attribute endpoint
88
# Endpoint used for making requests. Should be formatted as a URI.
9-
#
109
# @return [String]
11-
#
1210
EndpointParameters = Struct.new(
1311
:endpoint,
1412
keyword_init: true

0 commit comments

Comments
 (0)