Skip to content

Commit c012501

Browse files
author
Matt Muller
committed
URI -> URL for endpoint rules
1 parent b8e7a8e commit c012501

16 files changed

Lines changed: 21 additions & 33 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ module EndpointRules
1616

1717
# An Endpoint resolved by an EndpointProvider
1818
class Endpoint
19-
# @param [String] uri
19+
# @param [String] url
2020
# @param [Hash] properties ({})
2121
# @param [Hash] headers ({})
22-
def initialize(uri:, properties: {}, headers: {})
23-
@uri = uri
22+
def initialize(url:, properties: {}, headers: {})
23+
@url = url
2424
@properties = properties
2525
@headers = headers
2626
end
2727

28-
# The URI of the endpoint.
28+
# The URL of the endpoint.
2929
# @return [String]
30-
attr_accessor :uri
30+
attr_accessor :url
3131

3232
# The authentication schemes supported by the endpoint.
3333
# @return [Hash]

gems/smithy-client/spec/smithy-client/endpoint_rules_spec.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@
55
module Smithy
66
module Client
77
describe EndpointRules do
8-
describe EndpointRules::Endpoint do
9-
describe '#initialize' do
10-
it 'sets the uri and defaults other values' do
11-
uri = 'https://example.com'
12-
endpoint = EndpointRules::Endpoint.new(uri: uri)
13-
expect(endpoint.uri).to eq(uri)
14-
expect(endpoint.properties).to eq({})
15-
expect(endpoint.headers).to eq({})
16-
end
17-
end
18-
end
19-
208
describe '.valid_host_label?' do
219
it 'returns false for an empty value' do
2210
expect(EndpointRules.valid_host_label?('', false)).to be false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module <%= module_name %>
4949
private
5050

5151
def apply_endpoint(context, endpoint)
52-
context.http_request.endpoint = endpoint.uri
52+
context.http_request.endpoint = endpoint.url
5353
endpoint.headers.each do |key, value|
5454
context.http_request.headers[key] = value
5555
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module <%= module_name %>
2222
end.to raise_error(ArgumentError, expected['error'])
2323
<% else -%>
2424
endpoint = subject.resolve(params)
25-
expect(endpoint.uri).to eq(expected['endpoint']['url'])
25+
expect(endpoint.url).to eq(expected['endpoint']['url'])
2626
expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {})
2727
expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {})
2828
<% end -%>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def endpoint_rule_with_condition(levels, rule)
6767

6868
def endpoint(endpoint, levels)
6969
res = StringIO.new
70-
res << "return Smithy::Client::EndpointRules::Endpoint.new(uri: #{str(endpoint['url'])}"
70+
res << "return Smithy::Client::EndpointRules::Endpoint.new(url: #{str(endpoint['url'])}"
7171
res << ", headers: #{templated_hash_to_s(endpoint['headers'])}" if endpoint['headers']
7272
res << ", properties: #{templated_hash_to_s(endpoint['properties'])}" if endpoint['properties']
7373
res << ")\n"

gems/smithy/spec/interfaces/client/endpoint_provider_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
endpoint = subject.resolve(params)
1919
expect(endpoint).to be_a(Smithy::Client::EndpointRules::Endpoint)
20-
expect(endpoint.uri).to eq('https://example.com/baz')
20+
expect(endpoint.url).to eq('https://example.com/baz')
2121
end
2222

2323
it 'raises errors from rules' do

projections/shapes/lib/shapes/auth_resolver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module ShapeService
66
# Resolves the auth scheme from {AuthParameters}.
77
class AuthResolver
88
# @param [AuthParameters] parameters
9-
# @return [Array<Hash>]
9+
# @return [Array<Smithy::Client::AuthOption>]
1010
def resolve(parameters)
1111
options = []
12-
options << { scheme_id: 'smithy.api#noAuth' }
12+
options << Smithy::Client::AuthOption.new(scheme_id: 'smithy.api#noAuth')
1313
options
1414
end
1515
end

projections/shapes/lib/shapes/endpoint_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class EndpointProvider
1010
# @raise [ArgumentError]
1111
def resolve(parameters)
1212
if Smithy::Client::EndpointRules.set?(parameters.endpoint)
13-
return Smithy::Client::EndpointRules::Endpoint.new(uri: parameters.endpoint)
13+
return Smithy::Client::EndpointRules::Endpoint.new(url: parameters.endpoint)
1414
end
1515
raise ArgumentError, "Endpoint is not set - you must configure an endpoint."
1616
end

projections/shapes/lib/shapes/plugins/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def call(context)
4141
private
4242

4343
def apply_endpoint(context, endpoint)
44-
context.http_request.endpoint = endpoint.uri
44+
context.http_request.endpoint = endpoint.url
4545
endpoint.headers.each do |key, value|
4646
context.http_request.headers[key] = value
4747
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module ShapeService
22
class AuthResolver
3-
def resolve: (AuthParameters) -> Array[String]
3+
def resolve: (AuthParameters) -> Array[Smithy::Client::AuthOption]
44
end
55
end

0 commit comments

Comments
 (0)