aws-sdk-code-generator 0.4.0.pre → 0.6.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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aws-sdk-code-generator/api.rb +2 -1
  3. data/lib/aws-sdk-code-generator/client_constructor.rb +2 -1
  4. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +2 -1
  5. data/lib/aws-sdk-code-generator/client_operation_list.rb +4 -0
  6. data/lib/aws-sdk-code-generator/code_builder.rb +54 -2
  7. data/lib/aws-sdk-code-generator/endpoint_parameter.rb +190 -0
  8. data/lib/aws-sdk-code-generator/eventstream_example.rb +34 -34
  9. data/lib/aws-sdk-code-generator/gem_builder.rb +3 -5
  10. data/lib/aws-sdk-code-generator/helper.rb +11 -1
  11. data/lib/aws-sdk-code-generator/plugin_list.rb +5 -2
  12. data/lib/aws-sdk-code-generator/rbs/error_list.rb +38 -0
  13. data/lib/aws-sdk-code-generator/rbs/keyword_argument_builder.rb +159 -0
  14. data/lib/aws-sdk-code-generator/rbs/method_signature.rb +11 -0
  15. data/lib/aws-sdk-code-generator/rbs/resource_action.rb +39 -0
  16. data/lib/aws-sdk-code-generator/rbs/resource_association.rb +50 -0
  17. data/lib/aws-sdk-code-generator/rbs/resource_batch_action.rb +59 -0
  18. data/lib/aws-sdk-code-generator/rbs/resource_client_request.rb +40 -0
  19. data/lib/aws-sdk-code-generator/rbs/waiter.rb +53 -0
  20. data/lib/aws-sdk-code-generator/rbs.rb +40 -0
  21. data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +3 -1
  22. data/lib/aws-sdk-code-generator/resource_client_request.rb +3 -1
  23. data/lib/aws-sdk-code-generator/resource_waiter.rb +6 -5
  24. data/lib/aws-sdk-code-generator/service.rb +85 -16
  25. data/lib/aws-sdk-code-generator/views/async_client_class.rb +5 -1
  26. data/lib/aws-sdk-code-generator/views/client_api_module.rb +58 -16
  27. data/lib/aws-sdk-code-generator/views/client_class.rb +5 -1
  28. data/lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb +6 -50
  29. data/lib/aws-sdk-code-generator/views/endpoint_provider_class.rb +9 -0
  30. data/lib/aws-sdk-code-generator/views/endpoints_module.rb +18 -124
  31. data/lib/aws-sdk-code-generator/views/endpoints_plugin.rb +46 -4
  32. data/lib/aws-sdk-code-generator/views/errors_module.rb +21 -0
  33. data/lib/aws-sdk-code-generator/views/event_streams_module.rb +7 -1
  34. data/lib/aws-sdk-code-generator/views/features/smoke.rb +100 -23
  35. data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +1 -4
  36. data/lib/aws-sdk-code-generator/views/gemspec.rb +13 -3
  37. data/lib/aws-sdk-code-generator/views/rbs/client_class.rb +172 -0
  38. data/lib/aws-sdk-code-generator/views/rbs/errors_module.rb +28 -0
  39. data/lib/aws-sdk-code-generator/views/rbs/resource_class.rb +95 -0
  40. data/lib/aws-sdk-code-generator/views/rbs/root_resource_class.rb +30 -0
  41. data/lib/aws-sdk-code-generator/views/rbs/types_module.rb +257 -0
  42. data/lib/aws-sdk-code-generator/views/rbs/waiters_module.rb +22 -0
  43. data/lib/aws-sdk-code-generator/views/resource_class.rb +22 -0
  44. data/lib/aws-sdk-code-generator/views/root_resource_class.rb +19 -0
  45. data/lib/aws-sdk-code-generator/views/service_module.rb +41 -27
  46. data/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +25 -12
  47. data/lib/aws-sdk-code-generator/views/types_module.rb +34 -11
  48. data/lib/aws-sdk-code-generator.rb +29 -1
  49. data/templates/async_client_class.mustache +6 -1
  50. data/templates/client_api_module.mustache +14 -0
  51. data/templates/client_class.mustache +10 -47
  52. data/templates/endpoint_parameters_class.mustache +16 -13
  53. data/templates/endpoints_module.mustache +19 -11
  54. data/templates/endpoints_plugin.mustache +38 -20
  55. data/templates/errors_module.mustache +5 -0
  56. data/templates/features/smoke.mustache +11 -15
  57. data/templates/features/step_definitions.mustache +0 -5
  58. data/templates/gemspec.mustache +5 -2
  59. data/templates/rbs/client_class.mustache +39 -0
  60. data/templates/rbs/errors_module.mustache +17 -0
  61. data/templates/rbs/resource_class.mustache +71 -0
  62. data/templates/rbs/root_resource_class.mustache +26 -0
  63. data/templates/rbs/types_module.mustache +37 -0
  64. data/templates/rbs/waiters_module.mustache +17 -0
  65. data/templates/resource_class.mustache +8 -1
  66. data/templates/root_resource_class.mustache +5 -0
  67. data/templates/service_module.mustache +13 -3
  68. data/templates/spec/endpoint_provider_spec_class.mustache +11 -1
  69. data/templates/types_module.mustache +4 -0
  70. metadata +27 -7
  71. data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +0 -26
  72. data/templates/features/smoke_step_definitions.mustache +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4bb64ca30811529d0c5c4149e3d46b7eabef0d3068672ca06ed6d9fc97369f5
