aws-sdk-code-generator 0.2.4.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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aws-sdk-code-generator/client_constructor.rb +4 -1
  3. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +10 -4
  4. data/lib/aws-sdk-code-generator/code_builder.rb +78 -9
  5. data/lib/aws-sdk-code-generator/codegenerated_plugin.rb +34 -0
  6. data/lib/aws-sdk-code-generator/gem_builder.rb +4 -5
  7. data/lib/aws-sdk-code-generator/plugin_list.rb +29 -9
  8. data/lib/aws-sdk-code-generator/service.rb +22 -0
  9. data/lib/aws-sdk-code-generator/views/async_client_class.rb +6 -2
  10. data/lib/aws-sdk-code-generator/views/client_api_module.rb +18 -2
  11. data/lib/aws-sdk-code-generator/views/client_class.rb +7 -2
  12. data/lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb +80 -0
  13. data/lib/aws-sdk-code-generator/views/endpoint_provider_class.rb +34 -0
  14. data/lib/aws-sdk-code-generator/views/endpoints_module.rb +177 -0
  15. data/lib/aws-sdk-code-generator/views/endpoints_plugin.rb +85 -0
  16. data/lib/aws-sdk-code-generator/views/gemspec.rb +4 -0
  17. data/lib/aws-sdk-code-generator/views/service_module.rb +15 -1
  18. data/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +198 -0
  19. data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -4
  20. data/lib/aws-sdk-code-generator/views/types_module.rb +8 -7
  21. data/lib/aws-sdk-code-generator.rb +6 -0
  22. data/templates/async_client_class.mustache +2 -2
  23. data/templates/client_api_module.mustache +7 -0
  24. data/templates/client_class.mustache +4 -1
  25. data/templates/endpoint_parameters_class.mustache +50 -0
  26. data/templates/endpoint_provider_class.mustache +30 -0
  27. data/templates/endpoints_module.mustache +33 -0
  28. data/templates/endpoints_plugin.mustache +76 -0
  29. data/templates/gemspec.mustache +1 -1
  30. data/templates/spec/endpoint_provider_spec_class.mustache +76 -0
  31. data/templates/spec/spec_helper.mustache +5 -0
  32. metadata +14 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cd62265104fa228849cca4ee26d749025e7ba94a0ff446885abc045a17a91cf
4
- data.tar.gz: 537442139442f772fecb3e829a9a584a07bf6795757c01b90032f78c5b4fde99
3
+ metadata.gz: 6f47bca9edb4689814cec21486fbc9924716462ea8dc0cf69e05d82b11c95d3b
4
+ data.tar.gz: 7173e29d52ac6118968e30d35e750cfe2a702e9c4a320041c46ab534f6c5d018
5
5
  SHA512:
