aws-sdk-code-generator 0.2.0.pre → 0.2.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/templates/apig_endpoint_class.mustache +16 -0
- data/templates/apig_readme.mustache +62 -0
- data/templates/async_client_class.mustache +127 -0
- data/templates/authorizer_class.mustache +37 -0
- data/templates/client_api_module.mustache +106 -0
- data/templates/client_class.mustache +295 -0
- data/templates/code.mustache +4 -0
- data/templates/documentation.mustache +4 -0
- data/templates/errors_module.mustache +70 -0
- data/templates/event_streams_module.mustache +76 -0
- data/templates/features/env.mustache +15 -0
- data/templates/features/smoke.mustache +17 -0
- data/templates/features/smoke_step_definitions.mustache +27 -0
- data/templates/features/step_definitions.mustache +8 -0
- data/templates/gemspec.mustache +30 -0
- data/templates/method.mustache +7 -0
- data/templates/resource_class.mustache +304 -0
- data/templates/root_resource_class.mustache +51 -0
- data/templates/service_module.mustache +48 -0
- data/templates/spec/spec_helper.mustache +15 -0
- data/templates/types_module.mustache +46 -0
- data/templates/version.mustache +1 -0
- data/templates/waiters_module.mustache +112 -0
- metadata +53 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a65077a940c697e439cae503d4683f5aec9dd5aee7a154b63f380543786d524c
|
4
|
+
data.tar.gz: 197c2c803eb600eb4d68f3b36a4ed0acec2effa7f3de11ec2dc610b610fd7765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0403d7112475a44303431fbb706b7aa7fbf2d5422cfb8ba3d9f240e13e85ea638f358e19d9678d16ea8b6f87745728a55fdf20193c86e504c3828c0f6476fb1f
|
7
|
+
data.tar.gz: e0623c91975e000b312db4d0106280b9655a0c1985e8684249dfd41171aeba38fe218ae88574e012b1d8a4879bfe03df3aa0515567fb05fe116c7567bb04e604
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module {{module_name}}
|
4
|
+
module Plugins
|
5
|
+
|
6
|
+
class APIGEndpoint < Seahorse::Client::Plugin
|
7
|
+
|
8
|
+
def after_initialize(client)
|
9
|
+
if client.config.endpoint.nil?
|
10
|
+
client.config.endpoint = '{{default_endpoint}}'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# {{service_name}}
|
2
|
+
|
3
|
+
This is the Version {{gem_major_version}} of the {{gem_name}} gem.
|
4
|
+
|
5
|
+
## WARNING
|
6
|
+
|
7
|
+
Please read through this `README.md` and `{{gem_name}}.gemspec` then tailor it with your gem needs before serving it for any official usage or gem publishing. If you have any questions, issue or feature requests for this generated gem, feel free to open an issue or PR againt [`AWS SDK for Ruby`](https://github.com/aws/aws-sdk-ruby)
|
8
|
+
|
9
|
+
## API Client
|
10
|
+
|
11
|
+
Initialize a service client and list all operations available.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require '{{gem_name}}'
|
15
|
+
|
16
|
+
client = {{module_name}}::Client.new
|
17
|
+
|
18
|
+
puts client.operation_names
|
19
|
+
```
|
20
|
+
|
21
|
+
For each operation usage example, see `lib/client.rb` documentation block per operation
|
22
|
+
|
23
|
+
## Authorizer
|
24
|
+
|
25
|
+
For operations used custom authorizer, you can provide your own authorizer token logic at `lib/plugins/authorizer.rb` under method `generate_token`. For more information, please see [here](http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html).
|
26
|
+
|
27
|
+
## AWS Credentials
|
28
|
+
|
29
|
+
For those API requets that are authenticated with AWS Credentials (e.g. IAM roles), you would need to configure `:credentials` and `:region` that helps sigining request with [AWS Signature V4](http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html). You can also provide those information via your environment:
|
30
|
+
|
31
|
+
The SDK searches the following locations for credentials:
|
32
|
+
|
33
|
+
* `ENV['AWS_ACCESS_KEY_ID']` and `ENV['AWS_SECRET_ACCESS_KEY']`
|
34
|
+
* Unless `ENV['AWS_SDK_CONFIG_OPT_OUT']` is set, the shared configuration files (`~/.aws/credentials` and `~/.aws/config`) will be checked for a `role_arn` and `source_profile`, which if present will be used to attempt to assume a role.
|
35
|
+
* The shared credentials ini file at `~/.aws/credentials` ([more information](http://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs))
|
36
|
+
* Unless `ENV['AWS_SDK_CONFIG_OPT_OUT']` is set, the shared configuration ini file at `~/.aws/config` will also be parsed for credentials.
|
37
|
+
* From an instance profile when running on EC2, or from the ECS credential provider when running in an ECS container with that feature enabled.
|
38
|
+
|
39
|
+
The SDK searches the following locations for a region:
|
40
|
+
|
41
|
+
* `ENV['AWS_REGION']`
|
42
|
+
* Unless `ENV['AWS_SDK_CONFIG_OPT_OUT']` is set, the shared configuration files (`~/.aws/credentials` and `~/.aws/config`) will also be checked for a region selection.
|
43
|
+
|
44
|
+
Valid region and credentials options are:
|
45
|
+
|
46
|
+
* `:region` - A string like `us-west-2`.
|
47
|
+
* `:credentials` - An instance of one of the following classes:
|
48
|
+
* [`Aws::Credentials`](http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Credentials.html)
|
49
|
+
* [`Aws::SharedCredentials`](http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SharedCredentials.html)
|
50
|
+
* [`Aws::InstanceProfileCredentials`](http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/InstanceProfileCredentials.html)
|
51
|
+
* [`Aws::AssumeRoleCredentials`](http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/AssumeRoleCredentials.html)
|
52
|
+
|
53
|
+
## API Key
|
54
|
+
|
55
|
+
Simply provide an `:api_key` value when calling an API along with other params, this value will be picked up in the `x-api-key` header value.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
DEFAULT: This library is distributed under the
|
60
|
+
[Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
61
|
+
|
62
|
+
Feel free to change your license specification here and at `{{gem_name}}.gemspec`
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
if RUBY_VERSION >= '2.1'
|
7
|
+
begin
|
8
|
+
require 'http/2'
|
9
|
+
rescue LoadError; end
|
10
|
+
end
|
11
|
+
{{#plugin_requires}}
|
12
|
+
require '{{.}}'
|
13
|
+
{{/plugin_requires}}
|
14
|
+
|
15
|
+
Aws::Plugins::GlobalConfiguration.add_identifier(:{{service_identifier}})
|
16
|
+
|
17
|
+
module {{module_name}}
|
18
|
+
class AsyncClient < Seahorse::Client::AsyncBase
|
19
|
+
|
20
|
+
include Aws::AsyncClientStubs
|
21
|
+
|
22
|
+
@identifier = :{{service_identifier}}
|
23
|
+
|
24
|
+
set_api(ClientApi::API)
|
25
|
+
|
26
|
+
{{#plugin_class_names}}
|
27
|
+
add_plugin({{{.}}})
|
28
|
+
{{/plugin_class_names}}
|
29
|
+
|
30
|
+
{{#client_constructor}}
|
31
|
+
{{>documentation}}
|
32
|
+
{{/client_constructor}}
|
33
|
+
def initialize(*args)
|
34
|
+
unless Kernel.const_defined?("HTTP2")
|
35
|
+
raise "Must include http/2 gem to use AsyncClient instances."
|
36
|
+
end
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
# @!group API Operations
|
41
|
+
{{#operations}}
|
42
|
+
|
43
|
+
{{#documentation}}
|
44
|
+
{{>documentation}}
|
45
|
+
{{/documentation}}
|
46
|
+
# @overload {{name}}(params = {})
|
47
|
+
# @param [Hash] params ({})
|
48
|
+
def {{name}}(params = {}, options = {}{{{block_option}}})
|
49
|
+
params = params.dup
|
50
|
+
{{#eventstream_input}}
|
51
|
+
input_event_stream_handler = _event_stream_handler(
|
52
|
+
:input,
|
53
|
+
params.delete(:input_event_stream_handler),
|
54
|
+
EventStreams::{{input_eventstream_member}}
|
55
|
+
)
|
56
|
+
{{/eventstream_input}}
|
57
|
+
{{#eventstream_output}}
|
58
|
+
output_event_stream_handler = _event_stream_handler(
|
59
|
+
:output,
|
60
|
+
params.delete(:output_event_stream_handler) || params.delete(:event_stream_handler),
|
61
|
+
EventStreams::{{output_eventstream_member}}
|
62
|
+
)
|
63
|
+
{{/eventstream_output}}
|
64
|
+
|
65
|
+
yield({{#eventstream_output}}output_event_stream_handler{{/eventstream_output}}) if block_given?
|
66
|
+
|
67
|
+
req = build_request(:{{name}}, params)
|
68
|
+
|
69
|
+
{{#eventstream_input}}
|
70
|
+
req.context[:input_event_stream_handler] = input_event_stream_handler
|
71
|
+
req.handlers.add(Aws::Binary::EncodeHandler, priority: 95)
|
72
|
+
{{/eventstream_input}}
|
73
|
+
{{#eventstream_output}}
|
74
|
+
req.context[:output_event_stream_handler] = output_event_stream_handler
|
75
|
+
req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)
|
76
|
+
{{/eventstream_output}}
|
77
|
+
|
78
|
+
req.send_request(options{{{block_option}}})
|
79
|
+
end
|
80
|
+
{{/operations}}
|
81
|
+
|
82
|
+
# @!endgroup
|
83
|
+
|
84
|
+
# @param params ({})
|
85
|
+
# @api private
|
86
|
+
def build_request(operation_name, params = {})
|
87
|
+
handlers = @handlers.for(operation_name)
|
88
|
+
context = Seahorse::Client::RequestContext.new(
|
89
|
+
operation_name: operation_name,
|
90
|
+
operation: config.api.operation(operation_name),
|
91
|
+
client: self,
|
92
|
+
params: params,
|
93
|
+
http_response: Seahorse::Client::Http::AsyncResponse.new,
|
94
|
+
config: config)
|
95
|
+
context[:gem_name] = '{{gem_name}}'
|
96
|
+
context[:gem_version] = '{{gem_version}}'
|
97
|
+
Seahorse::Client::Request.new(handlers, context)
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def _event_stream_handler(type, handler, event_stream_class)
|
103
|
+
case handler
|
104
|
+
when event_stream_class then handler
|
105
|
+
when Proc then event_stream_class.new.tap(&handler)
|
106
|
+
when nil then event_stream_class.new
|
107
|
+
else
|
108
|
+
msg = "expected #{type}_event_stream_handler to be a block or "\
|
109
|
+
"instance of {{module_name}}::#{event_stream_class}"\
|
110
|
+
", got `#{handler.inspect}` instead"
|
111
|
+
raise ArgumentError, msg
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class << self
|
116
|
+
|
117
|
+
# @api private
|
118
|
+
attr_reader :identifier
|
119
|
+
|
120
|
+
# @api private
|
121
|
+
def errors_module
|
122
|
+
Errors
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module {{module_name}}
|
4
|
+
module Plugins
|
5
|
+
|
6
|
+
# APIG Custom Authorizer, generated token will be used by API Gateway
|
7
|
+
# to interact with AWS Lambda for authentication
|
8
|
+
#
|
9
|
+
# More information see: http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html
|
10
|
+
class Authorizer < Seahorse::Client::Plugin
|
11
|
+
|
12
|
+
def add_handlers(handlers, config)
|
13
|
+
handlers.add(CustomAuthHandler, step: :initialize)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @api private
|
17
|
+
class CustomAuthHandler < Seahorse::Client::Handler
|
18
|
+
|
19
|
+
def call(context)
|
20
|
+
if context.operation['authtype'] == 'custom'
|
21
|
+
context.config.authorizer_token = generate_token(context)
|
22
|
+
end
|
23
|
+
@handler.call(context)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# TODO
|
29
|
+
# Provide your own token generation logic here
|
30
|
+
def generate_token(context)
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
module {{module_name}}
|
7
|
+
# @api private
|
8
|
+
module ClientApi
|
9
|
+
|
10
|
+
include Seahorse::Model
|
11
|
+
|
12
|
+
{{#shapes}}
|
13
|
+
{{name}} = {{class_name}}.new({{{constructor_args}}})
|
14
|
+
{{/shapes}}
|
15
|
+
|
16
|
+
{{#shape_definitions}}
|
17
|
+
{{#lines}}
|
18
|
+
{{{.}}}{{/lines}}
|
19
|
+
|
20
|
+
{{/shape_definitions}}
|
21
|
+
|
22
|
+
# @api private
|
23
|
+
API = Seahorse::Model::Api.new.tap do |api|
|
24
|
+
|
25
|
+
api.version = "{{api_version}}"
|
26
|
+
|
27
|
+
api.metadata = {
|
28
|
+
{{#metadata}}
|
29
|
+
{{{key}}} => {{{value}}},
|
30
|
+
{{/metadata}}
|
31
|
+
}
|
32
|
+
{{#endpoint_operation}}
|
33
|
+
api.endpoint_operation = :{{endpoint_operation}}
|
34
|
+
{{/endpoint_operation}}
|
35
|
+
{{#require_endpoint_discovery}}
|
36
|
+
api.require_endpoint_discovery = true
|
37
|
+
{{/require_endpoint_discovery}}
|
38
|
+
{{#operations}}
|
39
|
+
|
40
|
+
api.add_operation(:{{method_name}}, Seahorse::Model::Operation.new.tap do |o|
|
41
|
+
o.name = "{{name}}"
|
42
|
+
o.http_method = "{{http_method}}"
|
43
|
+
o.http_request_uri = "{{{http_request_uri}}}"
|
44
|
+
{{#http_checksum_required}}
|
45
|
+
o.http_checksum_required = true
|
46
|
+
{{/http_checksum_required}}
|
47
|
+
{{#deprecated}}
|
48
|
+
o.deprecated = true
|
49
|
+
{{/deprecated}}
|
50
|
+
{{#endpoint_operation}}
|
51
|
+
o.endpoint_operation = true
|
52
|
+
{{/endpoint_operation}}
|
53
|
+
{{#endpoint_discovery_available}}
|
54
|
+
o.endpoint_discovery = {
|
55
|
+
{{#endpoint_discovery}}
|
56
|
+
{{{key}}} => {{{value}}},
|
57
|
+
{{/endpoint_discovery}}
|
58
|
+
}
|
59
|
+
{{/endpoint_discovery_available}}
|
60
|
+
{{#authorizer}}
|
61
|
+
o.authorizer = "{{authorizer}}"
|
62
|
+
{{/authorizer}}
|
63
|
+
{{#authtype}}
|
64
|
+
o['authtype'] = "{{.}}"
|
65
|
+
{{/authtype}}
|
66
|
+
{{#endpoint_trait}}
|
67
|
+
o.endpoint_pattern = {
|
68
|
+
{{#endpoint_pattern}}
|
69
|
+
{{{key}}} => {{{value}}},
|
70
|
+
{{/endpoint_pattern}}
|
71
|
+
}
|
72
|
+
{{/endpoint_trait}}
|
73
|
+
{{#require_apikey}}
|
74
|
+
o.require_apikey = {{require_apikey}}
|
75
|
+
{{/require_apikey}}
|
76
|
+
{{#shape_references}}
|
77
|
+
{{#lines}}
|
78
|
+
{{{.}}}{{/lines}}
|
79
|
+
{{/shape_references}}
|
80
|
+
{{#error_shape_names}}
|
81
|
+
o.errors << Shapes::ShapeRef.new(shape: {{.}})
|
82
|
+
{{/error_shape_names}}
|
83
|
+
{{#pager}}
|
84
|
+
{{#lines}}
|
85
|
+
{{{.}}}{{/lines}}
|
86
|
+
{{/pager}}
|
87
|
+
{{#async}}
|
88
|
+
o.async = true
|
89
|
+
{{/async}}
|
90
|
+
end)
|
91
|
+
{{/operations}}
|
92
|
+
{{#apig_authorizer}}
|
93
|
+
|
94
|
+
api.add_authorizer(:{{authorizer_name}}, Seahorse::Model::Authorizer.new.tap do |a|
|
95
|
+
a.name = "{{name}}"{{#type}}
|
96
|
+
a.type = "{{type}}"{{/type}}{{#location}}
|
97
|
+
a.placement = {
|
98
|
+
:location => "{{location}}",
|
99
|
+
:name => "{{location_name}}"
|
100
|
+
}{{/location}}
|
101
|
+
end)
|
102
|
+
{{/apig_authorizer}}
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -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
|