4
- data.tar.gz: c2e56887b3686a58569da5fa643a8cb69bcca35c4b0f24dbdd67e48c3d3675c8
3
+ metadata.gz: 7a56cc48e83d1c1b3f3c4abf956e29fdd7adb2aed45c2ff8d69b8489ad569518
4
+ data.tar.gz: 5ff9d87ff0f38a08370358ccccd6bf9e69f0e77da2bcba60b1042501fead60d7
5
5
  SHA512:
6
- metadata.gz: 3a6b20c93b4c58ef3bfac9e2d48551540106fa907deb17b72bb00876c807a2dbf05079b38634534a18a563a6f0b6affd98564a94a16370ba4e3d7efcf34a1034
7
- data.tar.gz: 63b927d59a16241bc32e5ec51d647ae6dcc952c562e9eedccf50451bf62a64065d3833be2b8b0d7ffef6114300068b426bf3a96617c0c97f8bb9932b3ff45605
6
+ metadata.gz: be96b1aa147f0e2a8bdf45c383feaa21511d81c6129e648cc5fc488f1f19808aee62ec78916c2f9a9a5e3060dcc12bdb61a1e9a890af21c3ee610438997e3798
7
+ data.tar.gz: c4f0731f69dd91ddcd4498363cb149ee361cfe452c8cbe6c8e7e05d85586bf11b84494a4ececd41f0308ce1dfb612aa3e032575f9abca3566f6476f6857d1a67
@@ -131,7 +131,8 @@ module AwsSdkCodeGenerator
131
131
  # @return [Boolean]
132
132
  def streaming_input?(shape, operation)
133
133
  shape['streaming'] && operation &&
134
- operation['authtype'] == "v4-unsigned-body"
134
+ (operation['unsignedPayload'] ||
135
+ operation['authtype'] == 'v4-unsigned-body')
135
136
  end
136
137
 
137
138
  def plural?(resource)
@@ -8,7 +8,8 @@ module AwsSdkCodeGenerator
8
8
 
9
9
  def initialize(options)
10
10
  plugin_options = documented_plugin_options(options.fetch(:plugins)) +
11
- documented_plugin_options(options.fetch(:codegenerated_plugins))
11
+ documented_plugin_options(options.fetch(:codegenerated_plugins)) +
12
+ documented_plugin_options(options.fetch(:default_plugins, []))
12
13
  documentation = {}
13
14
  plugin_options.each do |option|
