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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aws-sdk-code-generator/api.rb +12 -2
  3. data/lib/aws-sdk-code-generator/client_constructor.rb +4 -1
  4. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +27 -7
  5. data/lib/aws-sdk-code-generator/client_response_structure_example.rb +8 -1
  6. data/lib/aws-sdk-code-generator/code_builder.rb +78 -9
  7. data/lib/aws-sdk-code-generator/codegenerated_plugin.rb +34 -0
  8. data/lib/aws-sdk-code-generator/gem_builder.rb +27 -5
  9. data/lib/aws-sdk-code-generator/helper.rb +10 -1
  10. data/lib/aws-sdk-code-generator/plugin_list.rb +30 -9
  11. data/lib/aws-sdk-code-generator/service.rb +22 -0
  12. data/lib/aws-sdk-code-generator/views/async_client_class.rb +6 -2
  13. data/lib/aws-sdk-code-generator/views/client_api_module.rb +40 -5
  14. data/lib/aws-sdk-code-generator/views/client_class.rb +7 -2
  15. data/lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb +80 -0
  16. data/lib/aws-sdk-code-generator/views/endpoint_provider_class.rb +34 -0
  17. data/lib/aws-sdk-code-generator/views/endpoints_module.rb +177 -0
  18. data/lib/aws-sdk-code-generator/views/endpoints_plugin.rb +85 -0
  19. data/lib/aws-sdk-code-generator/views/gemspec.rb +6 -2
  20. data/lib/aws-sdk-code-generator/views/service_module.rb +22 -0
  21. data/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +198 -0
  22. data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -4
  23. data/lib/aws-sdk-code-generator/views/types_module.rb +60 -24
  24. data/lib/aws-sdk-code-generator.rb +7 -1
  25. data/templates/async_client_class.mustache +5 -7
  26. data/templates/client_api_module.mustache +7 -0
  27. data/templates/client_class.mustache +4 -1
  28. data/templates/endpoint_parameters_class.mustache +50 -0
  29. data/templates/endpoint_provider_class.mustache +30 -0
  30. data/templates/endpoints_module.mustache +33 -0
  31. data/templates/endpoints_plugin.mustache +76 -0
  32. data/templates/gemspec.mustache +2 -1
  33. data/templates/license.txt +202 -0
  34. data/templates/service_module.mustache +11 -1
  35. data/templates/spec/endpoint_provider_spec_class.mustache +76 -0
  36. data/templates/spec/spec_helper.mustache +5 -0
  37. data/templates/types_module.mustache +7 -0
  38. metadata +16 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4fa27373a270b0e11b172d68ccc2c1c5b7926f986a1fb630be00b0a591a956a
4
- data.tar.gz: 78f1365cdb7d7b78bdb6b2269e8ce18a42907eff158f7dae9b20c7fcaf6b6a88
3
+ metadata.gz: 6f47bca9edb4689814cec21486fbc9924716462ea8dc0cf69e05d82b11c95d3b
4
+ data.tar.gz: 7173e29d52ac6118968e30d35e750cfe2a702e9c4a320041c46ab534f6c5d018
5
5
  SHA512:
6
- metadata.gz: 94e82e811fa8689c93762b0c590f2d12f3c0dbda5d040d932d7caeb5396096cf8b2109394bb992f0325b137993534cadd0905515f7265e74b25b9de81efb9f51
7
- data.tar.gz: b7f27268bbc20faa1c6a6439019ca9ec57e905f509ff4b95904eb0e6b13f0bf6e87f6eca0b81b1235d60f5d961fc0bbd5fd2c97ed7076cda9c7bc8b595966c1a
6
+ metadata.gz: c009d5dec4abd1d587254c564eeb88c89bd08d687070ae539ea4ea0fc64d747edc8b28641f7544ea9860363aa7467a631fae896d815cde99cc3502c7b7b844e2
7
+ data.tar.gz: b195875c8e9dd16ba6373784bd786dc79663a6e0f421c2835462cd1bccc407e2168d5a98947bffa6fc31ea1eb65ba27fca67047c83ef2a9d65987e4dbd3902d0
@@ -77,7 +77,12 @@ module AwsSdkCodeGenerator
77
77
  "Hash<String,#{ruby_input_type(shape['value'], api, operation, nested: true)}>"
78
78
  end
79
79
  when 'string' then 'String'
