aws-sdk-code-generator 0.1.0.pre → 0.2.4.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/lib/aws-sdk-code-generator/api.rb +150 -0
  3. data/lib/aws-sdk-code-generator/apply_docs.rb +15 -2
  4. data/lib/aws-sdk-code-generator/client_constructor.rb +39 -0
  5. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +282 -0
  6. data/lib/aws-sdk-code-generator/client_operation_list.rb +148 -0
  7. data/lib/aws-sdk-code-generator/client_response_structure_example.rb +115 -0
  8. data/lib/aws-sdk-code-generator/code_builder.rb +146 -133
  9. data/lib/aws-sdk-code-generator/crosslink.rb +42 -0
  10. data/lib/aws-sdk-code-generator/docstring.rb +199 -0
  11. data/lib/aws-sdk-code-generator/error_list.rb +77 -0
  12. data/lib/aws-sdk-code-generator/errors.rb +2 -0
  13. data/lib/aws-sdk-code-generator/eventstream_example.rb +220 -0
  14. data/lib/aws-sdk-code-generator/gem_builder.rb +42 -25
  15. data/lib/aws-sdk-code-generator/hash_formatter.rb +5 -2
  16. data/lib/aws-sdk-code-generator/helper.rb +86 -119
  17. data/lib/aws-sdk-code-generator/plugin_list.rb +147 -0
  18. data/lib/aws-sdk-code-generator/resource_action.rb +69 -0
  19. data/lib/aws-sdk-code-generator/resource_action_code.rb +57 -0
  20. data/lib/aws-sdk-code-generator/resource_association.rb +37 -0
  21. data/lib/aws-sdk-code-generator/resource_attribute.rb +76 -0
  22. data/lib/aws-sdk-code-generator/resource_batch_action.rb +56 -0
  23. data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +136 -0
  24. data/lib/aws-sdk-code-generator/resource_batch_action_documentation.rb +108 -0
  25. data/lib/aws-sdk-code-generator/resource_batch_builder.rb +212 -0
  26. data/lib/aws-sdk-code-generator/resource_builder.rb +48 -0
  27. data/lib/aws-sdk-code-generator/resource_client_request.rb +62 -0
  28. data/lib/aws-sdk-code-generator/resource_client_request_documentation.rb +81 -0
  29. data/lib/aws-sdk-code-generator/resource_client_request_params.rb +86 -0
  30. data/lib/aws-sdk-code-generator/resource_data_method.rb +60 -0
  31. data/lib/aws-sdk-code-generator/resource_has_association.rb +117 -0
  32. data/lib/aws-sdk-code-generator/resource_has_many_association.rb +52 -0
  33. data/lib/aws-sdk-code-generator/resource_has_many_association_code.rb +76 -0
  34. data/lib/aws-sdk-code-generator/resource_identifier.rb +44 -0
  35. data/lib/aws-sdk-code-generator/resource_identifiers_method.rb +29 -0
  36. data/lib/aws-sdk-code-generator/resource_load_method.rb +68 -0
  37. data/lib/aws-sdk-code-generator/resource_method.rb +22 -0
  38. data/lib/aws-sdk-code-generator/resource_skip_params.rb +36 -0
  39. data/lib/aws-sdk-code-generator/resource_value_source.rb +68 -0
  40. data/lib/aws-sdk-code-generator/resource_waiter.rb +80 -0
  41. data/lib/aws-sdk-code-generator/service.rb +30 -7
  42. data/lib/aws-sdk-code-generator/shared_example.rb +131 -0
  43. data/lib/aws-sdk-code-generator/syntax_example.rb +60 -0
  44. data/lib/aws-sdk-code-generator/syntax_example_hash.rb +174 -0
  45. data/lib/aws-sdk-code-generator/underscore.rb +10 -5
  46. data/lib/aws-sdk-code-generator/view.rb +33 -0
  47. data/lib/aws-sdk-code-generator/views/apig_endpoint_class.rb +25 -0
  48. data/lib/aws-sdk-code-generator/views/apig_readme.rb +32 -0
  49. data/lib/aws-sdk-code-generator/views/async_client_class.rb +68 -0
  50. data/lib/aws-sdk-code-generator/views/authorizer_class.rb +17 -0
  51. data/lib/aws-sdk-code-generator/views/client_api_module.rb +602 -0
  52. data/lib/aws-sdk-code-generator/views/client_class.rb +93 -0
  53. data/lib/aws-sdk-code-generator/views/docstring.rb +27 -0
  54. data/lib/aws-sdk-code-generator/views/errors_module.rb +32 -0
  55. data/lib/aws-sdk-code-generator/views/event_streams_module.rb +149 -0
  56. data/lib/aws-sdk-code-generator/views/features/env.rb +9 -0
  57. data/lib/aws-sdk-code-generator/views/features/smoke.rb +52 -0
  58. data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +26 -0
  59. data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +6 -2
  60. data/lib/aws-sdk-code-generator/views/gemspec.rb +39 -5
  61. data/lib/aws-sdk-code-generator/views/resource_class.rb +122 -0
  62. data/lib/aws-sdk-code-generator/views/root_resource_class.rb +58 -0
  63. data/lib/aws-sdk-code-generator/views/service_module.rb +38 -14
  64. data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -0
  65. data/lib/aws-sdk-code-generator/views/types_module.rb +329 -0
  66. data/lib/aws-sdk-code-generator/views/version.rb +2 -0
  67. data/lib/aws-sdk-code-generator/views/waiters_module.rb +37 -0
  68. data/lib/aws-sdk-code-generator/views.rb +2 -0
  69. data/lib/aws-sdk-code-generator/waiter.rb +95 -0
  70. data/lib/aws-sdk-code-generator/yard_option_tag.rb +43 -0
  71. data/lib/aws-sdk-code-generator.rb +68 -75
  72. data/templates/apig_endpoint_class.mustache +16 -0
  73. data/templates/apig_readme.mustache +62 -0
  74. data/templates/async_client_class.mustache +125 -0
  75. data/templates/authorizer_class.mustache +37 -0
  76. data/templates/client_api_module.mustache +106 -0
  77. data/templates/client_class.mustache +295 -0
  78. data/templates/code.mustache +4 -0
  79. data/templates/documentation.mustache +4 -0
  80. data/templates/errors_module.mustache +70 -0
  81. data/templates/event_streams_module.mustache +76 -0
  82. data/templates/features/env.mustache +15 -0
  83. data/templates/features/smoke.mustache +22 -0
  84. data/templates/features/smoke_step_definitions.mustache +31 -0
  85. data/templates/features/step_definitions.mustache +13 -0
  86. data/templates/gemspec.mustache +31 -0
  87. data/templates/license.txt +202 -0
  88. data/templates/method.mustache +7 -0
  89. data/templates/resource_class.mustache +304 -0
  90. data/templates/root_resource_class.mustache +51 -0
  91. data/templates/service_module.mustache +58 -0
  92. data/templates/spec/spec_helper.mustache +15 -0
  93. data/templates/types_module.mustache +53 -0
  94. data/templates/version.mustache +1 -0
  95. data/templates/waiters_module.mustache +112 -0
  96. metadata +115 -70
  97. data/lib/aws-sdk-code-generator/dsl/access_control_statement.rb +0 -23
  98. data/lib/aws-sdk-code-generator/dsl/attribute_accessor.rb +0 -43
  99. data/lib/aws-sdk-code-generator/dsl/attribute_reader.rb +0 -11
  100. data/lib/aws-sdk-code-generator/dsl/attribute_writer.rb +0 -11
  101. data/lib/aws-sdk-code-generator/dsl/autoload_statement.rb +0 -15
  102. data/lib/aws-sdk-code-generator/dsl/block_param.rb +0 -11
  103. data/lib/aws-sdk-code-generator/dsl/class.rb +0 -27
  104. data/lib/aws-sdk-code-generator/dsl/code_literal.rb +0 -66
  105. data/lib/aws-sdk-code-generator/dsl/code_object.rb +0 -33
  106. data/lib/aws-sdk-code-generator/dsl/docstring.rb +0 -36
  107. data/lib/aws-sdk-code-generator/dsl/eigenclass.rb +0 -15
  108. data/lib/aws-sdk-code-generator/dsl/extend_statement.rb +0 -12
  109. data/lib/aws-sdk-code-generator/dsl/formatter.rb +0 -25
  110. data/lib/aws-sdk-code-generator/dsl/include_statement.rb +0 -17
  111. data/lib/aws-sdk-code-generator/dsl/main.rb +0 -105
  112. data/lib/aws-sdk-code-generator/dsl/method.rb +0 -108
  113. data/lib/aws-sdk-code-generator/dsl/module.rb +0 -167
  114. data/lib/aws-sdk-code-generator/dsl/option_tag.rb +0 -36
  115. data/lib/aws-sdk-code-generator/dsl/param.rb +0 -43
  116. data/lib/aws-sdk-code-generator/dsl/param_list.rb +0 -38
  117. data/lib/aws-sdk-code-generator/dsl/return_tag.rb +0 -19
  118. data/lib/aws-sdk-code-generator/dsl/tag_default.rb +0 -20
  119. data/lib/aws-sdk-code-generator/dsl/tag_docstring.rb +0 -27
  120. data/lib/aws-sdk-code-generator/dsl/tag_type.rb +0 -18
  121. data/lib/aws-sdk-code-generator/generators/client_api_module.rb +0 -334
  122. data/lib/aws-sdk-code-generator/generators/client_class.rb +0 -389
  123. data/lib/aws-sdk-code-generator/generators/client_operation_documentation.rb +0 -166
  124. data/lib/aws-sdk-code-generator/generators/errors_module.rb +0 -25
  125. data/lib/aws-sdk-code-generator/generators/resource/action.rb +0 -88
  126. data/lib/aws-sdk-code-generator/generators/resource/batch_builder.rb +0 -211
  127. data/lib/aws-sdk-code-generator/generators/resource/builder.rb +0 -50
  128. data/lib/aws-sdk-code-generator/generators/resource/client_getter.rb +0 -15
  129. data/lib/aws-sdk-code-generator/generators/resource/client_request.rb +0 -49
  130. data/lib/aws-sdk-code-generator/generators/resource/client_request_docs.rb +0 -97
  131. data/lib/aws-sdk-code-generator/generators/resource/client_request_params.rb +0 -88
  132. data/lib/aws-sdk-code-generator/generators/resource/collection_class.rb +0 -180
  133. data/lib/aws-sdk-code-generator/generators/resource/data_attribute_getter.rb +0 -24
  134. data/lib/aws-sdk-code-generator/generators/resource/data_loaded_method.rb +0 -18
  135. data/lib/aws-sdk-code-generator/generators/resource/data_method.rb +0 -49
  136. data/lib/aws-sdk-code-generator/generators/resource/exists_method.rb +0 -29
  137. data/lib/aws-sdk-code-generator/generators/resource/extract_identifier_method.rb +0 -32
  138. data/lib/aws-sdk-code-generator/generators/resource/has_association.rb +0 -101
  139. data/lib/aws-sdk-code-generator/generators/resource/has_many_association.rb +0 -108
  140. data/lib/aws-sdk-code-generator/generators/resource/identifier_getter.rb +0 -26
  141. data/lib/aws-sdk-code-generator/generators/resource/identifiers_method.rb +0 -28
  142. data/lib/aws-sdk-code-generator/generators/resource/initialize_method.rb +0 -67
  143. data/lib/aws-sdk-code-generator/generators/resource/load_method.rb +0 -65
  144. data/lib/aws-sdk-code-generator/generators/resource/value_source.rb +0 -68
  145. data/lib/aws-sdk-code-generator/generators/resource/waiter_method.rb +0 -61
  146. data/lib/aws-sdk-code-generator/generators/resource_class.rb +0 -325
  147. data/lib/aws-sdk-code-generator/generators/response_structure_example.rb +0 -83
  148. data/lib/aws-sdk-code-generator/generators/root_resource_class.rb +0 -42
  149. data/lib/aws-sdk-code-generator/generators/service_documentation.rb +0 -64
  150. data/lib/aws-sdk-code-generator/generators/shared_example.rb +0 -132
  151. data/lib/aws-sdk-code-generator/generators/structure_type_class.rb +0 -95
  152. data/lib/aws-sdk-code-generator/generators/syntax_example.rb +0 -169
  153. data/lib/aws-sdk-code-generator/generators/types_module.rb +0 -52
  154. data/lib/aws-sdk-code-generator/generators/waiter_class.rb +0 -62
  155. data/lib/aws-sdk-code-generator/generators/waiters_module.rb +0 -20