14
15
  documentation[option.name] = YardOptionTag.new(
@@ -16,6 +16,7 @@ module AwsSdkCodeGenerator
16
16
  @method_name = options.fetch(:method_name)
17
17
  @operation = options.fetch(:operation)
18
18
  @api = options.fetch(:api)
19
+ @protocol = options.fetch(:protocol)
19
20
  @client_examples = options.fetch(:client_examples, [])
20
21
  @examples = options.fetch(:examples)
21
22
  @module_name = options.fetch(:module_name)
@@ -279,7 +280,7 @@ module AwsSdkCodeGenerator
279
280
 
280
281
  def see_also_tag(operation, api)
281
282
  uid = api['metadata']['uid']
282
- if api['metadata']['protocol'] != 'api-gateway' && Crosslink.taggable?(uid)
283
+ if @protocol != 'api-gateway' && Crosslink.taggable?(uid)
283
284
  "# " + Crosslink.tag_string(uid, operation)
284
285
  end
285
286
  end
@@ -9,6 +9,7 @@ module AwsSdkCodeGenerator
9
9
  api = options.fetch(:api)
10
10
  examples = options.fetch(:examples, {})
11
11
  module_name = options.fetch(:module_name)
12
+ protocol = options.fetch(:protocol)
12
13
  protocol_settings = options.fetch(:protocol_settings, {})
13
14
  client_examples = options.fetch(:client_examples, {})
14
15
  paginators = options.fetch(:paginators, {})
@@ -41,6 +42,7 @@ module AwsSdkCodeGenerator
41
42
  method_name: method_name,
42
43
  operation: operation,
43
44
  api: api,
45
+ protocol: protocol,
44
46
  examples: examples,
45
47
  client_examples: client_examples[method_name] || [],
46
48
  async_client: true
@@ -60,6 +62,7 @@ module AwsSdkCodeGenerator
60
62
  method_name: method_name,
61
63
  operation: operation,
62
64
  api: api,
65
+ protocol: protocol,
63
66
  examples: examples,
64
67
  client_examples: client_examples[method_name] || [],
65
68
  async_client: false
@@ -80,6 +83,7 @@ module AwsSdkCodeGenerator
80
83
  method_name: method_name,
81
84
  operation: operation,
82
85
  api: api,
86
+ protocol: protocol,
83
87
  examples: examples,
84
88
  client_examples: client_examples[method_name] || [],
85
89
  async_client: false,
@@ -109,6 +109,58 @@ module AwsSdkCodeGenerator
109
109
  end
110
110
  end
111
111
 
112
+ # @return [Enumerable<String<path>, String<code>>]
113
+ def rbs_files(options = {})
114
+ Enumerator.new do |y|
115
+ prefix = options.fetch(:prefix, '')
116
+ codegenerated_plugins = codegen_plugins(prefix)
117
+ client_class = Views::RBS::ClientClass.new(
118
+ service_name: @service.name,
119
+ codegenerated_plugins: codegenerated_plugins,
120
+ aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
121
+ legacy_endpoints: @service.legacy_endpoints?,
122
+ signature_version: @service.signature_version,
123
+ api: @service.api,
124
+ waiters: @service.waiters,
125
+ protocol: @service.protocol,
126
+ add_plugins: @service.add_plugins,
127
+ remove_plugins: @service.remove_plugins,
128
+ )
129
+ y.yield("#{prefix}/client.rbs", client_class.render)
130
+ y.yield("#{prefix}/errors.rbs", Views::RBS::ErrorsModule.new(
131
+ service: @service
132
+ ).render)
133
+ y.yield("#{prefix}/resource.rbs", Views::RBS::RootResourceClass.new(
134
+ service_name: @service.name,
135
+ client_class: client_class,
136
+ api: @service.api,
137
+ resources: @service.resources,
138
+ paginators: @service.paginators,
139
+ ).render)
140
+ y.yield("#{prefix}/waiters.rbs", Views::RBS::WaitersModule.new(
141
+ service_name: @service.name,
142
+ api: @service.api,
143
+ waiters: @service.waiters,
144
+ ).render)
145
+ y.yield("#{prefix}/types.rbs", Views::RBS::TypesModule.new(
146
+ service: @service
147
+ ).render)
148
+ if @resources
149
+ @resources['resources'].keys.sort.each do |class_name|
150
+ path = "#{prefix}/#{Underscore.underscore(class_name)}.rbs"
151
+ code = Views::RBS::ResourceClass.new(
152
+ service_name: @service.name,
153
+ class_name: class_name,
154
+ resource: @resources['resources'][class_name],
155
+ api: @service.api,
156
+ paginators: @service.paginators,
157
+ ).render
158
+ y.yield(path, code)
159
+ end
160
+ end
161
+ end
162
+ end
163
+
112
164
  private
113
165
 
114
166
  def service_module(prefix, codegenerated_plugins)
@@ -133,13 +185,13 @@ module AwsSdkCodeGenerator
133
185
  Views::ClientClass.new(
134
186
  service_identifier: @service.identifier,
135
187
  service_name: @service.name,
188
+ protocol: @service.protocol,
136
189
  protocol_settings: @service.protocol_settings,
137
190
  module_name: @service.module_name,
138
191
  gem_name: @service.gem_name,
139
192
  gem_version: @service.gem_version,
140
193
  aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
141
194
  client_examples: @client_examples,
142
- protocol: @service.protocol,
143
195
  signature_version: @service.signature_version,
144
196
  require_endpoint_discovery: @service.require_endpoint_discovery,
145
197
  add_plugins: @service.add_plugins,
@@ -158,12 +210,12 @@ module AwsSdkCodeGenerator
158
210
  Views::AsyncClientClass.new(
159
211
  service_identifier: @service.identifier,
160
212
  service_name: @service.name,
213
+ protocol: @service.protocol,
161
214
  protocol_settings: @service.protocol_settings,
162
215
  module_name: @service.module_name,
163
216
  gem_name: @service.gem_name,
164
217
  gem_version: @service.gem_version,
165
218
  aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
166
- protocol: @service.protocol,
167
219
  signature_version: @service.signature_version,
168
220
  add_plugins: @service.add_plugins,
169
221
  remove_plugins: @service.remove_plugins,
@@ -0,0 +1,190 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class EndpointParameter
5
+ def initialize(name, definition, service, operation=nil)
6
+ @name = name
7
+
8
+ @value, @source = endpoint_parameter_value(name, definition, service, operation)
9
+
10
+ @type = definition['type']
11
+ @built_in = definition['builtIn']
12
+ @default = definition['default']
13
+ @required = definition['required']
14
+ @documentation = "# @!attribute #{key}\n"
15
+ if definition['documentation']
16
+ @documentation += " # #{definition['documentation']}\n"
17
+ end
18
+ if deprecated = definition['deprecated']
19
+ @documentation += " #\n # @deprecated\n"
20
+ if deprecated['message']
21
+ @documentation += " # #{deprecated['message']}\n"
22
+ end
23
+ if deprecated['since']
24
+ @documentation += " # Since: #{deprecated['since']}\n"
25
+ end
26
+ end
27
+ @documentation += " #\n # @return [#{@type}]\n #"
28
+ end
29
+
30
+ # @return [String]
31
+ attr_reader :name
32
+
33
+ # @return [String]
34
+ attr_reader :documentation
35
+
36
+ # @return [Boolean]
37
+ attr_reader :required
38
+
39
+ # @return [String]
40
+ attr_reader :source
41
+
42
+ # @return [String]
43
+ attr_reader :value
44
+
45
+ # @return [String,Boolean,Array]
46
+ def default
47
+ case @default
48
+ when String
49
+ "\"#{@default}\""
50
+ else
51
+ @default.to_s
52
+ end
53
+ end
54
+
55
+ def default?
56
+ !@default.nil?
57
+ end
58
+
59
+ def validate_required?
60
+ required && !default?
61
+ end
62
+
63
+ def key
64
+ Underscore.underscore(name)
65
+ end
66
+
67
+ private
68
+
69
+ # Most to least
70
+ # staticContextParams
71
+ # contextParam
72
+ # operationContextParams
73
+ # clientContextParams (always sourced from config)
74
+ # Built-In Bindings (sourced from config in most cases, context in some cases to allow operation level overrides)
75
+ # Built-in binding default values
76
+ # @retyrn [value, source]. source may be one of [operation, config, default]
77
+ def endpoint_parameter_value(param_name, param_data, service, operation)
78
+ unless operation.nil?
79
+ value, source = [
80
+ static_context_param(operation, param_name), 'operation'
81
+ ]
82
+ value, source = [
83
+ context_param_value(service, operation, param_name), 'operation'
84
+ ] unless value
85
+ value, source = [
86
+ operation_context_param_value(operation, param_name), 'operation'
87
+ ] unless value
88
+ end
89
+
90
+ value, source = [
91
+ client_context_param_value(service, param_name, param_data),
92
+ 'config'
93
+ ] unless value
94
+
95
+
96
+ # built-ins may be sourced from operation context in some cases
97
+ unless value
98
+ value, source = built_in_param_value(service, param_data)
99
+ end
100
+
101
+ [value || 'nil', source || 'default']
102
+ end
103
+
104
+ def client_context_param_value(service, param_name, param_data)
105
+ if service.api['clientContextParams']&.key?(param_name) &&
106
+ !param_data['builtIn']
107
+ "config.#{Underscore.underscore(param_name)}"
108
+ end
109
+ end
110
+
111
+ # built-ins may be sourced from operation context in some cases
112
+ def built_in_param_value(service, param_data)
113
+ source = 'config'
114
+ value =
115
+ case param_data['builtIn']
116
+ when 'AWS::Region'
117
+ 'config.region'
118
+ when 'AWS::UseFIPS'
119
+ 'config.use_fips_endpoint'
120
+ when 'AWS::UseDualStack'
121
+ if service.name == 'S3' || service.name == 'S3Control'
122
+ source = 'operation'
123
+ 'context[:use_dualstack_endpoint]'
124
+ else
125
+ 'config.use_dualstack_endpoint'
126
+ end
127
+ when 'AWS::Auth::AccountId'
128
+ 'config.credentials.credentials.account_id'
129
+ when 'AWS::Auth::AccountIdEndpointMode'
130
+ 'config.account_id_endpoint_mode'
131
+ when 'AWS::STS::UseGlobalEndpoint'
132
+ "config.sts_regional_endpoints == 'legacy'"
133
+ when 'AWS::S3::UseGlobalEndpoint'
134
+ "config.s3_us_east_1_regional_endpoint == 'legacy'"
135
+ when 'AWS::S3::Accelerate'
136
+ if service.name == 'S3' || service.name == 'S3Control'
137
+ source = 'operation'
138
+ 'context[:use_accelerate_endpoint]'
139
+ else
140
+ 'config.use_accelerate_endpoint'
141
+ end
142
+ when 'AWS::S3::ForcePathStyle'
143
+ 'config.force_path_style'
144
+ when 'AWS::S3::UseArnRegion', 'AWS::S3Control::UseArnRegion'
145
+ 'config.s3_use_arn_region'
146
+ when 'AWS::S3::DisableMultiRegionAccessPoints'
147
+ 'config.s3_disable_multiregion_access_points'
148
+ when 'SDK::Endpoint'
149
+ '(config.endpoint.to_s unless config.regional_endpoint)'
150
+ else
151
+ source = nil
152
+ nil # no value, not a default
153
+ end
154
+ [value, source]
155
+ end
156
+
157
+ def context_param_value(service, operation, param_name)
158
+ return nil unless operation['input']
159
+
160
+ input_shape = operation['input']['shape']
161
+ members = service.api['shapes'][input_shape].fetch('members', {})
162
+ members.detect do |(member_name, member)|
163
+ context_param = member.fetch('contextParam', {})
164
+ if context_param.fetch('name', nil) == param_name
165
+ break "context.params[:#{Underscore.underscore(member_name)}]"
166
+ end
167
+ end
168
+ end
169
+
170
+ def operation_context_param_value(operation, param_name)
171
+ return nil unless operation['input']
172
+
173
+ binding = operation.fetch('operationContextParams', {})[param_name]
174
+
175
+ return nil unless binding
176
+
177
+ "JMESPath.search(\"#{Underscore.underscore_jmespath(binding['path'])}\", context.params)"
178
+ end
179
+
180
+ def static_context_param(operation, param_name)
181
+ value = operation.fetch('staticContextParams', {})
182
+ .fetch(param_name, {}).fetch('value', nil)
183
+ if !value.nil? && value.is_a?(String)
184
+ "\"#{value}\""
185
+ else
186
+ value
187
+ end
188
+ end
189
+ end
190
+ end
@@ -39,52 +39,53 @@ module AwsSdkCodeGenerator
39
39
  <<-EXAMPLE.strip
40
40
  # @example Bi-directional EventStream Operation Example
41
41
  #
42
- # You can signal input events after initial request is
43
- # established, events will be sent to stream
44
- # immediately (once stream connection is established successfully).
42
+ # You can signal input events after the initial request is established. Events
43
+ # will be sent to the stream immediately once the stream connection is
44
+ # established successfully.
45
45
  #
46
- # To signal events, you can call #signal methods from an #{@input_eventstream} object.
47
- # Make sure signal events before calling #wait or #join! at async response.
46
+ # To signal events, you can call the #signal methods from an #{@input_eventstream}
47
+ # object. You must signal events before calling #wait or #join! on the async response.
48
48
  #
49
49
  # input_stream = #{@input_eventstream}.new
50
50
  #
51
- # async_resp = #{@receiver}.#{@method_name}( # params input,
51
+ # async_resp = #{@receiver}.#{@method_name}(
52
+ # # params input
52
53
  # input_event_stream_handler: input_stream) do |out_stream|
53
54
  #
54
- # # register callbacks for events arrival
55
+ # # register callbacks for events
55
56
  #{event_entry(:output, 'out_stream', 2)}
56
57
  #
57
58
  # end
58
- # # => returns Aws::Seahorse::Client::AsyncResponse
59
+ # # => Aws::Seahorse::Client::AsyncResponse
59
60
  #
60
61
  # # signal events
61
62
  #{event_entry(:input, 'input_stream')}
62
63
  #
63
- # # make sure signaling :end_stream in the end
64
+ # # make sure to signal :end_stream at the end
64
65
  # input_stream.signal_end_stream
65
66
  #
66
- # # wait until stream is closed before finalizing sync response
67
+ # # wait until stream is closed before finalizing the sync response
67
68
  # resp = async_resp.wait
68
- # # Or close stream and finalizing sync response immediately
69
+ # # Or close the stream and finalize sync response immediately
69
70
  # # resp = async_resp.join!
70
71
  #
71
- # Inorder to streamingly processing events received, you can also provide an #{@output_eventstream}
72
- # object to register callbacks before initializing request instead of processing from request block
72
+ # You can also provide an #{@output_eventstream} object to register callbacks
73
+ # before initializing the request instead of processing from the request block.
73
74
  #
74
75
  # output_stream = #{@output_eventstream}.new
75
- # # register callbacks for events arrival
76
+ # # register callbacks for output events
76
77
  #{event_entry(:output, 'output_stream')}
77
78
  #{error_event_entry('output_stream')}
78
79
  #
79
- # async_resp = #{@receiver}.#{@method_name} ( #params input,
80
+ # async_resp = #{@receiver}.#{@method_name} (
81
+ # # params input
80
82
  # input_event_stream_handler: input_stream
81
83
  # output_event_stream_handler: output_stream
82
84
  # )
83
85
  #
84
- # resp = async_resp.wait!
86
+ # resp = async_resp.join!
85
87
  #
86
- # Besides above usage patterns for process events when they arrive immediately, you can also
87
- # iterate through events after response complete.
88
+ # You can also iterate through events after the response is complete.
88
89
  #
89
90
  # Events are available at #{@resp_var}.#{@output_eventstream_member} # => Enumerator
90
91
  EXAMPLE
@@ -94,22 +95,22 @@ module AwsSdkCodeGenerator
94
95
  <<-EXAMPLE.strip
95
96
  # @example EventStream Operation Example
96
97
  #
97
- # You can process event once it arrives immediately, or wait until
98
- # full response complete and iterate through eventstream enumerator.
98
+ # You can process the event once it arrives immediately, or wait until the
99
+ # full response is complete and iterate through the eventstream enumerator.
99
100
  #
100
101
  # To interact with event immediately, you need to register ##{@method_name}
101
- # with callbacks, callbacks can be register for specifc events or for all events,
102
- # callback for errors in the event stream is also available for register.
102
+ # with callbacks. Callbacks can be registered for specific events or for all
103
+ # events, including error events.
103
104
  #
104
- # Callbacks can be passed in by `:event_stream_handler` option or within block
105
- # statement attached to ##{@method_name} call directly. Hybrid pattern of both
106
- # is also supported.
105
+ # Callbacks can be passed into the `:event_stream_handler` option or within a
106
+ # block statement attached to the ##{@method_name} call directly. Hybrid
107
+ # pattern of both is also supported.
107
108
  #
108
- # `:event_stream_handler` option takes in either Proc object or
109
+ # `:event_stream_handler` option takes in either a Proc object or
109
110
  # #{@output_eventstream} object.
110
111
  #
111
- # Usage pattern a): callbacks with a block attached to ##{@method_name}
112
- # Example for registering callbacks for all event types and error event
112
+ # Usage pattern a): Callbacks with a block attached to ##{@method_name}
113
+ # Example for registering callbacks for all event types and an error event
113
114
  #
114
115
  # #{@receiver}.#{@method_name}( # params input# ) do |stream|
115
116
  #{error_event_entry('stream', 2)}
@@ -122,9 +123,9 @@ module AwsSdkCodeGenerator
122
123
  #
123
124
  # end
124
125
  #
125
- # Usage pattern b): pass in `:event_stream_handler` for ##{@method_name}
126
+ # Usage pattern b): Pass in `:event_stream_handler` for ##{@method_name}
126
127
  #
127
- # 1) create a #{@output_eventstream} object
128
+ # 1) Create a #{@output_eventstream} object
128
129
  # Example for registering callbacks with specific events
129
130
  #
130
131
  # handler = #{@output_eventstream}.new
@@ -132,7 +133,7 @@ module AwsSdkCodeGenerator
132
133
  #
133
134
  # #{@receiver}.#{@method_name}( # params input #, event_stream_handler: handler)
134
135
  #
135
- # 2) use a Ruby Proc object
136
+ # 2) Use a Ruby Proc object
136
137
  # Example for registering callbacks with specific events
137
138
  #
138
139
  # handler = Proc.new do |stream|
@@ -141,7 +142,7 @@ module AwsSdkCodeGenerator
141
142
  #
142
143
  # #{@receiver}.#{@method_name}( # params input #, event_stream_handler: handler)
143
144
  #
144
- # Usage pattern c): hybird pattern of a) and b)
145
+ # Usage pattern c): Hybrid pattern of a) and b)
145
146
  #
146
147
  # handler = #{@output_eventstream}.new
147
148
  #{event_entry(:output, 'handler', 2)}
@@ -150,8 +151,7 @@ module AwsSdkCodeGenerator
150
151
  #{error_event_entry('stream', 2)}
151
152
  # end
152
153
  #
153
- # Besides above usage patterns for process events when they arrive immediately, you can also
154
- # iterate through events after response complete.
154
+ # You can also iterate through events after the response complete.
155
155
  #
156
156
  # Events are available at #{@resp_var}.#{@output_eventstream_member} # => Enumerator
157
157
  # For parameter input example, please refer to following request syntax
@@ -25,7 +25,6 @@ module AwsSdkCodeGenerator
25
25
  y.yield('features/step_definitions.rb', features_step_definitions_file)
26
26
  if @service.smoke_tests
27
27
  y.yield('features/smoke.feature', smoke_file)
28
- y.yield('features/smoke_step_definitions.rb', smoke_step_definitions_file)
29
28
  end
30
29
  y.yield('VERSION', version_file)
31
30
  y.yield('LICENSE.txt', license_file)
@@ -37,6 +36,9 @@ module AwsSdkCodeGenerator
37
36
  code.spec_files.each do |path, code|
38
37
  y.yield("spec/#{path}", code)
39
38
  end
39
+ code.rbs_files.each do |path, code|
40
+ y.yield("sig/#{path}", code)
41
+ end
40
42
  end.each(&block)
41
43
  end
42
44
 
@@ -54,10 +56,6 @@ module AwsSdkCodeGenerator
54
56
  Views::Features::Smoke.new(options).render
55
57
  end
56
58
 
57
- def smoke_step_definitions_file
58
- Views::Features::SmokeStepDefinitions.new(options).render
59
- end
60
-
61
59
  def features_step_definitions_file
62
60
  Views::Features::StepDefinitions.new(options).render
63
61
  end
@@ -175,8 +175,18 @@ module AwsSdkCodeGenerator
175
175
  str.gsub(/(.{1,#{width}})(\s+|\Z)/, "#{indent}\\1\n").chomp
176
176
  end
177
177
 
178
+ def gem_lib_path(gem_name)
179
+ File.expand_path(
180
+ File.join(
181
+ __dir__,
182
+ "../../../../gems/#{gem_name}/lib/"
183
+ )
184
+ )
185
+ end
186
+
178
187
  module_function :deep_copy, :operation_streaming?, :downcase_first, :wrap_string, :apig_prefix,
179
- :eventstream_output?, :eventstream_input?, :operation_eventstreaming?, :pascal_case
188
+ :eventstream_output?, :eventstream_input?, :operation_eventstreaming?, :pascal_case,
189
+ :gem_lib_path
180
190
 
181
191
  end
182
192
  end
@@ -54,14 +54,17 @@ module AwsSdkCodeGenerator
54
54
  'Aws::Plugins::ResponsePaging' => "#{core_plugins}/response_paging.rb",
55
55
  'Aws::Plugins::StubResponses' => "#{core_plugins}/stub_responses.rb",
56
56
  'Aws::Plugins::IdempotencyToken' => "#{core_plugins}/idempotency_token.rb",
57
+ 'Aws::Plugins::InvocationId' => "#{core_plugins}/invocation_id.rb",
57
58
  'Aws::Plugins::JsonvalueConverter' => "#{core_plugins}/jsonvalue_converter.rb",
58
59
  'Aws::Plugins::ClientMetricsPlugin' => "#{core_plugins}/client_metrics_plugin.rb",
59
60
  'Aws::Plugins::ClientMetricsSendPlugin' => "#{core_plugins}/client_metrics_send_plugin.rb",
60
61
  'Aws::Plugins::TransferEncoding' => "#{core_plugins}/transfer_encoding.rb",
61
62
  'Aws::Plugins::HttpChecksum' => "#{core_plugins}/http_checksum.rb",
62
63
  'Aws::Plugins::ChecksumAlgorithm' => "#{core_plugins}/checksum_algorithm.rb",
64
+ 'Aws::Plugins::RequestCompression' => "#{core_plugins}/request_compression.rb",
63
65
  'Aws::Plugins::DefaultsMode' => "#{core_plugins}/defaults_mode.rb",
64
- 'Aws::Plugins::RecursionDetection' => "#{core_plugins}/recursion_detection.rb"
66
+ 'Aws::Plugins::RecursionDetection' => "#{core_plugins}/recursion_detection.rb",
67
+ 'Aws::Plugins::Telemetry' => "#{core_plugins}/telemetry.rb"
65
68
  }
66
69
  end
67
70
 
@@ -74,7 +77,6 @@ module AwsSdkCodeGenerator
74
77
  plugins.delete('Aws::Plugins::ClientMetricsPlugin')
75
78
  plugins.delete('Aws::Plugins::ClientMetricsSendPlugin')
76
79
  plugins.delete('Aws::Plugins::TransferEncoding')
77
- plugins['Aws::Plugins::InvocationId'] = "#{core_plugins}/invocation_id.rb"
78
80
  plugins
79
81
  end
80
82
 
@@ -85,6 +87,7 @@ module AwsSdkCodeGenerator
85
87
  'rest-xml' => { 'Aws::Plugins::Protocols::RestXml' => "#{core_plugins}/protocols/rest_xml.rb" },
86
88
  'query' => { 'Aws::Plugins::Protocols::Query' => "#{core_plugins}/protocols/query.rb" },
87
89
  'ec2' => { 'Aws::Plugins::Protocols::EC2' => "#{core_plugins}/protocols/ec2.rb" },
90
+ 'smithy-rpc-v2-cbor' => { 'Aws::Plugins::Protocols::RpcV2' => "#{core_plugins}/protocols/rpc_v2.rb" },
88
91
  'api-gateway' => {
89
92
  'Aws::Plugins::Protocols::ApiGateway' => "#{core_plugins}/protocols/api_gateway.rb",
90
93
  'Aws::Plugins::ApiKey' => "#{core_plugins}/api_key.rb",
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module RBS
5
+ class ErrorList
6
+ include Enumerable
7
+
8
+ def initialize(api:, module_name:)
9
+ @api = api
10
+ @module_name = module_name
11
+ @errors = @api['shapes'].inject([]) do |es, (name, shape)|
12
+ if error_struct?(shape)
13
+ members = shape["members"].map do |member_name, member_body|
14
+ MethodSignature.new(
15
+ method_name: Underscore.underscore(member_name),
16
+ overloads: ["() -> #{Docstring.ucfirst(member_body['type'] ||'::String')}"]
17
+ )
18
+ end
19
+ es << {
20
+ name: name,
21
+ members: members,
22
+ }
23
+ end
24
+ es
25
+ end
26
+ end
27
+
28
+ def error_struct?(shape)
29
+ shape['type'] == 'structure' && !!!shape['event'] &&
30
+ (shape['error'] || shape['exception'])
31
+ end
32
+
33
+ def to_a
34
+ @errors
35
+ end
36
+ end
37
+ end
38
+ end