80
- when 'structure' then "Types::#{shape_ref['shape']}"
80
+ when 'structure'
81
+ if shape['document']
82
+ 'Hash,Array,String,Numeric,Boolean'
83
+ else
84
+ "Types::#{shape_ref['shape']}"
85
+ end
81
86
  when 'timestamp' then 'Time,DateTime,Date,Integer,String'
82
87
  else
83
88
  raise "unhandled type #{shape.type}.inspect"
@@ -98,7 +103,12 @@ module AwsSdkCodeGenerator
98
103
  when 'long' then 'Integer'
99
104
  when 'map' then "Hash<String,#{ruby_type(shape['value'], api)}>"
100
105
  when 'string' then streaming?(shape_ref, api) ? 'IO' : 'String'
101
- when 'structure' then "Types::#{shape_ref['shape']}"
106
+ when 'structure'
107
+ if shape['document']
108
+ 'Hash,Array,String,Numeric,Boolean'
109
+ else
110
+ "Types::#{shape_ref['shape']}"
111
+ end
102
112
  when 'timestamp' then 'Time'
103
113
  else
104
114
  raise "unhandled type #{shape['type'].inspect}"
@@ -4,8 +4,11 @@ module AwsSdkCodeGenerator
4
4
  class ClientConstructor
5
5
 
6
6
  # @option options [required, PluginList] :plugins
7
+ # @option options [required, Array<CodegeneratedPlugin>] :codegenerated_plugins
8
+
7
9
  def initialize(options)
8
- plugin_options = documented_plugin_options(options.fetch(:plugins))
10
+ plugin_options = documented_plugin_options(options.fetch(:plugins)) +
11
+ documented_plugin_options(options.fetch(:codegenerated_plugins))
9
12
  documentation = {}
10
13
  plugin_options.each do |option|
11
14
  documentation[option.name] = YardOptionTag.new(
@@ -3,6 +3,10 @@
3
3
  module AwsSdkCodeGenerator
4
4
  class ClientOperationDocumentation
5
5
 
6
+ # get all of the enumerable methods that may conflict with members
7
+ # count has special handling in UnsafeEnumerableMethods
8
+ ENUMERABLE_METHODS = Class.new.new.extend(Enumerable).methods - [:count]
9
+
6
10
  # @option options [required, String] :method_name
7
11
  # @option options [required, Hash] :operation
8
12
  # @option options [required, Hash] :api
@@ -57,7 +61,7 @@ module AwsSdkCodeGenerator
57
61
  : request_syntax_example(method_name, operation, api),
58
62
  response_structure_example(operation, api),
59
63
  waiters_tag(@waiters),
60
- see_also_tag(operation, api),
64
+ see_also_tag(@name, api),
61
65
  ], block_comment: false)
62
66
  end
63
67
  alias to_s to_str
@@ -97,9 +101,15 @@ module AwsSdkCodeGenerator
97
101
  if member_ref['idempotencyToken']
98
102
  docstring = docstring.to_s + "<p><b>A suitable default value is auto-generated.** You should normally not need to pass this option.</b></p>"
99
103
  end
100
- if member_ref['jsonvalue']
104
+ if member_ref['jsonvalue'] || member_shape['jsonvalue']
101
105
  docstring = docstring.to_s + "<p><b>SDK automatically handles json encoding and base64 encoding for you when the required value (Hash, Array, etc.) is provided according to the description.</b></p>"
102
106
  end