@@ -0,0 +1,295 @@
1
+ # frozen_string_literal: true
2
+
3
+ {{#generated_src_warning}}
4
+ {{generated_src_warning}}
5
+ {{/generated_src_warning}}
6
+ {{#plugin_requires}}
7
+ require '{{.}}'
8
+ {{/plugin_requires}}
9
+
10
+ Aws::Plugins::GlobalConfiguration.add_identifier(:{{service_identifier}})
11
+
12
+ module {{module_name}}
13
+ # An API client for {{service_name}}. To construct a client, you need to configure a `:region` and `:credentials`.
14
+ #
15
+ # client = {{module_name}}::Client.new(
16
+ # region: region_name,
17
+ # credentials: credentials,
18
+ # # ...
19
+ # )
20
+ #
21
+ # For details on configuring region and credentials see
22
+ # the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).
23
+ #
24
+ # See {#initialize} for a full list of supported configuration options.
25
+ class Client < Seahorse::Client::Base
26
+
27
+ include Aws::ClientStubs
28
+
29
+ @identifier = :{{service_identifier}}
30
+
31
+ set_api(ClientApi::API)
32
+
33
+ {{#plugin_class_names}}
34
+ add_plugin({{{.}}})
35
+ {{/plugin_class_names}}
36
+
37
+ {{#client_constructor}}
38
+ # @overload initialize(options)
39
+ # @param [Hash] options
40
+ {{>documentation}}
41
+ # @option options [URI::HTTP,String] :http_proxy A proxy to send
42
+ # requests through. Formatted like 'http://proxy.com:123'.
43
+ #
44
+ # @option options [Float] :http_open_timeout (15) The number of
45
+ # seconds to wait when opening a HTTP session before raising a
46
+ # `Timeout::Error`.
47
+ #
48
+ # @option options [Integer] :http_read_timeout (60) The default
49
+ # number of seconds to wait for response data. This value can
50
+ # safely be set per-request on the session.
51
+ #
52
+ # @option options [Float] :http_idle_timeout (5) The number of
53
+ # seconds a connection is allowed to sit idle before it is
54
+ # considered stale. Stale connections are closed and removed
55
+ # from the pool before making a request.
56
+ #
57
+ # @option options [Float] :http_continue_timeout (1) The number of
58
+ # seconds to wait for a 100-continue response before sending the
59
+ # request body. This option has no effect unless the request has
60
+ # "Expect" header set to "100-continue". Defaults to `nil` which
61
+ # disables this behaviour. This value can safely be set per
62
+ # request on the session.
63
+ #
64
+ # @option options [Boolean] :http_wire_trace (false) When `true`,
65
+ # HTTP debug output will be sent to the `:logger`.
66
+ #
67
+ # @option options [Boolean] :ssl_verify_peer (true) When `true`,
68
+ # SSL peer certificates are verified when establishing a
69
+ # connection.
70
+ #
71
+ # @option options [String] :ssl_ca_bundle Full path to the SSL
72
+ # certificate authority bundle file that should be used when
73
+ # verifying peer certificates. If you do not pass
74
+ # `:ssl_ca_bundle` or `:ssl_ca_directory` the the system default
75
+ # will be used if available.
76
+ #
77
+ # @option options [String] :ssl_ca_directory Full path of the
78
+ # directory that contains the unbundled SSL certificate
79
+ # authority files for verifying peer certificates. If you do
80
+ # not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the
81
+ # system default will be used if available.
82
+ #
83
+ {{/client_constructor}}
84
+ def initialize(*args)
85
+ super
86
+ end
87
+
88
+ # @!group API Operations
89
+ {{#operations}}
90
+
91
+ {{#documentation}}
92
+ {{>documentation}}
93
+ {{/documentation}}
94
+ # @overload {{name}}(params = {})
95
+ # @param [Hash] params ({})
96
+ def {{name}}(params = {}, options = {}{{{block_option}}})
97
+ {{#eventstream_output}}
98
+ params = params.dup
99
+ event_stream_handler = case handler = params.delete(:event_stream_handler)
100
+ when EventStreams::{{output_eventstream_member}} then handler
101
+ when Proc then EventStreams::{{output_eventstream_member}}.new.tap(&handler)
102
+ when nil then EventStreams::{{output_eventstream_member}}.new
103
+ else
104
+ msg = "expected :event_stream_handler to be a block or "\
105
+ "instance of {{module_name}}::EventStreams::{{output_eventstream_member}}"\
106
+ ", got `#{handler.inspect}` instead"
107
+ raise ArgumentError, msg
108
+ end
109
+
110
+ yield(event_stream_handler) if block_given?
111
+
112
+ {{/eventstream_output}}
113
+ req = build_request(:{{name}}, params)
114
+ {{#eventstream_output}}
115
+
116
+ req.context[:event_stream_handler] = event_stream_handler
117
+ req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)
118
+
119
+ {{/eventstream_output}}
120
+ req.send_request(options{{{block_option}}})
121
+ end
122
+ {{/operations}}
123
+
124
+ # @!endgroup
125
+
126
+ # @param params ({})
127
+ # @api private
128
+ def build_request(operation_name, params = {})
129
+ handlers = @handlers.for(operation_name)
130
+ {{#authorizer?}}
131
+ authorizer = nil
132
+ if config.api.operation(operation_name).authorizer
133
+ authorizer_name = config.api.operation(operation_name).authorizer
134
+ config.api.authorizers.each do |_, auth|
135
+ authorizer = auth if auth.name == authorizer_name
136
+ end
137
+ end
138
+ {{/authorizer?}}
139
+ context = Seahorse::Client::RequestContext.new(
140
+ operation_name: operation_name,
141
+ operation: config.api.operation(operation_name),{{#authorizer?}}
142
+ authorizer: authorizer,{{/authorizer?}}
143
+ client: self,
144
+ params: params,
145
+ config: config)
146
+ context[:gem_name] = '{{gem_name}}'
147
+ context[:gem_version] = '{{gem_version}}'
148
+ Seahorse::Client::Request.new(handlers, context)
149
+ end
150
+ {{#waiters?}}
151
+
152
+ # Polls an API operation until a resource enters a desired state.
153
+ #
154
+ # ## Basic Usage
155
+ #
156
+ # A waiter will call an API operation until:
157
+ #
158
+ # * It is successful
159
+ # * It enters a terminal state
160
+ # * It makes the maximum number of attempts
161
+ #
162
+ # In between attempts, the waiter will sleep.
163
+ #
164
+ # # polls in a loop, sleeping between attempts
165
+ # client.wait_until(waiter_name, params)
166
+ #
167
+ # ## Configuration
168
+ #
169
+ # You can configure the maximum number of polling attempts, and the
170
+ # delay (in seconds) between each polling attempt. You can pass
171
+ # configuration as the final arguments hash.
172
+ #
173
+ # # poll for ~25 seconds
174
+ # client.wait_until(waiter_name, params, {
175
+ # max_attempts: 5,
176
+ # delay: 5,
177
+ # })
178
+ #
179
+ # ## Callbacks
180
+ #
181
+ # You can be notified before each polling attempt and before each
182
+ # delay. If you throw `:success` or `:failure` from these callbacks,
183
+ # it will terminate the waiter.
184
+ #
185
+ # started_at = Time.now
186
+ # client.wait_until(waiter_name, params, {
187
+ #
188
+ # # disable max attempts
189
+ # max_attempts: nil,
190
+ #
191
+ # # poll for 1 hour, instead of a number of attempts
192
+ # before_wait: -> (attempts, response) do
193
+ # throw :failure if Time.now - started_at > 3600
194
+ # end
195
+ # })
196
+ #
197
+ # ## Handling Errors
198
+ #
199
+ # When a waiter is unsuccessful, it will raise an error.
200
+ # All of the failure errors extend from
201
+ # {Aws::Waiters::Errors::WaiterFailed}.
202
+ #
203
+ # begin
204
+ # client.wait_until(...)
205
+ # rescue Aws::Waiters::Errors::WaiterFailed
206
+ # # resource did not enter the desired state in time
207
+ # end
208
+ #
209
+ # ## Valid Waiters
210
+ #
211
+ # The following table lists the valid waiter names, the operations they call,
212
+ # and the default `:delay` and `:max_attempts` values.
213
+ #
214
+ {{#waiters_markdown_table}}
215
+ {{#lines}}
216
+ # {{{.}}}{{/lines}}
217
+ {{/waiters_markdown_table}}
218
+ #
219
+ # @raise [Errors::FailureStateError] Raised when the waiter terminates
220
+ # because the waiter has entered a state that it will not transition
221
+ # out of, preventing success.
222
+ #
223
+ # @raise [Errors::TooManyAttemptsError] Raised when the configured
224
+ # maximum number of attempts have been made, and the waiter is not
225
+ # yet successful.
226
+ #
227
+ # @raise [Errors::UnexpectedError] Raised when an error is encounted
228
+ # while polling for a resource that is not expected.
229
+ #
230
+ # @raise [Errors::NoSuchWaiterError] Raised when you request to wait
231
+ # for an unknown state.
232
+ #
233
+ # @return [Boolean] Returns `true` if the waiter was successful.
234
+ # @param [Symbol] waiter_name
235
+ # @param [Hash] params ({})
236
+ # @param [Hash] options ({})
237
+ # @option options [Integer] :max_attempts
238
+ # @option options [Integer] :delay
239
+ # @option options [Proc] :before_attempt
240
+ # @option options [Proc] :before_wait
241
+ def wait_until(waiter_name, params = {}, options = {})
242
+ w = waiter(waiter_name, options)
243
+ yield(w.waiter) if block_given? # deprecated
244
+ w.wait(params)
245
+ end
246
+
247
+ # @api private
248
+ # @deprecated
249
+ def waiter_names
250
+ waiters.keys
251
+ end
252
+
253
+ private
254
+
255
+ # @param [Symbol] waiter_name
256
+ # @param [Hash] options ({})
257
+ def waiter(waiter_name, options = {})
258
+ waiter_class = waiters[waiter_name]
259
+ if waiter_class
260
+ waiter_class.new(options.merge(client: self))
261
+ else
262
+ raise Aws::Waiters::Errors::NoSuchWaiterError.new(waiter_name, waiters.keys)
263
+ end
264
+ end
265
+
266
+ def waiters
267
+ {
268
+ {{#waiters}}
269
+ {{name}}: Waiters::{{class_name}}{{^last}},{{/last}}
270
+ {{/waiters}}
271
+ }
272
+ end
273
+ {{/waiters?}}
274
+ {{^waiters?}}
275
+
276
+ # @api private
277
+ # @deprecated
278
+ def waiter_names
279
+ []
280
+ end
281
+ {{/waiters?}}
282
+
283
+ class << self
284
+
285
+ # @api private
286
+ attr_reader :identifier
287
+
288
+ # @api private
289
+ def errors_module
290
+ Errors
291
+ end
292
+
293
+ end
294
+ end
295
+ end
@@ -0,0 +1,4 @@
1
+ {{#code}}
2
+ {{#lines}}
3
+ {{{.}}}{{/lines}}
4
+ {{/code}}
@@ -0,0 +1,4 @@
1
+ {{#documentation}}
2
+ {{#lines}}
3
+ {{{.}}}{{/lines}}
4
+ {{/documentation}}
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ {{#generated_src_warning}}
4
+ {{generated_src_warning}}
5
+ {{/generated_src_warning}}
6
+ module {{module_name}}
7
+
8
+ # When {{service_name}} returns an error response, the Ruby SDK constructs and raises an error.
9
+ # These errors all extend {{module_name}}::Errors::ServiceError < {Aws::Errors::ServiceError}
10
+ #
11
+ # You can rescue all {{service_name}} errors using ServiceError:
12
+ #
13
+ # begin
14
+ # # do stuff
15
+ # rescue {{module_name}}::Errors::ServiceError
16
+ # # rescues all {{service_name}} API errors
17
+ # end
18
+ #
19
+ #
20
+ # ## Request Context
21
+ # ServiceError objects have a {Aws::Errors::ServiceError#context #context} method that returns
22
+ # information about the request that generated the error.
23
+ # See {Seahorse::Client::RequestContext} for more information.
24
+ #
25
+ # ## Error Classes
26
+ {{#errors}}
27
+ {{=<% %>=}}
28
+ # * {<% name %>}
29
+ <%={{ }}=%>
30
+ {{/errors}}
31
+ #
32
+ # Additionally, error classes are dynamically generated for service errors based on the error code
33
+ # if they are not defined above.
34
+ module Errors
35
+
36
+ extend Aws::Errors::DynamicErrors
37
+
38
+ {{#errors}}
39
+ class {{name}} < ServiceError
40
+
41
+ # @param [Seahorse::Client::RequestContext] context
42
+ # @param [String] message
43
+ # @param [{{data_type}}] data
44
+ def initialize(context, message, data = Aws::EmptyStructure.new)
45
+ super(context, message, data)
46
+ end
47
+ {{#members}}
48
+
49
+ # @return [{{type}}]
50
+ def {{name}}
51
+ {{#shared}}@{{name}} || {{/shared}}@data[:{{name}}]
52
+ end
53
+ {{/members}}
54
+ {{#retryable}}
55
+
56
+ def retryable?
57
+ true
58
+ end
59
+ {{/retryable}}
60
+ {{#throttling}}
61
+
62
+ def throttling?
63
+ true
64
+ end
65
+ {{/throttling}}
66
+ end
67
+
68
+ {{/errors}}
69
+ end
70
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ {{#generated_src_warning}}
4
+ {{generated_src_warning}}
5
+ {{/generated_src_warning}}
6
+ module {{module_name}}
7
+ module EventStreams
8
+ {{#input_eventstreams}}
9
+ class {{class_name}}
10
+
11
+ def initialize
12
+ @event_emitter = Aws::EventEmitter.new
13
+ end
14
+
15
+ {{#event_entries}}
16
+ {{param_hash}}
17
+ def signal_{{name}}_event(params = {})
18
+ @event_emitter.emit(:{{name}}, params)
19
+ end
20
+
21
+ {{/event_entries}}
22
+ def signal_end_stream
23
+ @event_emitter.emit(:end_stream, {})
24
+ end
25
+
26
+ # @api private
27
+ # @return Aws::EventEmitter
28
+ attr_reader :event_emitter
29
+
30
+ end
31
+
32
+ {{/input_eventstreams}}
33
+ {{#output_eventstreams}}
34
+ class {{class_name}}
35
+
36
+ def initialize
37
+ @event_emitter = Aws::EventEmitter.new
38
+ end
39
+
40
+ {{#types}}
41
+ def on_{{.}}_event(&block)
42
+ @event_emitter.on(:{{.}}, block) if block_given?
43
+ end
44
+
45
+ {{/types}}
46
+ def on_error_event(&block)
47
+ @event_emitter.on(:error, block) if block_given?
48
+ end
49
+
50
+ def on_initial_response_event(&block)
51
+ @event_emitter.on(:initial_response, block) if block_given?
52
+ end
53
+
54
+ def on_unknown_event(&block)
55
+ @event_emitter.on(:unknown_event, block) if block_given?
56
+ end
57
+
58
+ def on_event(&block)
59
+ {{#types}}
60
+ on_{{.}}_event(&block)
61
+ {{/types}}
62
+ on_error_event(&block)
63
+ on_initial_response_event(&block)
64
+ on_unknown_event(&block)
65
+ end
66
+
67
+ # @api private
68
+ # @return Aws::EventEmitter
69
+ attr_reader :event_emitter
70
+
71
+ end
72
+ {{/output_eventstreams}}
73
+
74
+ end
75
+ end
76
+
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ {{#generated_src_warning}}
4
+ {{generated_src_warning}}
5
+ {{/generated_src_warning}}
6
+ $:.unshift(File.expand_path('../../lib', __FILE__))
7
+ $:.unshift(File.expand_path('../../../aws-sdk-core/features', __FILE__))
8
+ {{#gem_dependencies}}
9
+ $:.unshift(File.expand_path('../../../{{dependency}}/lib', __FILE__))
10
+ {{/gem_dependencies}}
11
+
12
+ require 'features_helper'
13
+ require '{{gem_name}}'
14
+
15
+ {{module_name}}::Client.add_plugin(ApiCallTracker)
@@ -0,0 +1,22 @@
1
+ {{#generated_src_warning}}
2
+ {{generated_src_warning}}
3
+ {{/generated_src_warning}}
4
+ Feature: Smoke tests for {{service}}
5
+
6
+ Background:
7
+ {{#client_endpoint}}
8
+ Given I create a client with endpoint '{{client_endpoint}}'
9
+ {{/client_endpoint}}
10
+ {{^client_endpoint}}
11
+ Given I create a client in region '{{client_region}}'
12
+ {{/client_endpoint}}
13
+ {{#smoke_tests}}
14
+
15
+ {{smoke_test_tags}}
16
+ Scenario: {{scenario_string}}
17
+ When I call the operation '{{operation}}' with params:
18
+ """
19
+ {{&param_hash}}
20
+ """
21
+ Then {{error_expectation}}
22
+ {{/smoke_tests}}
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ {{#generated_src_warning}}
4
+ {{generated_src_warning}}
5
+ {{/generated_src_warning}}
6
+ # Shared Smoke Test Definitions
7
+ Given(/I create a client in region '(.*?)'/) do |region|
8
+ @regional_client = {{module_name}}::Client.new(region: region)
9
+ end
10
+
11
+ Given(/I create a client with endpoint '(.*?)'/) do |endpoint|
12
+ @regional_client = {{module_name}}::Client.new(endpoint: endpoint)
13
+ end
14
+
15
+ When(/I call the operation '(.*?)' with params:/) do |operation, params|
16
+ opts = JSON.parse(params, symbolize_names: true)
17
+ begin
18
+ @regional_client.send(operation.to_sym, opts)
19
+ @operation_raised_error = false
20
+ rescue StandardError
21
+ @operation_raised_error = true
22
+ end
23
+ end
24
+
25
+ Then(/I expect an error was raised/) do
26
+ expect(@operation_raised_error).to be_truthy
27
+ end
28
+
29
+ Then(/I expect an error was not raised/) do
30
+ expect(@operation_raised_error).not_to be_truthy
31
+ end
@@ -0,0 +1,13 @@
1
+ Before("@{{var_name}}") do
2
+ {{#client_endpoint}}
3
+ @service = {{module_name}}::Resource.new(endpoint: '{{client_endpoint}}')
4
+ {{/client_endpoint}}
5
+ {{^client_endpoint}}
6
+ @service = {{module_name}}::Resource.new
7
+ {{/client_endpoint}}
8
+ @client = @service.client
9
+ end
10
+
11
+ After("@{{var_name}}") do
12
+ # shared cleanup logic
13
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ {{#generated_src_warning}}
4
+ {{generated_src_warning}}
5
+ {{/generated_src_warning}}
6
+ Gem::Specification.new do |spec|
7
+
8
+ spec.name = '{{gem_name}}'
9
+ spec.version = File.read(File.expand_path('../VERSION', __FILE__)).strip
10
+ spec.summary = '{{summary}}'
11
+ spec.description = '{{description}}'
12
+ spec.author = '{{author}}'
13
+ spec.homepage = '{{homepage}}'
14
+ spec.license = 'Apache-2.0'
15
+ spec.email = ['{{email}}']
16
+ spec.require_paths = ['lib']
17
+ spec.files = Dir['LICENSE.txt', 'CHANGELOG.md', 'VERSION', 'lib/**/*.rb']
18
+
19
+ {{#metadata}}
20
+ spec.metadata = {
21
+ 'source_code_uri' => '{{code_uri}}',
22
+ 'changelog_uri' => '{{code_uri}}/CHANGELOG.md'
23
+ }
24
+
25
+ {{/metadata}}
26
+ {{#dependencies}}
27
+ spec.add_dependency('{{gem}}', '{{&version}}')
28
+ {{/dependencies}}
29
+
30
+ spec.required_ruby_version = '>= 2.3'
31
+ end