generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathendpoints.rb
More file actions
66 lines (57 loc) · 2.14 KB
/
endpoints.rb
File metadata and controls
66 lines (57 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true
module Smithy
module Welds
# Provides default endpoint builtin/function bindings.
class Endpoints < Weld
def pre_process(model)
id, service = model['shapes'].select { |_k, s| s['type'] == 'service' }.first
return if service['traits'] && service['traits']['smithy.rules#endpointRuleSet']
say_status :insert, "Adding default endpoint rules to service #{id}", :yellow unless @plan.quiet
add_default_endpoints(service)
end
def endpoint_built_in_bindings
{
'SDK::Endpoint' => {
render_build: proc do |_plan|
'config.endpoint'
end,
render_test_set: proc do |_plan, value|
{ 'endpoint' => value }
end
}
}
end
def endpoint_function_bindings
{
'isValidHostLabel' => 'Smithy::Client::EndpointRules.valid_host_label?',
'parseURL' => 'Smithy::Client::EndpointRules.parse_url',
'substring' => 'Smithy::Client::EndpointRules.substring',
'uriEncode' => 'Smithy::Client::EndpointRules.uri_encode',
'isSet' => 'Smithy::Client::EndpointRules.set?',
'not' => 'Smithy::Client::EndpointRules.not?',
'getAttr' => 'Smithy::Client::EndpointRules.attr',
'stringEquals' => 'Smithy::Client::EndpointRules.string_equals?',
'booleanEquals' => 'Smithy::Client::EndpointRules.boolean_equals?'
}
end
def endpoint_auth_scheme_bindings
{
'bearer' => 'smithy.api#httpBearerAuth',
'none' => 'smithy.api#noAuth'
}
end
private
def add_default_endpoints(service)
service['traits'] ||= {}
service['traits']['smithy.rules#endpointRuleSet'] = default_endpoint_rules
service['traits']['smithy.rules#endpointTests'] = default_endpoint_tests
end
def default_endpoint_rules
JSON.load_file(File.join(__dir__.to_s, 'default_endpoint_rules.json'))
end
def default_endpoint_tests
JSON.load_file(File.join(__dir__.to_s, 'default_endpoint_tests.json'))
end
end
end
end