107
+ if member_shape['document']
108
+ docstring = docstring.to_s + "<p>Document type used to carry open content (Hash,Array,String,Numeric,Boolean). A document type value is serialized using the same format as its surroundings and requires no additional encoding or escaping.</p>"
109
+ end
110
+ if member_ref['union']
111
+ docstring = docstring.to_s + "<p>This is a union type and you must set exactly one of the members.</p>"
112
+ end
103
113
  YardOptionTag.new(
104
114
  name: Underscore.underscore(member_name),
105
115
  ruby_type: Api.ruby_input_type(member_ref, api, operation),
@@ -130,7 +140,11 @@ module AwsSdkCodeGenerator
130
140
  methods = shape['members'].map do |member_name, member_ref|
131
141
  member_type = Docstring.escape_html(Api.ruby_type(member_ref, api))
132
142
  method_name = Underscore.underscore(member_name)
133
- "# * {#{type}##{method_name} ##{method_name}} => #{member_type}"
143
+ if ENUMERABLE_METHODS.include?(method_name.to_sym)
144
+ "# * {#{type}##{method_name} #data.#{method_name}} => #{member_type} (This method conflicts with a method on Response, call it through the data member)"
145
+ else
146
+ "# * {#{type}##{method_name} ##{method_name}} => #{member_type}"
147
+ end
134
148
  end
135
149
  "# @return [#{type}] Returns a {Seahorse::Client::Response response} object which responds to the following methods:\n#\n" + methods.join("\n")
136
150
  else
@@ -218,17 +232,19 @@ module AwsSdkCodeGenerator
218
232
  end
219
233
 
220
234
  def request_syntax_example(method_name, operation, api)
221
- SyntaxExample.new(
235
+ example = SyntaxExample.new(
222
236
  api: api,
223
237
  shape: Api.shape(operation['input'], api),
224
238
  method_name: method_name,
225
239
  receiver: 'client',
226
240
  resp_var: 'resp',
227
241
  ).format
242
+ # TODO - QuickSight is breaking this
243
+ example if example && example.lines.count < 1000
228
244
  end
229
245
 
230
246
  def async_request_syntax_example(method_name, operation, api)
231
- SyntaxExample.new(
247
+ example = SyntaxExample.new(
232
248
  api: api,
233
249
  shape: Api.shape(operation['input'], api),
234
250
  method_name: method_name,
@@ -236,15 +252,19 @@ module AwsSdkCodeGenerator
236
252
  resp_var: 'async_resp',
237
253
  async: true
238
254
  ).format
255
+ # TODO - QuickSight is breaking this
256
+ example if example && example.lines.count < 1000
239
257
  end
240
258
 
241
259
  def response_structure_example(operation, api)
242
260
  output = Api.shape(operation['output'], api) if operation['output']
243
261
  if output && output['members'] && output['members'].size > 0
244
- Docstring.block_comment(ClientResponseStructureExample.new(
262
+ docstring = Docstring.block_comment(ClientResponseStructureExample.new(
245
263
  shape_ref: operation['output'],
246
264
  api: api
247
265
  ).to_s)
266
+ # TODO - QuickSight is breaking this
267
+ docstring if docstring && docstring.lines.count < 1000
248
268
  end
249
269
  end
250
270
 
@@ -260,7 +280,7 @@ module AwsSdkCodeGenerator
260
280
  def see_also_tag(operation, api)
261
281
  uid = api['metadata']['uid']
262
282
  if api['metadata']['protocol'] != 'api-gateway' && Crosslink.taggable?(uid)
263
- "# " + Crosslink.tag_string(uid, operation['name'])
283
+ "# " + Crosslink.tag_string(uid, operation)
264
284
  end
265
285
  end
266
286
 
@@ -5,6 +5,8 @@ require 'set'
5
5
  module AwsSdkCodeGenerator
6
6
  class ClientResponseStructureExample
7
7
 
8
+ ENUMERABLE_METHODS = Class.new.new.extend(Enumerable).methods - [:count]
9
+
8
10
  # @option options [required, Hash] :shape_ref
9
11
  # @option options [required, Hash] :api
10
12
  def initialize(options = {})
@@ -40,7 +42,12 @@ module AwsSdkCodeGenerator
40
42
  return event_ctx
41
43
  elsif shape['members']
42
44
  shape['members'].each_pair do |member_name, member_ref|
43
- lines += entry(member_ref, "#{context}.#{underscore(member_name)}", visited)
45
+ method_name = underscore(member_name)
46
+ if context == 'resp' && ENUMERABLE_METHODS.include?(method_name.to_sym)
47
+ lines += entry(member_ref, "#{context}.data.#{method_name}", visited)
48
+ else
49
+ lines += entry(member_ref, "#{context}.#{method_name}", visited)
50
+ end
44
51
  end
45
52
  end
46
53
  lines
@@ -51,15 +51,18 @@ module AwsSdkCodeGenerator
51
51
 
52
52
  # @return [Enumerable<String<path>, String<code>>]
53
53
  def source_files(options = {})
54
+
54
55
  prefix = options.fetch(:prefix, @service.gem_name)
56
+ codegenerated_plugins = codegen_plugins(prefix)
57
+
55
58
  Enumerator.new do |y|
56
59
  if @service.protocol == 'api-gateway'
57
60
  y.yield("#{prefix}/../../README.md", apig_readme)
58
61
  y.yield("#{prefix}/plugins/authorizer.rb", authorizer_class)
59
62
  y.yield("#{prefix}/plugins/apig_endpoint.rb", apig_endpoint_class)
60
63
  end
61
- y.yield("#{prefix}.rb", service_module(prefix))
62
- unless prefix == 'aws-sdk-sts'
64
+ y.yield("#{prefix}.rb", service_module(prefix, codegenerated_plugins))
65
+ unless @service.included_in_core?
63
66
  y.yield("#{prefix}/customizations.rb", '')
64
67
  end
65
68
  y.yield("#{prefix}/types.rb", types_module)
@@ -67,13 +70,23 @@ module AwsSdkCodeGenerator
67
70
  y.yield("#{prefix}/event_streams.rb", event_streams_module)
68
71
  end
69
72
  y.yield("#{prefix}/client_api.rb", client_api_module)
70
- y.yield("#{prefix}/client.rb", client_class)
73
+
74
+ codegenerated_plugins.each { |p| y.yield(p.path, p.source) }
75
+
76
+ y.yield("#{prefix}/client.rb", client_class(codegenerated_plugins))
71
77
  if @service.protocol_settings['h2'] == 'eventstream'
72
- y.yield("#{prefix}/async_client.rb", async_client_class)
78
+ y.yield("#{prefix}/async_client.rb", async_client_class(codegenerated_plugins))
73
79
  end
74
80
  y.yield("#{prefix}/errors.rb", errors_module)
75
81
  y.yield("#{prefix}/waiters.rb", waiters_module) if @waiters
76
82
  y.yield("#{prefix}/resource.rb", root_resource_class)
83
+
84
+ unless @service.legacy_endpoints?
85
+ y.yield("#{prefix}/endpoint_parameters.rb", endpoint_parameters)
86
+ y.yield("#{prefix}/endpoints.rb", endpoints_module)
87
+ y.yield("#{prefix}/endpoint_provider.rb", endpoint_provider)
88
+ end
89
+
77
90
  if @resources
78
91
  @resources['resources'].keys.sort.each do |name|
79
92
  path = "#{prefix}/#{Underscore.underscore(name)}.rb"
@@ -84,10 +97,24 @@ module AwsSdkCodeGenerator
84
97
  end
85
98
  end
86
99
 
100
+ # @return [Enumerable<String<path>, String<code>>]
101
+ def spec_files(options = {})
102
+ prefix = options.fetch(:prefix, '')
103
+ Enumerator.new do |y|
104
+ y.yield("#{prefix}/spec_helper.rb", spec_helper_file)
105
+
106
+ if @service.endpoint_tests && !@service.legacy_endpoints?
107
+ y.yield("#{prefix}/endpoint_provider_spec.rb", endpoint_provider_spec_file)
108
+ end
109
+ end
110
+ end
111
+
87
112
  private
88
113
 
89
- def service_module(prefix)
90
- Views::ServiceModule.new(service: @service, prefix: prefix).render
114
+ def service_module(prefix, codegenerated_plugins)
115
+ Views::ServiceModule.new(
116
+ service: @service, prefix: prefix,
117
+ codegenerated_plugins: codegenerated_plugins).render
91
118
  end
92
119
 
93
120
  def types_module
@@ -102,7 +129,7 @@ module AwsSdkCodeGenerator
102
129
  Views::ClientApiModule.new(service: @service).render
103
130
  end
104
131
 
105
- def client_class
132
+ def client_class(codegenerated_plugins)
106
133
  Views::ClientClass.new(
107
134
  service_identifier: @service.identifier,
108
135
  service_name: @service.name,
@@ -121,11 +148,13 @@ module AwsSdkCodeGenerator
121
148
  paginators: @service.paginators,
122
149
  waiters: @service.waiters,
123
150
  examples: @service.examples,
124
- custom: @service.protocol == 'api-gateway'
151
+ custom: @service.protocol == 'api-gateway',
152
+ legacy_endpoints: @service.legacy_endpoints?,
153
+ codegenerated_plugins: codegenerated_plugins
125
154
  ).render
126
155
  end
127
156
 
128
- def async_client_class
157
+ def async_client_class(codegenerated_plugins)
129
158
  Views::AsyncClientClass.new(
130
159
  service_identifier: @service.identifier,
131
160
  service_name: @service.name,
@@ -139,6 +168,8 @@ module AwsSdkCodeGenerator
139
168
  add_plugins: @service.add_plugins,
140
169
  remove_plugins: @service.remove_plugins,
141
170
  api: @service.api,
171
+ legacy_endpoints: @service.legacy_endpoints?,
172
+ codegenerated_plugins: codegenerated_plugins,
142
173
  async_client: true
143
174
  ).render
144
175
  end
@@ -200,6 +231,44 @@ module AwsSdkCodeGenerator
200
231
  ).render
201
232
  end
202
233
 
234
+ def endpoint_parameters
235
+ Views::EndpointParametersClass.new(service: @service).render
236
+ end
237
+
238
+ def endpoint_provider
239
+ Views::EndpointProviderClass.new(service: @service).render
240
+ end
241
+
242
+ def endpoints_module
243
+ Views::EndpointsModule.new(service: @service).render
244
+ end
245
+
246
+ def endpoints_plugin
247
+ Views::EndpointsPlugin.new(service: @service).render
248
+ end
249
+
250
+ def endpoint_provider_spec_file
251
+ Views::Spec::EndpointProviderSpecClass.new(service: @service).render
252
+ end
253
+
254
+ def codegen_plugins(prefix)
255
+ unless @service.legacy_endpoints?
256
+ [
257
+ CodegeneratedPlugin.new(
258
+ source: endpoints_plugin,
259
+ class_name: "#{@service.module_name}::Plugins::Endpoints",
260
+ path: "#{prefix}/plugins/endpoints.rb"
261
+ )
262
+ ]
263
+ else
264
+ []
265
+ end
266
+ end
267
+
268
+ def spec_helper_file
269
+ Views::Spec::SpecHelper.new(service: @service).render
270
+ end
271
+
203
272
  private
204
273
 
205
274
  def has_eventstream
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class CodegeneratedPlugin
5
+
6
+ # @option options [required, String] :source
7
+ # @option options [required, String] :class_name
8
+ # @option options [required, String] :path
9
+ def initialize(options = {})
10
+ @source = options.fetch(:source)
11
+ @class_name = options.fetch(:class_name)
12
+ @path = options.fetch(:path)
13
+ end
14
+
15
+ attr_reader :source, :path, :class_name
16
+
17
+
18
+ def plugin_class
19
+ if @plugin_class.nil?
20
+ Object.module_eval(@source)
21
+ const_names = @class_name.split('::')
22
+ @plugin_class = const_names.inject(Kernel) do |const, const_name|
23
+ const.const_get(const_name)
24
+ end
25
+ end
26
+ @plugin_class
27
+ end
28
+
29
+ def options
30
+ plugin_class.public_send(:options)
31
+ end
32
+
33
+ end
34
+ end
@@ -8,26 +8,35 @@ module AwsSdkCodeGenerator
8
8
  def initialize(options)
9
9
  @options = options
10
10
  @service = options.fetch(:service)
11
+ validate_model!
11
12
  end
12
13
 
13
14
  # @return [Hash]
14
15
  attr_reader :options
15
16
 
17
+ def validate_model!
18
+ validate_document_support!
19
+ end
20
+
16
21
  def each(&block)
17
22
  Enumerator.new do |y|
18
23
  y.yield("#{@service.gem_name}.gemspec", gemspec_file)
19
24
  y.yield('features/env.rb', features_env_file)
20
25
  y.yield('features/step_definitions.rb', features_step_definitions_file)
21
- y.yield('spec/spec_helper.rb', spec_helper_file)
22
26
  if @service.smoke_tests
23
27
  y.yield('features/smoke.feature', smoke_file)
24
28
  y.yield('features/smoke_step_definitions.rb', smoke_step_definitions_file)
25
29
  end
26
30
  y.yield('VERSION', version_file)
31
+ y.yield('LICENSE.txt', license_file)
32
+
27
33
  code = CodeBuilder.new(@options)
28
34
  code.source_files.each do |path, code|
29
35
  y.yield("lib/#{path}", code)
30
36
  end
37
+ code.spec_files.each do |path, code|
38
+ y.yield("spec/#{path}", code)
39
+ end
31
40
  end.each(&block)
32
41
  end
33
42
 
@@ -53,13 +62,26 @@ module AwsSdkCodeGenerator
53
62
  Views::Features::StepDefinitions.new(options).render
54
63
  end
55
64
 
56
- def spec_helper_file
57
- Views::Spec::SpecHelper.new(options).render
58
- end
59
-
60
65
  def version_file
61
66
  Views::Version.new(options).render
62
67
  end
63
68
 
69
+ def license_file
70
+ File.read(File.expand_path('../../../templates/license.txt',__FILE__ ))
71
+ end
72
+
73
+ private
74
+
75
+ # document types are only supported for rest-json and json
76
+ def validate_document_support!
77
+ return if ['rest-json', 'json'].include?(@service.protocol)
78
+
79
+ # Check all shapes and raise if any are Document types
80
+ @service.api.fetch('shapes', {}).each do |name, shape|
81
+ if shape['type'] == 'structure' && shape['document']
82
+ raise "Shape #{name} is a document type. Document types are only supported in json protocols."
83
+ end
84
+ end
85
+ end
64
86
  end
65
87
  end
@@ -31,6 +31,15 @@ module AwsSdkCodeGenerator
31
31
  end.join('.')
32
32
  end
33
33
 
34
+ # convert a snake case to pascal case
35
+ def pascal_case(str)
36
+ str
37
+ .to_s
38
+ .split('_')
39
+ .collect(&:capitalize)
40
+ .join
41
+ end
42
+
34
43
  def structures
35
44
  Enumerator.new do |y|
36
45
  (@api['shapes'] || {}).each do |shape_name, shape|
@@ -167,7 +176,7 @@ module AwsSdkCodeGenerator
167
176
  end
168
177
 
169
178
  module_function :deep_copy, :operation_streaming?, :downcase_first, :wrap_string, :apig_prefix,
170
- :eventstream_output?, :eventstream_input?, :operation_eventstreaming?
179
+ :eventstream_output?, :eventstream_input?, :operation_eventstreaming?, :pascal_case
171
180
 
172
181
  end
173
182
  end
@@ -20,7 +20,7 @@ module AwsSdkCodeGenerator
20
20
  def compute_plugins(options)
21
21
  plugins = {}
22
22
  plugins.update(options[:async_client] ? default_async_plugins : default_plugins)
23
- plugins.update(signature_plugins(options.fetch(:signature_version)))
23
+ plugins.update(signature_plugins(options))
24
24
  plugins.update(protocol_plugins(options.fetch(:protocol)))
25
25
  plugins.update(options.fetch(:add_plugins))
26
26
  options.fetch(:remove_plugins).each do |plugin_name|
@@ -58,12 +58,16 @@ module AwsSdkCodeGenerator
58
58
  'Aws::Plugins::ClientMetricsPlugin' => "#{core_plugins}/client_metrics_plugin.rb",
59
59
  'Aws::Plugins::ClientMetricsSendPlugin' => "#{core_plugins}/client_metrics_send_plugin.rb",
60
60
  'Aws::Plugins::TransferEncoding' => "#{core_plugins}/transfer_encoding.rb",
61
- 'Aws::Plugins::HttpChecksum' => "#{core_plugins}/http_checksum.rb"
61
+ 'Aws::Plugins::HttpChecksum' => "#{core_plugins}/http_checksum.rb",
62
+ 'Aws::Plugins::ChecksumAlgorithm' => "#{core_plugins}/checksum_algorithm.rb",
63
+ 'Aws::Plugins::DefaultsMode' => "#{core_plugins}/defaults_mode.rb",
64
+ 'Aws::Plugins::RecursionDetection' => "#{core_plugins}/recursion_detection.rb"
62
65
  }
63
66
  end
64
67
 
65
68
  def default_async_plugins
66
69
  plugins = default_plugins.dup
70
+ plugins.delete('Seahorse::Client::Plugins::ContentLength')
67
71
  plugins.delete('Aws::Plugins::ResponsePaging')
68
72
  plugins.delete('Aws::Plugins::EndpointDiscovery')
69
73
  plugins.delete('Aws::Plugins::EndpointPattern')
@@ -92,14 +96,31 @@ module AwsSdkCodeGenerator
92
96
  }[protocol]
93
97
  end
94
98
 
95
- def signature_plugins(signature_version)
96
- case signature_version
97
- when 'v4'
98
- { 'Aws::Plugins::SignatureV4' => "#{core_plugins}/signature_v4.rb" }
99
- when 'v2'
100
- { 'Aws::Plugins::SignatureV2' => "#{core_plugins}/signature_v2.rb" }
99
+ # HACK: Sigv2 is deprecated, Sigv4/Bearer are with core. Always assume
100
+ # new signer plugin. This logic would be moved to gem dependencies
101
+ # calculation, but don't worry until new signature type.
102
+ #
103
+ # NOTE: If no rules are provided, just use old Signing method
104
+ def signature_plugins(options)
105
+ if !options[:legacy_endpoints]
106
+ {
107
+ 'Aws::Plugins::Sign' => "#{core_plugins}/sign.rb"
108
+ }
101
109
  else
102
- {}
110
+ auth_types = [options.fetch(:signature_version)]
111
+ auth_types += options[:api]['operations'].map { |_n, o| o['authtype'] }.compact
112
+ plugins = {}
113
+ auth_types.each do |auth_type|
114
+ case auth_type
115
+ when 'v4'
116
+ plugins['Aws::Plugins::SignatureV4'] = "#{core_plugins}/signature_v4.rb"
117
+ when 'v2'
118
+ plugins['Aws::Plugins::SignatureV2'] = "#{core_plugins}/signature_v2.rb"
119
+ when 'bearer'
120
+ plugins['Aws::Plugins::BearerAuthorization'] = "#{core_plugins}/bearer_authorization.rb"
121
+ end
122
+ end
123
+ plugins
103
124
  end
104
125
  end
105
126
 
@@ -14,6 +14,8 @@ module AwsSdkCodeGenerator
14
14
  # @option options [Hash, String] :waiters
15
15
  # @option options [Hash, String] :resources
16
16
  # @option options [Hash, String] :examples
17
+ # @option options [Hash, String] :endpoint_rules
18
+ # @option options [Hash, String] :endpoint_tests
17
19
  # @option options [Hash, String] :smoke_tests
18
20
  # @option options [Hash<gem,version>] :gem_dependencies ({})
19
21
  # @option options [Hash] :add_plugins ({})
@@ -34,6 +36,10 @@ module AwsSdkCodeGenerator
34
36
  @resources = load_json(options[:resources])
35
37
  @examples = load_json(options[:examples])
36
38
  @smoke_tests = load_json(options[:smoke_tests])
39
+ unless options[:legacy_endpoints]
40
+ @endpoint_rules = load_json(options[:endpoint_rules])
41
+ @endpoint_tests = load_json(options[:endpoint_tests])
42
+ end
37
43
  @gem_dependencies = options[:gem_dependencies] || {}
38
44
  @add_plugins = options[:add_plugins] || {}
39
45
  @remove_plugins = options[:remove_plugins] || []
@@ -77,6 +83,22 @@ module AwsSdkCodeGenerator
77
83
  # @return [Hash, nil] The service smoke test model.
78
84
  attr_reader :smoke_tests
79
85
 
86
+ # @return Boolean True if the service should use legacy endpoints
87
+ def legacy_endpoints?
88
+ !@endpoint_rules || @endpoint_rules.empty?
89
+ end
90
+
91
+ # @return Boolean True if the service is inlined in core (ie not a stand alone gem)
92
+ def included_in_core?
93
+ %w[STS SSO SSOOIDC].include?(name)
94
+ end
95
+
96
+ # @return [Hash, nil] The service endpoint rules.
97
+ attr_reader :endpoint_rules
98
+
99
+ # @return [Hash, nil] The service endpoint tests.
100
+ attr_reader :endpoint_tests
101
+
80
102
  # @return [Hash<String,String>] A hash of gem dependencies. Hash keys
81
103
  # are gem names, values are versions.
82
104
  attr_reader :gem_dependencies
@@ -23,7 +23,11 @@ module AwsSdkCodeGenerator
23
23
  @gem_name = options.fetch(:gem_name)
24
24
  @gem_version = options.fetch(:gem_version)
25
25
  @plugins = PluginList.new(options)
26
- @client_constructor = ClientConstructor.new(plugins: @plugins)
26
+ @codegenerated_plugins = options.fetch(:codegenerated_plugins, [])
27
+ @client_constructor = ClientConstructor.new(
28
+ options.merge(
29
+ plugins: @plugins,
30
+ codegenerated_plugins: @codegenerated_plugins))
27
31
  @operations = ClientOperationList.new(options).to_a
28
32
  end
29
33
 
@@ -60,7 +64,7 @@ module AwsSdkCodeGenerator
60
64
 
61
65
  # @return [Array<String>]
62
66
  def plugin_class_names
63
- @plugins.map(&:class_name)
67
+ @plugins.map(&:class_name) + @codegenerated_plugins.map(&:class_name)
64
68
  end
65
69
 
66
70
  end