6
- metadata.gz: 7dd69754c3ad489c192c4db3986fc79376dbd34316f5d6d79694e5807824d36de9333762d49727a4e92525bbea4b0190803474641282499e116afd7955d6a162
7
- data.tar.gz: a44c6a9fd0a8778bbe4d00c73dcc07584b1beac9c278671f006c349c7e7f0a36d6e8fa18084ebd61984769496abde3faf9037b85d09e40ce7c86d9f823030923
6
+ metadata.gz: c009d5dec4abd1d587254c564eeb88c89bd08d687070ae539ea4ea0fc64d747edc8b28641f7544ea9860363aa7467a631fae896d815cde99cc3502c7b7b844e2
7
+ data.tar.gz: b195875c8e9dd16ba6373784bd786dc79663a6e0f421c2835462cd1bccc407e2168d5a98947bffa6fc31ea1eb65ba27fca67047c83ef2a9d65987e4dbd3902d0
@@ -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(
@@ -101,7 +101,7 @@ module AwsSdkCodeGenerator
101
101
  if member_ref['idempotencyToken']
102
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>"
103
103
  end
104
- if member_ref['jsonvalue']
104
+ if member_ref['jsonvalue'] || member_shape['jsonvalue']
105
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>"
106
106
  end
107
107
  if member_shape['document']
@@ -232,17 +232,19 @@ module AwsSdkCodeGenerator
232
232
  end
233
233
 
234
234
  def request_syntax_example(method_name, operation, api)
235
- SyntaxExample.new(
235
+ example = SyntaxExample.new(
236
236
  api: api,
237
237
  shape: Api.shape(operation['input'], api),
238
238
  method_name: method_name,
239
239
  receiver: 'client',
240
240
  resp_var: 'resp',
241
241
  ).format
242
+ # TODO - QuickSight is breaking this
243
+ example if example && example.lines.count < 1000
242
244
  end
243
245
 
244
246
  def async_request_syntax_example(method_name, operation, api)
245
- SyntaxExample.new(
247
+ example = SyntaxExample.new(
246
248
  api: api,
247
249
  shape: Api.shape(operation['input'], api),
248
250
  method_name: method_name,
@@ -250,15 +252,19 @@ module AwsSdkCodeGenerator
250
252
  resp_var: 'async_resp',
251
253
  async: true
252
254
  ).format
255
+ # TODO - QuickSight is breaking this
256
+ example if example && example.lines.count < 1000
253
257
  end
254
258
 
255
259
  def response_structure_example(operation, api)
256
260
  output = Api.shape(operation['output'], api) if operation['output']
257
261
  if output && output['members'] && output['members'].size > 0
258
- Docstring.block_comment(ClientResponseStructureExample.new(
262
+ docstring = Docstring.block_comment(ClientResponseStructureExample.new(
259
263
  shape_ref: operation['output'],
260
264
  api: api
261
265
  ).to_s)
266
+ # TODO - QuickSight is breaking this
267
+ docstring if docstring && docstring.lines.count < 1000
262
268
  end
263
269
  end
264
270
 
@@ -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 %w[aws-sdk-sts aws-sdk-sso].include? prefix
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
@@ -23,17 +23,20 @@ module AwsSdkCodeGenerator
23
23
  y.yield("#{@service.gem_name}.gemspec", gemspec_file)
24
24
  y.yield('features/env.rb', features_env_file)
25
25
  y.yield('features/step_definitions.rb', features_step_definitions_file)
26
- y.yield('spec/spec_helper.rb', spec_helper_file)
27
26
  if @service.smoke_tests
28
27
  y.yield('features/smoke.feature', smoke_file)
29
28
  y.yield('features/smoke_step_definitions.rb', smoke_step_definitions_file)
30
29
  end
31
30
  y.yield('VERSION', version_file)
32
31
  y.yield('LICENSE.txt', license_file)
32
+
33
33
  code = CodeBuilder.new(@options)
34
34
  code.source_files.each do |path, code|
35
35
  y.yield("lib/#{path}", code)
36
36
  end
37
+ code.spec_files.each do |path, code|
38
+ y.yield("spec/#{path}", code)
39
+ end
37
40
  end.each(&block)
38
41
  end
39
42
 
@@ -59,10 +62,6 @@ module AwsSdkCodeGenerator
59
62
  Views::Features::StepDefinitions.new(options).render
60
63
  end
61
64
 
62
- def spec_helper_file
63
- Views::Spec::SpecHelper.new(options).render
64
- end
65
-
66
65
  def version_file
67
66
  Views::Version.new(options).render
68
67
  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,7 +58,10 @@ 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
 
@@ -93,14 +96,31 @@ module AwsSdkCodeGenerator
93
96
  }[protocol]
94
97
  end
95
98
 
96
- def signature_plugins(signature_version)
97
- case signature_version
98
- when 'v4'
99
- { 'Aws::Plugins::SignatureV4' => "#{core_plugins}/signature_v4.rb" }
100
- when 'v2'
101
- { '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
+ }
102
109
  else
103
- {}
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
104
124
  end
105
125
  end
106
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
@@ -31,8 +31,9 @@ module AwsSdkCodeGenerator
31
31
  'xmlNamespace' => true,
32
32
  'streaming' => true, # transfer-encoding
33
33
  'requiresLength' => true, # transfer-encoding
34
- 'union' => false,
34
+ 'union' => false, # should remain false
35
35
  'document' => true,
36
+ 'jsonvalue' => true,
36
37
  # event stream modeling
37
38
  'event' => false,
38
39
  'eventstream' => false,
@@ -83,7 +84,10 @@ module AwsSdkCodeGenerator
83
84
  'checksumFormat' => true,
84
85
  'globalEndpoint' => true,
85
86
  'serviceAbbreviation' => true,
86
- 'uid' => true
87
+ 'uid' => true,
88
+ 'awsQueryCompatible' => true, # AwsQuery migration
89
+ # ignore
90
+ 'ripServiceName' => true
87
91
  }
88
92
 
89
93
  # @option options [required, Service] :service
@@ -197,6 +201,15 @@ module AwsSdkCodeGenerator
197
201
  o.http_method = operation['http']['method']
198
202
  o.http_request_uri = operation['http']['requestUri']
199
203
  o.http_checksum_required = true if operation['httpChecksumRequired']
204
+ if operation.key?('httpChecksum')
205
+ operation['httpChecksum']['requestAlgorithmMember'] = underscore(operation['httpChecksum']['requestAlgorithmMember']) if operation['httpChecksum']['requestAlgorithmMember']
206
+ operation['httpChecksum']['requestValidationModeMember'] = underscore(operation['httpChecksum']['requestValidationModeMember']) if operation['httpChecksum']['requestValidationModeMember']
207
+
208
+ o.http_checksum = operation['httpChecksum'].inject([]) do |a, (k, v)|
209
+ a << { key: k.inspect, value: v.inspect }
210
+ a
211
+ end
212
+ end
200
213
  %w(input output).each do |key|
201
214
  if operation[key]
202
215
  o.shape_references << "o.#{key} = #{operation_ref(operation[key])}"
@@ -535,6 +548,9 @@ module AwsSdkCodeGenerator
535
548
  # @return [Boolean]
536
549
  attr_accessor :http_checksum_required
537
550
 
551
+ # @return [Hash]
552
+ attr_accessor :http_checksum
553
+
538
554
  # @return [Array<String>]
539
555
  attr_accessor :shape_references
540
556
 
@@ -18,6 +18,7 @@ module AwsSdkCodeGenerator
18
18
  # @option options [required, Hash] :api
19
19
  # @option options [Hash] :waiters
20
20
  # @option options [Hash] :client_examples
21
+ # @option options [Array<CodegeneratedPlugin] :codegenerated_plugins
21
22
  def initialize(options)
22
23
  @service_identifier = options.fetch(:service_identifier)
23
24
  @service_name = options.fetch(:service_name)
@@ -25,7 +26,11 @@ module AwsSdkCodeGenerator
25
26
  @gem_name = options.fetch(:gem_name)
26
27
  @gem_version = options.fetch(:gem_version)
27
28
  @plugins = PluginList.new(options)
28
- @client_constructor = ClientConstructor.new(options.merge(plugins: @plugins))
29
+ @codegenerated_plugins = options.fetch(:codegenerated_plugins, [])
30
+ @client_constructor = ClientConstructor.new(
31
+ options.merge(
32
+ plugins: @plugins,
33
+ codegenerated_plugins: @codegenerated_plugins))
29
34
  @operations = ClientOperationList.new(options).to_a
30
35
  @waiters = Waiter.build_list(options[:waiters])
31
36
  @custom = options.fetch(:custom)
@@ -65,7 +70,7 @@ module AwsSdkCodeGenerator
65
70
 
66
71
  # @return [Array<String>]
67
72
  def plugin_class_names
68
- @plugins.map(&:class_name)
73
+ @plugins.map(&:class_name) + @codegenerated_plugins.map(&:class_name)
69
74
  end
70
75
 
71
76
  # @return [Array<Waiter>]
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ class EndpointParametersClass < View
6
+
7
+ # @option options [required, Service] :service
8
+ def initialize(options)
9
+ @service = options.fetch(:service)
10
+ if (parameters = @service.endpoint_rules&.fetch('parameters'))
11
+ @parameters = parameters.map do |k,p|
12
+ EndpointParameter.new(k, p)
13
+ end
14
+ end
15
+ end
16
+
17
+ # @return [Array<EndpointParameter>]
18
+ attr_reader :parameters
19
+
20
+ # @return [String|nil]
21
+ def generated_src_warning
22
+ return if @service.protocol == 'api-gateway'
23
+ GENERATED_SRC_WARNING
24
+ end
25
+
26
+ def module_name
27
+ @service.module_name
28
+ end
29
+
30
+ class EndpointParameter
31
+ def initialize(name, definition={})
32
+ @name = name
33
+ @type = definition['type']
34
+ @built_in = definition['builtIn']
35
+ @default = definition['default']
36
+ @required = definition['required']
37
+ @documentation = "# @!attribute #{underscore_name}\n"
38
+ if definition['documentation']
39
+ @documentation += " # #{definition['documentation']}\n"
40
+ end
41
+ if deprecated = definition['deprecated']
42
+ @documentation += " #\n # @deprecated\n"
43
+ if deprecated['message']
44
+ @documentation += " # #{deprecated['message']}\n"
45
+ end
46
+ if deprecated['since']
47
+ @documentation += " # Since: #{deprecated['since']}\n"
48
+ end
49
+ end
50
+ @documentation += " #\n # @return [#{@type}]\n #"
51
+ end
52
+
53
+ # @return [String]
54
+ attr_reader :name
55
+
56
+ # @return [String]
57
+ attr_reader :documentation
58
+
59
+ # @return [Boolean]
60
+ attr_reader :required
61
+
62
+ # @return [String,Boolean]
63
+ attr_reader :default
64
+
65
+ def default?
66
+ !@default.nil?
67
+ end
68
+
69
+ def boolean_default?
70
+ default? && (@default == true || @default == false)
71
+ end
72
+
73
+ def underscore_name
74
+ Underscore.underscore(name)
75
+ end
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ class EndpointProviderClass < View
6
+
7
+ # @option options [required, Service] :service
8
+ # @option options [required, Hash] :endpoint_rules
9
+ def initialize(options)
10
+ @service = options.fetch(:service)
11
+ @endpoint_rules = @service.endpoint_rules
12
+
13
+ version = @endpoint_rules['version']
14
+ return if version&.match(/^\d+\.\d+$/) # && version == '1.0'
15
+
16
+ raise 'Endpoint Rules version must be 1.0'
17
+ end
18
+
19
+ # @return [String|nil]
20
+ def generated_src_warning
21
+ return if @service.protocol == 'api-gateway'
22
+ GENERATED_SRC_WARNING
23
+ end
24
+
25
+ def module_name
26
+ @service.module_name
27
+ end
28
+
29
+ def endpoint_rules_encoded
30
+ Base64.encode64(JSON.dump(@endpoint_rules))
31
+ end
32
+ end
33
+ end
34
+ end