aws-sdk-code-generator 0.2.2.pre → 0.3.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/aws-sdk-code-generator/api.rb +12 -2
- data/lib/aws-sdk-code-generator/client_constructor.rb +4 -1
- data/lib/aws-sdk-code-generator/client_operation_documentation.rb +27 -7
- data/lib/aws-sdk-code-generator/client_response_structure_example.rb +8 -1
- data/lib/aws-sdk-code-generator/code_builder.rb +78 -9
- data/lib/aws-sdk-code-generator/codegenerated_plugin.rb +34 -0
- data/lib/aws-sdk-code-generator/gem_builder.rb +27 -5
- data/lib/aws-sdk-code-generator/helper.rb +10 -1
- data/lib/aws-sdk-code-generator/plugin_list.rb +30 -9
- data/lib/aws-sdk-code-generator/service.rb +22 -0
- data/lib/aws-sdk-code-generator/views/async_client_class.rb +6 -2
- data/lib/aws-sdk-code-generator/views/client_api_module.rb +40 -5
- data/lib/aws-sdk-code-generator/views/client_class.rb +7 -2
- data/lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb +80 -0
- data/lib/aws-sdk-code-generator/views/endpoint_provider_class.rb +34 -0
- data/lib/aws-sdk-code-generator/views/endpoints_module.rb +177 -0
- data/lib/aws-sdk-code-generator/views/endpoints_plugin.rb +85 -0
- data/lib/aws-sdk-code-generator/views/gemspec.rb +6 -2
- data/lib/aws-sdk-code-generator/views/service_module.rb +22 -0
- data/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +198 -0
- data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -4
- data/lib/aws-sdk-code-generator/views/types_module.rb +60 -24
- data/lib/aws-sdk-code-generator.rb +7 -1
- data/templates/async_client_class.mustache +5 -7
- data/templates/client_api_module.mustache +7 -0
- data/templates/client_class.mustache +4 -1
- data/templates/endpoint_parameters_class.mustache +50 -0
- data/templates/endpoint_provider_class.mustache +30 -0
- data/templates/endpoints_module.mustache +33 -0
- data/templates/endpoints_plugin.mustache +76 -0
- data/templates/gemspec.mustache +2 -1
- data/templates/license.txt +202 -0
- data/templates/service_module.mustache +11 -1
- data/templates/spec/endpoint_provider_spec_class.mustache +76 -0
- data/templates/spec/spec_helper.mustache +5 -0
- data/templates/types_module.mustache +7 -0
- metadata +16 -4
@@ -0,0 +1,198 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module Spec
|
6
|
+
class EndpointProviderSpecClass < View
|
7
|
+
|
8
|
+
# @param [Hash] options
|
9
|
+
# @option options [required, Service] :service
|
10
|
+
def initialize(options)
|
11
|
+
@service = options.fetch(:service)
|
12
|
+
test_cases = @service.endpoint_tests.fetch('testCases', [])
|
13
|
+
@endpoint_tests = test_cases.map do |endpoint_test|
|
14
|
+
EndpointProviderTest.new(
|
15
|
+
service: @service,
|
16
|
+
documentation: endpoint_test['documentation'],
|
17
|
+
params: endpoint_test['params'],
|
18
|
+
tags: endpoint_test['tags'],
|
19
|
+
expect: endpoint_test['expect'],
|
20
|
+
operation_inputs: endpoint_test['operationInputs']
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Array<EndpointProviderTest>]
|
26
|
+
attr_reader :endpoint_tests
|
27
|
+
|
28
|
+
# @return [String|nil]
|
29
|
+
def generated_src_warning
|
30
|
+
return if @service.protocol == 'api-gateway'
|
31
|
+
GENERATED_SRC_WARNING
|
32
|
+
end
|
33
|
+
|
34
|
+
def module_name
|
35
|
+
@service.module_name
|
36
|
+
end
|
37
|
+
|
38
|
+
class EndpointProviderTest
|
39
|
+
def initialize(options)
|
40
|
+
@service = options[:service]
|
41
|
+
@documentation = options[:documentation]
|
42
|
+
@params = options[:params]&.map do |key, value|
|
43
|
+
[Underscore.underscore(key).to_sym, value]
|
44
|
+
end.to_h
|
45
|
+
@tags = options[:tags]
|
46
|
+
@expect = options[:expect]
|
47
|
+
operation_inputs = options[:operation_inputs] || []
|
48
|
+
@operation_inputs = operation_inputs.map do |operation_inputs_test|
|
49
|
+
OperationInputsTest.new(
|
50
|
+
service: @service,
|
51
|
+
operation_name: Underscore.underscore(
|
52
|
+
operation_inputs_test['operationName']
|
53
|
+
),
|
54
|
+
operation_params: operation_inputs_test['operationParams'] || [],
|
55
|
+
built_in_params: operation_inputs_test['builtInParams'] || [],
|
56
|
+
client_params: operation_inputs_test['clientParams'] || []
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [String]
|
62
|
+
attr_reader :documentation
|
63
|
+
|
64
|
+
# @return [Hash<Symbol, String>]
|
65
|
+
attr_reader :params
|
66
|
+
|
67
|
+
# @return [Array<String>]
|
68
|
+
attr_reader :tags
|
69
|
+
|
70
|
+
# @return [Hash]
|
71
|
+
attr_reader :expect
|
72
|
+
|
73
|
+
# # @return [Array<OperationInput>]
|
74
|
+
attr_reader :operation_inputs
|
75
|
+
|
76
|
+
def expect_error?
|
77
|
+
!@expect['error'].nil?
|
78
|
+
end
|
79
|
+
|
80
|
+
def expected_auth
|
81
|
+
if expect_auth?
|
82
|
+
@expect['endpoint']['properties']['authSchemes'].first
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def expect_auth?
|
87
|
+
@expect['endpoint'] &&
|
88
|
+
@expect['endpoint']['properties'] &&
|
89
|
+
@expect['endpoint']['properties']['authSchemes'] &&
|
90
|
+
!@expect['endpoint']['properties']['authSchemes'].empty?
|
91
|
+
end
|
92
|
+
|
93
|
+
def expected_headers
|
94
|
+
@expect['endpoint']['headers'].map { |k,v| Param.new(k, v.join(",")) }
|
95
|
+
end
|
96
|
+
|
97
|
+
def expect_headers?
|
98
|
+
@expect['endpoint'] &&
|
99
|
+
@expect['endpoint']['headers'] &&
|
100
|
+
!@expect['endpoint']['headers'].empty?
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
class OperationInputsTest
|
106
|
+
|
107
|
+
def initialize(options)
|
108
|
+
@service = options[:service]
|
109
|
+
@operation_name = options[:operation_name]
|
110
|
+
@operation_params = options[:operation_params].map do |k,v|
|
111
|
+
Param.new(Underscore.underscore(k), transform_operation_values(v))
|
112
|
+
end
|
113
|
+
@client_params = options[:client_params].map do |k,v|
|
114
|
+
Param.new(Underscore.underscore(k), v)
|
115
|
+
end
|
116
|
+
|
117
|
+
@client_params += options[:built_in_params].map do |k,v|
|
118
|
+
built_in_to_param(k, v)
|
119
|
+
end
|
120
|
+
# the expected default of UseGlobalEndpoint does not match the SDK's default value
|
121
|
+
if @service.identifier == 's3' && !options[:built_in_params].include?('AWS::S3::UseGlobalEndpoint')
|
122
|
+
@client_params << built_in_to_param('AWS::S3::UseGlobalEndpoint', false)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# @return String
|
127
|
+
attr_reader :operation_name
|
128
|
+
|
129
|
+
# @return [Hash<String, String>]
|
130
|
+
attr_reader :operation_params
|
131
|
+
|
132
|
+
# @return [Hash<String, String>]
|
133
|
+
attr_reader :client_params
|
134
|
+
|
135
|
+
private
|
136
|
+
def transform_operation_values(value)
|
137
|
+
case value
|
138
|
+
when Hash
|
139
|
+
value.each_with_object({}) do |(k, v), o|
|
140
|
+
o[Underscore.underscore(k)] = transform_operation_values(v)
|
141
|
+
end
|
142
|
+
when Array
|
143
|
+
value.map { |v| transform_operation_values(v) }
|
144
|
+
else
|
145
|
+
value
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def built_in_to_param(built_in, value)
|
150
|
+
case built_in
|
151
|
+
when 'AWS::Region'
|
152
|
+
Param.new('region', value)
|
153
|
+
when 'AWS::UseFIPS'
|
154
|
+
Param.new('use_fips_endpoint', value)
|
155
|
+
when 'AWS::UseDualStack'
|
156
|
+
Param.new('use_dualstack_endpoint', value)
|
157
|
+
when 'AWS::STS::UseGlobalEndpoint'
|
158
|
+
Param.new('sts_regional_endpoints', value ? 'legacy' : 'regional')
|
159
|
+
when 'AWS::S3::UseGlobalEndpoint'
|
160
|
+
Param.new('s3_us_east_1_regional_endpoint', value ? 'legacy' : 'regional')
|
161
|
+
when 'AWS::S3::Accelerate'
|
162
|
+
Param.new('use_accelerate_endpoint', value)
|
163
|
+
when 'AWS::S3::ForcePathStyle'
|
164
|
+
Param.new('force_path_style', value)
|
165
|
+
when 'AWS::S3::UseArnRegion'
|
166
|
+
Param.new('s3_use_arn_region', value)
|
167
|
+
when 'AWS::S3Control::UseArnRegion'
|
168
|
+
Param.new('s3_use_arn_region', value)
|
169
|
+
when 'AWS::S3::DisableMultiRegionAccessPoints'
|
170
|
+
Param.new('s3_disable_multiregion_access_points', value)
|
171
|
+
when 'SDK::Endpoint'
|
172
|
+
Param.new('endpoint', value)
|
173
|
+
else
|
174
|
+
raise ArgumentError, "#{built_in} not supported."
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
class Param
|
180
|
+
def initialize(param, value)
|
181
|
+
@param = param
|
182
|
+
@value = value
|
183
|
+
end
|
184
|
+
attr_accessor :param
|
185
|
+
|
186
|
+
def value
|
187
|
+
if @value.is_a? String
|
188
|
+
"'#{@value}'"
|
189
|
+
else
|
190
|
+
@value
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -9,13 +9,14 @@ module AwsSdkCodeGenerator
|
|
9
9
|
|
10
10
|
# @param [Hash] options
|
11
11
|
# @option options [required, Service] :service
|
12
|
+
# @option options[required, String] :aws_sdk_core_lib_path
|
12
13
|
def initialize(options)
|
13
|
-
service = options.fetch(:service)
|
14
|
-
@gem_name = service.gem_name
|
15
|
-
@gem_dependencies = service.gem_dependencies.map do |gem_name, _|
|
14
|
+
@service = options.fetch(:service)
|
15
|
+
@gem_name = @service.gem_name
|
16
|
+
@gem_dependencies = @service.gem_dependencies.map do |gem_name, _|
|
16
17
|
{ dependency: gem_name }
|
17
18
|
end
|
18
|
-
@custom = service.protocol == 'api-gateway'
|
19
|
+
@custom = @service.protocol == 'api-gateway'
|
19
20
|
end
|
20
21
|
|
21
22
|
attr_reader :gem_name
|
@@ -27,6 +28,10 @@ module AwsSdkCodeGenerator
|
|
27
28
|
GENERATED_SRC_WARNING
|
28
29
|
end
|
29
30
|
|
31
|
+
def included_in_core
|
32
|
+
@service.included_in_core?
|
33
|
+
end
|
34
|
+
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -13,6 +13,7 @@ module AwsSdkCodeGenerator
|
|
13
13
|
@service = options.fetch(:service)
|
14
14
|
@api = @service.api
|
15
15
|
@input_shapes = compute_input_shapes(@service.api)
|
16
|
+
@output_shapes = compute_output_shapes(@service.api)
|
16
17
|
end
|
17
18
|
|
18
19
|
# @return [String|nil]
|
@@ -47,7 +48,7 @@ module AwsSdkCodeGenerator
|
|
47
48
|
# eventstream shape will be inheriting from enumerator
|
48
49
|
if shape['eventstream']
|
49
50
|
list
|
50
|
-
elsif shape['type'] == 'structure'
|
51
|
+
elsif shape['type'] == 'structure' && !shape['document']
|
51
52
|
struct_members = struct_members(shape)
|
52
53
|
sensitive_params = struct_members.select(&:sensitive).map do |m|
|
53
54
|
m.member_name.to_sym
|
@@ -56,7 +57,8 @@ module AwsSdkCodeGenerator
|
|
56
57
|
class_name: shape_name,
|
57
58
|
members: struct_members,
|
58
59
|
sensitive_params: sensitive_params,
|
59
|
-
documentation: struct_class_docs(shape_name)
|
60
|
+
documentation: struct_class_docs(shape_name, shape),
|
61
|
+
union: shape['union']
|
60
62
|
)
|
61
63
|
else
|
62
64
|
list
|
@@ -71,7 +73,7 @@ module AwsSdkCodeGenerator
|
|
71
73
|
list << EventStreamClass.new(
|
72
74
|
class_name: shape_name,
|
73
75
|
types: struct_members(shape),
|
74
|
-
documentation: eventstream_class_docs(shape_name)
|
76
|
+
documentation: eventstream_class_docs(shape_name, shape)
|
75
77
|
)
|
76
78
|
else
|
77
79
|
list
|
@@ -97,19 +99,20 @@ module AwsSdkCodeGenerator
|
|
97
99
|
members
|
98
100
|
end
|
99
101
|
|
100
|
-
def struct_class_docs(shape_name)
|
102
|
+
def struct_class_docs(shape_name, shape)
|
101
103
|
join_docstrings([
|
102
104
|
html_to_markdown(Api.docstring(shape_name, @api)),
|
103
|
-
input_example_docs(shape_name),
|
105
|
+
input_example_docs(shape_name, shape),
|
106
|
+
output_example_docs(shape_name, shape),
|
104
107
|
attribute_macros_docs(shape_name),
|
105
108
|
see_also_tag(shape_name),
|
106
109
|
])
|
107
110
|
end
|
108
111
|
|
109
|
-
def eventstream_class_docs(shape_name)
|
112
|
+
def eventstream_class_docs(shape_name, shape)
|
110
113
|
join_docstrings([
|
111
114
|
html_to_markdown(Api.docstring(shape_name, @api)),
|
112
|
-
input_example_docs(shape_name),
|
115
|
+
input_example_docs(shape_name, shape),
|
113
116
|
eventstream_docs(shape_name),
|
114
117
|
see_also_tag(shape_name),
|
115
118
|
])
|
@@ -120,18 +123,32 @@ module AwsSdkCodeGenerator
|
|
120
123
|
" #event_types #=> Array, returns all modeled event types in the stream"
|
121
124
|
end
|
122
125
|
|
123
|
-
def
|
126
|
+
def output_example_docs(shape_name, shape)
|
127
|
+
if @output_shapes.include?(shape_name)
|
128
|
+
if shape['union']
|
129
|
+
"@note #{shape_name} is a union - when returned from an API call"\
|
130
|
+
' exactly one value will be set and the returned type will'\
|
131
|
+
" be a subclass of #{shape_name} corresponding to the set member."
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def input_example_docs(shape_name, shape)
|
124
137
|
if @input_shapes.include?(shape_name)
|
125
138
|
return if shape(shape_name)['members'].nil?
|
126
139
|
if shape(shape_name)['members'].empty?
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
140
|
+
'@api private'
|
141
|
+
elsif shape['union']
|
142
|
+
"@note #{shape_name} is a union - when making an API calls you"\
|
143
|
+
' must set exactly one of the members.'
|
144
|
+
# This doc block is no longer useful, but keeping for records
|
145
|
+
# else
|
146
|
+
# note = "@note When making an API call, you may pass #{shape_name}\n"
|
147
|
+
# note += " data as a hash:\n\n"
|
148
|
+
# note += ' ' + SyntaxExampleHash.new(
|
149
|
+
# shape: shape(shape_name),
|
150
|
+
# api: @service.api,
|
151
|
+
# ).format(' ')
|
135
152
|
end
|
136
153
|
end
|
137
154
|
end
|
@@ -172,11 +189,19 @@ module AwsSdkCodeGenerator
|
|
172
189
|
def compute_input_shapes(api)
|
173
190
|
inputs = Set.new
|
174
191
|
(api['operations'] || {}).each do |_, operation|
|
175
|
-
|
192
|
+
visit_shapes(operation['input'], inputs) if operation['input']
|
176
193
|
end
|
177
194
|
inputs
|
178
195
|
end
|
179
196
|
|
197
|
+
def compute_output_shapes(api)
|
198
|
+
outputs = Set.new
|
199
|
+
(api['operations'] || {}).each do |_, operation|
|
200
|
+
visit_shapes(operation['output'], outputs) if operation['output']
|
201
|
+
end
|
202
|
+
outputs
|
203
|
+
end
|
204
|
+
|
180
205
|
def idempotency_token?(member_ref)
|
181
206
|
member_ref['idempotencyToken'] || shape(member_ref)['idempotencyToken']
|
182
207
|
end
|
@@ -185,22 +210,22 @@ module AwsSdkCodeGenerator
|
|
185
210
|
"<p><b>A suitable default value is auto-generated.</b> You should normally not need to pass this option.</p>"
|
186
211
|
end
|
187
212
|
|
188
|
-
def
|
189
|
-
return if
|
190
|
-
|
213
|
+
def visit_shapes(shape_ref, shapes)
|
214
|
+
return if shapes.include?(shape_ref['shape']) # recursion
|
215
|
+
shapes << shape_ref['shape']
|
191
216
|
s = shape(shape_ref)
|
192
217
|
raise "cannot locate shape #{shape_ref['shape']}" if s.nil?
|
193
218
|
case s['type']
|
194
219
|
when 'structure'
|
195
220
|
return if s['members'].nil?
|
196
221
|
s['members'].each_pair do |_, member_ref|
|
197
|
-
|
222
|
+
visit_shapes(member_ref, shapes)
|
198
223
|
end
|
199
224
|
when 'list'
|
200
|
-
|
225
|
+
visit_shapes(s['member'], shapes)
|
201
226
|
when 'map'
|
202
|
-
|
203
|
-
|
227
|
+
visit_shapes(s['key'], shapes)
|
228
|
+
visit_shapes(s['value'], shapes)
|
204
229
|
end
|
205
230
|
end
|
206
231
|
|
@@ -245,6 +270,8 @@ module AwsSdkCodeGenerator
|
|
245
270
|
@members = options.fetch(:members)
|
246
271
|
@documentation = options.fetch(:documentation)
|
247
272
|
@sensitive_params = options.fetch(:sensitive_params)
|
273
|
+
@union = options.fetch(:union)
|
274
|
+
@members << StructMember.new(member_name: :unknown, member_class_name: 'Unknown') if @union
|
248
275
|
if @members.nil? || @members.empty?
|
249
276
|
@empty = true
|
250
277
|
else
|
@@ -265,6 +292,11 @@ module AwsSdkCodeGenerator
|
|
265
292
|
# @return [Array<Symbol>]
|
266
293
|
attr_accessor :sensitive_params
|
267
294
|
|
295
|
+
# @return [Boolean]
|
296
|
+
def union?
|
297
|
+
@union
|
298
|
+
end
|
299
|
+
|
268
300
|
# @return [Boolean]
|
269
301
|
def empty?
|
270
302
|
@empty
|
@@ -275,6 +307,7 @@ module AwsSdkCodeGenerator
|
|
275
307
|
|
276
308
|
def initialize(options)
|
277
309
|
@member_name = options.fetch(:member_name)
|
310
|
+
@member_class_name = AwsSdkCodeGenerator::Helper::pascal_case(@member_name)
|
278
311
|
@sensitive = options.fetch(:sensitive, false)
|
279
312
|
@last = false
|
280
313
|
end
|
@@ -285,6 +318,9 @@ module AwsSdkCodeGenerator
|
|
285
318
|
# @return [Boolean]
|
286
319
|
attr_accessor :sensitive
|
287
320
|
|
321
|
+
# @return [String]
|
322
|
+
attr_accessor :member_class_name
|
323
|
+
|
288
324
|
# @return [Boolean]
|
289
325
|
attr_accessor :last
|
290
326
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'aws-sdk-code-generator/api'
|
4
4
|
require_relative 'aws-sdk-code-generator/apply_docs'
|
5
|
+
require_relative 'aws-sdk-code-generator/codegenerated_plugin'
|
5
6
|
require_relative 'aws-sdk-code-generator/client_constructor'
|
6
7
|
require_relative 'aws-sdk-code-generator/client_operation_documentation'
|
7
8
|
require_relative 'aws-sdk-code-generator/client_operation_list'
|
@@ -53,9 +54,14 @@ require_relative 'aws-sdk-code-generator/views/features/smoke_step_definitions'
|
|
53
54
|
require_relative 'aws-sdk-code-generator/views/features/smoke'
|
54
55
|
require_relative 'aws-sdk-code-generator/views/gemspec'
|
55
56
|
require_relative 'aws-sdk-code-generator/views/resource_class'
|
57
|
+
require_relative 'aws-sdk-code-generator/views/endpoint_parameters_class'
|
58
|
+
require_relative 'aws-sdk-code-generator/views/endpoint_provider_class'
|
59
|
+
require_relative 'aws-sdk-code-generator/views/endpoints_module'
|
60
|
+
require_relative 'aws-sdk-code-generator/views/endpoints_plugin'
|
56
61
|
require_relative 'aws-sdk-code-generator/views/root_resource_class'
|
57
62
|
require_relative 'aws-sdk-code-generator/views/service_module'
|
58
63
|
require_relative 'aws-sdk-code-generator/views/spec/spec_helper'
|
64
|
+
require_relative 'aws-sdk-code-generator/views/spec/endpoint_provider_spec_class'
|
59
65
|
require_relative 'aws-sdk-code-generator/views/types_module'
|
60
66
|
require_relative 'aws-sdk-code-generator/views/event_streams_module'
|
61
67
|
require_relative 'aws-sdk-code-generator/views/authorizer_class'
|
@@ -76,7 +82,7 @@ module AwsSdkCodeGenerator
|
|
76
82
|
# WARNING ABOUT GENERATED CODE
|
77
83
|
#
|
78
84
|
# This file is generated. See the contributing guide for more information:
|
79
|
-
# https://github.com/aws/aws-sdk-ruby/blob/
|
85
|
+
# https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
|
80
86
|
#
|
81
87
|
# WARNING ABOUT GENERATED CODE
|
82
88
|
WARNING_TXT
|
@@ -3,11 +3,9 @@
|
|
3
3
|
{{#generated_src_warning}}
|
4
4
|
{{generated_src_warning}}
|
5
5
|
{{/generated_src_warning}}
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
rescue LoadError; end
|
10
|
-
end
|
6
|
+
begin
|
7
|
+
require 'http/2'
|
8
|
+
rescue LoadError; end
|
11
9
|
{{#plugin_requires}}
|
12
10
|
require '{{.}}'
|
13
11
|
{{/plugin_requires}}
|
@@ -68,11 +66,11 @@ module {{module_name}}
|
|
68
66
|
|
69
67
|
{{#eventstream_input}}
|
70
68
|
req.context[:input_event_stream_handler] = input_event_stream_handler
|
71
|
-
req.handlers.add(Aws::Binary::EncodeHandler, priority:
|
69
|
+
req.handlers.add(Aws::Binary::EncodeHandler, priority: 55)
|
72
70
|
{{/eventstream_input}}
|
73
71
|
{{#eventstream_output}}
|
74
72
|
req.context[:output_event_stream_handler] = output_event_stream_handler
|
75
|
-
req.handlers.add(Aws::Binary::DecodeHandler, priority:
|
73
|
+
req.handlers.add(Aws::Binary::DecodeHandler, priority: 55)
|
76
74
|
{{/eventstream_output}}
|
77
75
|
|
78
76
|
req.send_request(options{{{block_option}}})
|
@@ -44,6 +44,13 @@ module {{module_name}}
|
|
44
44
|
{{#http_checksum_required}}
|
45
45
|
o.http_checksum_required = true
|
46
46
|
{{/http_checksum_required}}
|
47
|
+
{{#http_checksum}}
|
48
|
+
o.http_checksum = {
|
49
|
+
{{#http_checksum}}
|
50
|
+
{{{key}}} => {{{value}}},
|
51
|
+
{{/http_checksum}}
|
52
|
+
}
|
53
|
+
{{/http_checksum}}
|
47
54
|
{{#deprecated}}
|
48
55
|
o.deprecated = true
|
49
56
|
{{/deprecated}}
|
@@ -45,7 +45,7 @@ module {{module_name}}
|
|
45
45
|
# seconds to wait when opening a HTTP session before raising a
|
46
46
|
# `Timeout::Error`.
|
47
47
|
#
|
48
|
-
# @option options [
|
48
|
+
# @option options [Float] :http_read_timeout (60) The default
|
49
49
|
# number of seconds to wait for response data. This value can
|
50
50
|
# safely be set per-request on the session.
|
51
51
|
#
|
@@ -61,6 +61,9 @@ module {{module_name}}
|
|
61
61
|
# disables this behaviour. This value can safely be set per
|
62
62
|
# request on the session.
|
63
63
|
#
|
64
|
+
# @option options [Float] :ssl_timeout (nil) Sets the SSL timeout
|
65
|
+
# in seconds.
|
66
|
+
#
|
64
67
|
# @option options [Boolean] :http_wire_trace (false) When `true`,
|
65
68
|
# HTTP debug output will be sent to the `:logger`.
|
66
69
|
#
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
module {{module_name}}
|
7
|
+
# Endpoint parameters used to influence endpoints per request.
|
8
|
+
#
|
9
|
+
{{#parameters}}
|
10
|
+
{{documentation}}
|
11
|
+
{{/parameters}}
|
12
|
+
EndpointParameters = Struct.new(
|
13
|
+
{{#parameters}}
|
14
|
+
:{{underscore_name}},
|
15
|
+
{{/parameters}}
|
16
|
+
{{^parameters}}
|
17
|
+
nil
|
18
|
+
{{/parameters}}
|
19
|
+
) do
|
20
|
+
include Aws::Structure
|
21
|
+
|
22
|
+
# @api private
|
23
|
+
class << self
|
24
|
+
PARAM_MAP = {
|
25
|
+
{{#parameters}}
|
26
|
+
'{{name}}' => :{{underscore_name}},
|
27
|
+
{{/parameters}}
|
28
|
+
}.freeze
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(options = {})
|
32
|
+
{{#parameters}}
|
33
|
+
self[:{{underscore_name}}] = options[:{{underscore_name}}]
|
34
|
+
{{#default?}}
|
35
|
+
{{#boolean_default?}}
|
36
|
+
self[:{{underscore_name}}] = {{default}} if self[:{{underscore_name}}].nil?
|
37
|
+
{{/boolean_default?}}
|
38
|
+
{{^boolean_default?}}
|
39
|
+
self[:{{underscore_name}}] ||= '{{default}}' if self[:{{underscore_name}}].nil?
|
40
|
+
{{/boolean_default?}}
|
41
|
+
{{/default?}}
|
42
|
+
{{#required}}
|
43
|
+
if self[:{{underscore_name}}].nil?
|
44
|
+
raise ArgumentError, "Missing required EndpointParameter: :{{underscore_name}}"
|
45
|
+
end
|
46
|
+
{{/required}}
|
47
|
+
{{/parameters}}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
module {{module_name}}
|
7
|
+
class EndpointProvider
|
8
|
+
def initialize(rule_set = nil)
|
9
|
+
@@rule_set ||= begin
|
10
|
+
endpoint_rules = Aws::Json.load(Base64.decode64(RULES))
|
11
|
+
Aws::Endpoints::RuleSet.new(
|
12
|
+
version: endpoint_rules['version'],
|
13
|
+
service_id: endpoint_rules['serviceId'],
|
14
|
+
parameters: endpoint_rules['parameters'],
|
15
|
+
rules: endpoint_rules['rules']
|
16
|
+
)
|
17
|
+
end
|
18
|
+
@provider = Aws::Endpoints::RulesProvider.new(rule_set || @@rule_set)
|
19
|
+
end
|
20
|
+
|
21
|
+
def resolve_endpoint(parameters)
|
22
|
+
@provider.resolve_endpoint(parameters)
|
23
|
+
end
|
24
|
+
|
25
|
+
# @api private
|
26
|
+
RULES = <<-JSON
|
27
|
+
{{endpoint_rules_encoded}}
|
28
|
+
JSON
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
|
7
|
+
module {{module_name}}
|
8
|
+
module Endpoints
|
9
|
+
|
10
|
+
{{#endpoint_classes}}
|
11
|
+
class {{name}}
|
12
|
+
def self.build(context)
|
13
|
+
{{#has_endpoint_built_in?}}
|
14
|
+
unless context.config.regional_endpoint
|
15
|
+
endpoint = context.config.endpoint.to_s
|
16
|
+
end
|
17
|
+
{{/has_endpoint_built_in?}}
|
18
|
+
{{module_name}}::EndpointParameters.new(
|
19
|
+
{{#parameters}}
|
20
|
+
{{#static_string?}}
|
21
|
+
{{key}}: "{{{value}}}",
|
22
|
+
{{/static_string?}}
|
23
|
+
{{^static_string?}}
|
24
|
+
{{key}}: {{{value}}},
|
25
|
+
{{/static_string?}}
|
26
|
+
{{/parameters}}
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
{{/endpoint_classes}}
|
32
|
+
end
|
33
|
+
end
|