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.
- checksums.yaml +5 -5
- data/lib/aws-sdk-code-generator/api.rb +150 -0
- data/lib/aws-sdk-code-generator/apply_docs.rb +15 -2
- data/lib/aws-sdk-code-generator/client_constructor.rb +39 -0
- data/lib/aws-sdk-code-generator/client_operation_documentation.rb +282 -0
- data/lib/aws-sdk-code-generator/client_operation_list.rb +148 -0
- data/lib/aws-sdk-code-generator/client_response_structure_example.rb +115 -0
- data/lib/aws-sdk-code-generator/code_builder.rb +146 -133
- data/lib/aws-sdk-code-generator/crosslink.rb +42 -0
- data/lib/aws-sdk-code-generator/docstring.rb +199 -0
- data/lib/aws-sdk-code-generator/error_list.rb +77 -0
- data/lib/aws-sdk-code-generator/errors.rb +2 -0
- data/lib/aws-sdk-code-generator/eventstream_example.rb +220 -0
- data/lib/aws-sdk-code-generator/gem_builder.rb +42 -25
- data/lib/aws-sdk-code-generator/hash_formatter.rb +5 -2
- data/lib/aws-sdk-code-generator/helper.rb +86 -119
- data/lib/aws-sdk-code-generator/plugin_list.rb +147 -0
- data/lib/aws-sdk-code-generator/resource_action.rb +69 -0
- data/lib/aws-sdk-code-generator/resource_action_code.rb +57 -0
- data/lib/aws-sdk-code-generator/resource_association.rb +37 -0
- data/lib/aws-sdk-code-generator/resource_attribute.rb +76 -0
- data/lib/aws-sdk-code-generator/resource_batch_action.rb +56 -0
- data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +136 -0
- data/lib/aws-sdk-code-generator/resource_batch_action_documentation.rb +108 -0
- data/lib/aws-sdk-code-generator/resource_batch_builder.rb +212 -0
- data/lib/aws-sdk-code-generator/resource_builder.rb +48 -0
- data/lib/aws-sdk-code-generator/resource_client_request.rb +62 -0
- data/lib/aws-sdk-code-generator/resource_client_request_documentation.rb +81 -0
- data/lib/aws-sdk-code-generator/resource_client_request_params.rb +86 -0
- data/lib/aws-sdk-code-generator/resource_data_method.rb +60 -0
- data/lib/aws-sdk-code-generator/resource_has_association.rb +117 -0
- data/lib/aws-sdk-code-generator/resource_has_many_association.rb +52 -0
- data/lib/aws-sdk-code-generator/resource_has_many_association_code.rb +76 -0
- data/lib/aws-sdk-code-generator/resource_identifier.rb +44 -0
- data/lib/aws-sdk-code-generator/resource_identifiers_method.rb +29 -0
- data/lib/aws-sdk-code-generator/resource_load_method.rb +68 -0
- data/lib/aws-sdk-code-generator/resource_method.rb +22 -0
- data/lib/aws-sdk-code-generator/resource_skip_params.rb +36 -0
- data/lib/aws-sdk-code-generator/resource_value_source.rb +68 -0
- data/lib/aws-sdk-code-generator/resource_waiter.rb +80 -0
- data/lib/aws-sdk-code-generator/service.rb +30 -7
- data/lib/aws-sdk-code-generator/shared_example.rb +131 -0
- data/lib/aws-sdk-code-generator/syntax_example.rb +60 -0
- data/lib/aws-sdk-code-generator/syntax_example_hash.rb +174 -0
- data/lib/aws-sdk-code-generator/underscore.rb +10 -5
- data/lib/aws-sdk-code-generator/view.rb +33 -0
- data/lib/aws-sdk-code-generator/views/apig_endpoint_class.rb +25 -0
- data/lib/aws-sdk-code-generator/views/apig_readme.rb +32 -0
- data/lib/aws-sdk-code-generator/views/async_client_class.rb +68 -0
- data/lib/aws-sdk-code-generator/views/authorizer_class.rb +17 -0
- data/lib/aws-sdk-code-generator/views/client_api_module.rb +602 -0
- data/lib/aws-sdk-code-generator/views/client_class.rb +93 -0
- data/lib/aws-sdk-code-generator/views/docstring.rb +27 -0
- data/lib/aws-sdk-code-generator/views/errors_module.rb +32 -0
- data/lib/aws-sdk-code-generator/views/event_streams_module.rb +149 -0
- data/lib/aws-sdk-code-generator/views/features/env.rb +9 -0
- data/lib/aws-sdk-code-generator/views/features/smoke.rb +52 -0
- data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +26 -0
- data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +6 -2
- data/lib/aws-sdk-code-generator/views/gemspec.rb +39 -5
- data/lib/aws-sdk-code-generator/views/resource_class.rb +122 -0
- data/lib/aws-sdk-code-generator/views/root_resource_class.rb +58 -0
- data/lib/aws-sdk-code-generator/views/service_module.rb +38 -14
- data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -0
- data/lib/aws-sdk-code-generator/views/types_module.rb +329 -0
- data/lib/aws-sdk-code-generator/views/version.rb +2 -0
- data/lib/aws-sdk-code-generator/views/waiters_module.rb +37 -0
- data/lib/aws-sdk-code-generator/views.rb +2 -0
- data/lib/aws-sdk-code-generator/waiter.rb +95 -0
- data/lib/aws-sdk-code-generator/yard_option_tag.rb +43 -0
- data/lib/aws-sdk-code-generator.rb +68 -75
- data/templates/apig_endpoint_class.mustache +16 -0
- data/templates/apig_readme.mustache +62 -0
- data/templates/async_client_class.mustache +125 -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 +22 -0
- data/templates/features/smoke_step_definitions.mustache +31 -0
- data/templates/features/step_definitions.mustache +13 -0
- data/templates/gemspec.mustache +31 -0
- data/templates/license.txt +202 -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 +58 -0
- data/templates/spec/spec_helper.mustache +15 -0
- data/templates/types_module.mustache +53 -0
- data/templates/version.mustache +1 -0
- data/templates/waiters_module.mustache +112 -0
- metadata +115 -70
- data/lib/aws-sdk-code-generator/dsl/access_control_statement.rb +0 -23
- data/lib/aws-sdk-code-generator/dsl/attribute_accessor.rb +0 -43
- data/lib/aws-sdk-code-generator/dsl/attribute_reader.rb +0 -11
- data/lib/aws-sdk-code-generator/dsl/attribute_writer.rb +0 -11
- data/lib/aws-sdk-code-generator/dsl/autoload_statement.rb +0 -15
- data/lib/aws-sdk-code-generator/dsl/block_param.rb +0 -11
- data/lib/aws-sdk-code-generator/dsl/class.rb +0 -27
- data/lib/aws-sdk-code-generator/dsl/code_literal.rb +0 -66
- data/lib/aws-sdk-code-generator/dsl/code_object.rb +0 -33
- data/lib/aws-sdk-code-generator/dsl/docstring.rb +0 -36
- data/lib/aws-sdk-code-generator/dsl/eigenclass.rb +0 -15
- data/lib/aws-sdk-code-generator/dsl/extend_statement.rb +0 -12
- data/lib/aws-sdk-code-generator/dsl/formatter.rb +0 -25
- data/lib/aws-sdk-code-generator/dsl/include_statement.rb +0 -17
- data/lib/aws-sdk-code-generator/dsl/main.rb +0 -105
- data/lib/aws-sdk-code-generator/dsl/method.rb +0 -108
- data/lib/aws-sdk-code-generator/dsl/module.rb +0 -167
- data/lib/aws-sdk-code-generator/dsl/option_tag.rb +0 -36
- data/lib/aws-sdk-code-generator/dsl/param.rb +0 -43
- data/lib/aws-sdk-code-generator/dsl/param_list.rb +0 -38
- data/lib/aws-sdk-code-generator/dsl/return_tag.rb +0 -19
- data/lib/aws-sdk-code-generator/dsl/tag_default.rb +0 -20
- data/lib/aws-sdk-code-generator/dsl/tag_docstring.rb +0 -27
- data/lib/aws-sdk-code-generator/dsl/tag_type.rb +0 -18
- data/lib/aws-sdk-code-generator/generators/client_api_module.rb +0 -334
- data/lib/aws-sdk-code-generator/generators/client_class.rb +0 -389
- data/lib/aws-sdk-code-generator/generators/client_operation_documentation.rb +0 -166
- data/lib/aws-sdk-code-generator/generators/errors_module.rb +0 -25
- data/lib/aws-sdk-code-generator/generators/resource/action.rb +0 -88
- data/lib/aws-sdk-code-generator/generators/resource/batch_builder.rb +0 -211
- data/lib/aws-sdk-code-generator/generators/resource/builder.rb +0 -50
- data/lib/aws-sdk-code-generator/generators/resource/client_getter.rb +0 -15
- data/lib/aws-sdk-code-generator/generators/resource/client_request.rb +0 -49
- data/lib/aws-sdk-code-generator/generators/resource/client_request_docs.rb +0 -97
- data/lib/aws-sdk-code-generator/generators/resource/client_request_params.rb +0 -88
- data/lib/aws-sdk-code-generator/generators/resource/collection_class.rb +0 -180
- data/lib/aws-sdk-code-generator/generators/resource/data_attribute_getter.rb +0 -24
- data/lib/aws-sdk-code-generator/generators/resource/data_loaded_method.rb +0 -18
- data/lib/aws-sdk-code-generator/generators/resource/data_method.rb +0 -49
- data/lib/aws-sdk-code-generator/generators/resource/exists_method.rb +0 -29
- data/lib/aws-sdk-code-generator/generators/resource/extract_identifier_method.rb +0 -32
- data/lib/aws-sdk-code-generator/generators/resource/has_association.rb +0 -101
- data/lib/aws-sdk-code-generator/generators/resource/has_many_association.rb +0 -108
- data/lib/aws-sdk-code-generator/generators/resource/identifier_getter.rb +0 -26
- data/lib/aws-sdk-code-generator/generators/resource/identifiers_method.rb +0 -28
- data/lib/aws-sdk-code-generator/generators/resource/initialize_method.rb +0 -67
- data/lib/aws-sdk-code-generator/generators/resource/load_method.rb +0 -65
- data/lib/aws-sdk-code-generator/generators/resource/value_source.rb +0 -68
- data/lib/aws-sdk-code-generator/generators/resource/waiter_method.rb +0 -61
- data/lib/aws-sdk-code-generator/generators/resource_class.rb +0 -325
- data/lib/aws-sdk-code-generator/generators/response_structure_example.rb +0 -83
- data/lib/aws-sdk-code-generator/generators/root_resource_class.rb +0 -42
- data/lib/aws-sdk-code-generator/generators/service_documentation.rb +0 -64
- data/lib/aws-sdk-code-generator/generators/shared_example.rb +0 -132
- data/lib/aws-sdk-code-generator/generators/structure_type_class.rb +0 -95
- data/lib/aws-sdk-code-generator/generators/syntax_example.rb +0 -169
- data/lib/aws-sdk-code-generator/generators/types_module.rb +0 -52
- data/lib/aws-sdk-code-generator/generators/waiter_class.rb +0 -62
- data/lib/aws-sdk-code-generator/generators/waiters_module.rb +0 -20
@@ -1,95 +0,0 @@
|
|
1
|
-
module AwsSdkCodeGenerator
|
2
|
-
module Generators
|
3
|
-
class StructureTypeClass < Dsl::CodeLiteral
|
4
|
-
|
5
|
-
include Helper
|
6
|
-
|
7
|
-
# @option options [required, String] :name
|
8
|
-
# @option options [required, Hash] :api
|
9
|
-
# @option options [required, Boolean] :used_as_input
|
10
|
-
def initialize(options)
|
11
|
-
@name = options.fetch(:name)
|
12
|
-
@api = options.fetch(:api)
|
13
|
-
@shape = @api['shapes'][@name]
|
14
|
-
super()
|
15
|
-
|
16
|
-
apply_class_docs
|
17
|
-
apply_input_example if options.fetch(:used_as_input)
|
18
|
-
apply_returned_by
|
19
|
-
document_members
|
20
|
-
if @shape['members'].empty?
|
21
|
-
apply_empty_structure
|
22
|
-
else
|
23
|
-
apply_structure_with_members
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def apply_class_docs
|
30
|
-
if class_docs = documentation(@shape)
|
31
|
-
append(Dsl::Docstring.new(class_docs).to_s)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def apply_input_example
|
36
|
-
if @shape['members'].empty?
|
37
|
-
note = '@api private'
|
38
|
-
else
|
39
|
-
note = "@note When making an API call, pass #{@name}\n"
|
40
|
-
note += " data as a hash:\n\n"
|
41
|
-
note += SyntaxExample.new(
|
42
|
-
struct_shape: @shape,
|
43
|
-
api: @api,
|
44
|
-
indent: ' ' * 6
|
45
|
-
).format
|
46
|
-
end
|
47
|
-
append(Dsl::Docstring.new(note).to_s)
|
48
|
-
end
|
49
|
-
|
50
|
-
def apply_returned_by
|
51
|
-
# TODO : implement this
|
52
|
-
end
|
53
|
-
|
54
|
-
def apply_empty_structure
|
55
|
-
append("class #{@name} < Aws::EmptyStructure; end")
|
56
|
-
end
|
57
|
-
|
58
|
-
def apply_structure_with_members
|
59
|
-
append("class #{@name} < Struct.new(")
|
60
|
-
@shape['members'].keys.each.with_index do |member_name, n|
|
61
|
-
comma = n == @shape['members'].size - 1 ? ')' : ','
|
62
|
-
append(" :#{underscore(member_name)}#{comma}")
|
63
|
-
end
|
64
|
-
append(" include Aws::Structure")
|
65
|
-
append("end")
|
66
|
-
end
|
67
|
-
|
68
|
-
def document_members
|
69
|
-
@shape['members'].each.with_index do |(name, ref), n|
|
70
|
-
append("#") unless n == 0
|
71
|
-
append(Dsl::Docstring.new(attribute_macro(name, ref)).to_s)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def attribute_macro(member_name, member_ref)
|
76
|
-
docs = documentation(member_ref, line_width:68).lines.to_a.join(" ")
|
77
|
-
macro = "@!attribute [rw] #{underscore(member_name)}\n"
|
78
|
-
macro << " #{docs}\n" unless docs == ''
|
79
|
-
macro << " @return [#{ruby_type(member_ref)}]"
|
80
|
-
macro
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def needs_defaults?
|
86
|
-
@shape['members'].any? do |_, member_ref|
|
87
|
-
type = shape(member_ref)['type']
|
88
|
-
|
89
|
-
type == 'list' || type == 'map'
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
module AwsSdkCodeGenerator
|
2
|
-
module Generators
|
3
|
-
class SyntaxExample < Dsl::Docstring
|
4
|
-
|
5
|
-
include Helper
|
6
|
-
|
7
|
-
# @option options [required, Hash] :struct_shape
|
8
|
-
# @option options [required, Hash] :api
|
9
|
-
# @option options [String] :indent ('')
|
10
|
-
def initialize(options = {})
|
11
|
-
@indent = options.fetch(:indent, '')
|
12
|
-
@api = options.fetch(:api)
|
13
|
-
@struct_shape = options.fetch(:struct_shape)
|
14
|
-
end
|
15
|
-
|
16
|
-
def format
|
17
|
-
if @struct_shape && @struct_shape['members'].length > 0
|
18
|
-
@indent + struct(@struct_shape, @indent, [])
|
19
|
-
else
|
20
|
-
''
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def ref_value(ref, i, visited)
|
27
|
-
if visited.include?(ref['shape'])
|
28
|
-
return "{\n#{i} # recursive #{ref['shape']}\n#{i}}"
|
29
|
-
else
|
30
|
-
visited = visited + [ref['shape']]
|
31
|
-
end
|
32
|
-
|
33
|
-
s = shape(ref)
|
34
|
-
case s['type']
|
35
|
-
when 'structure'
|
36
|
-
if ref['shape'] == 'AttributeValue'
|
37
|
-
'"value"'
|
38
|
-
else
|
39
|
-
struct(s, i, visited)
|
40
|
-
end
|
41
|
-
|
42
|
-
when 'blob'
|
43
|
-
if ref['streaming']
|
44
|
-
'source_file'
|
45
|
-
else
|
46
|
-
'"data"'
|
47
|
-
end
|
48
|
-
|
49
|
-
when 'list' then list(s, i, visited)
|
50
|
-
when 'map' then map(s, i, visited)
|
51
|
-
when 'boolean' then "false"
|
52
|
-
when 'integer', 'long' then '1'
|
53
|
-
when 'float', 'double' then '1.0'
|
54
|
-
when 'byte' then '97'
|
55
|
-
when 'character' then '"a"'
|
56
|
-
when 'string' then string(ref)
|
57
|
-
when 'timestamp' then 'Time.now'
|
58
|
-
else raise "unsupported shape #{s['type'].inspect}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def struct(struct_shape, i, visited)
|
63
|
-
lines = ['{']
|
64
|
-
struct_shape['members'].each_pair do |member_name, member_ref|
|
65
|
-
lines << struct_member(struct_shape, member_name, member_ref, i, visited)
|
66
|
-
end
|
67
|
-
lines << "#{i}}"
|
68
|
-
lines.join("\n")
|
69
|
-
end
|
70
|
-
|
71
|
-
def struct_member(struct, member_name, member_ref, i, visited)
|
72
|
-
entry = "#{i} #{underscore(member_name)}: #{ref_value(member_ref, i + ' ', visited)},"
|
73
|
-
required = (struct['required'] || []).include?(member_name)
|
74
|
-
apply_comments(member_ref, entry, required: required)
|
75
|
-
end
|
76
|
-
|
77
|
-
def list(list_shape, i, visited)
|
78
|
-
member_ref = list_shape['member']
|
79
|
-
if complex?(member_ref)
|
80
|
-
complex_list(member_ref, i, visited)
|
81
|
-
else
|
82
|
-
scalar_list(member_ref, i, visited)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def scalar_list(member_ref, i, visited)
|
87
|
-
"[#{ref_value(member_ref, i, visited)}]"
|
88
|
-
end
|
89
|
-
|
90
|
-
def complex_list(member_ref, i, visited)
|
91
|
-
"[\n#{i} #{ref_value(member_ref, i + ' ', visited)},\n#{i}]"
|
92
|
-
end
|
93
|
-
|
94
|
-
def map(map_shape, i, visited)
|
95
|
-
key = string(map_shape['key'])
|
96
|
-
value = ref_value(map_shape['value'], i + ' ', visited)
|
97
|
-
"{\n#{i} #{key} => #{value},#{comments(map_shape['value'], false)}\n#{i}}"
|
98
|
-
end
|
99
|
-
|
100
|
-
def string(ref)
|
101
|
-
string_shape = shape(ref)
|
102
|
-
if string_shape['enum']
|
103
|
-
string_shape['enum'].first.inspect
|
104
|
-
else ref['shape']
|
105
|
-
ref['shape'].inspect
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def apply_comments(ref, text, options = {})
|
110
|
-
required = options.fetch(:required)
|
111
|
-
lines = text.lines.to_a
|
112
|
-
if lines[0].match(/\n$/)
|
113
|
-
lines[0] = lines[0].sub(/\n$/, comments(ref, required) + "\n")
|
114
|
-
else
|
115
|
-
lines[0] += comments(ref, required)
|
116
|
-
end
|
117
|
-
lines.join
|
118
|
-
end
|
119
|
-
|
120
|
-
def comments(ref, required)
|
121
|
-
comments = []
|
122
|
-
if ref[:response_target]
|
123
|
-
comments << 'where to write response data, file path, or IO object'
|
124
|
-
end
|
125
|
-
if ref[:streaming]
|
126
|
-
comments << 'file/IO object, or string data'
|
127
|
-
end
|
128
|
-
if required
|
129
|
-
comments << 'required'
|
130
|
-
end
|
131
|
-
if enum = enum_values(ref)
|
132
|
-
comments << "accepts #{enum.to_a.join(', ')}"
|
133
|
-
end
|
134
|
-
if ddb_av?(ref)
|
135
|
-
comments << 'value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>'
|
136
|
-
end
|
137
|
-
comments == [] ? '' : " # #{comments.join(', ')}"
|
138
|
-
end
|
139
|
-
|
140
|
-
def enum_values(ref)
|
141
|
-
s = shape(ref)
|
142
|
-
case s['type']
|
143
|
-
when 'list' then enum_values(s['member'])
|
144
|
-
when 'string' then s['enum']
|
145
|
-
else nil
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def complex?(ref)
|
150
|
-
s = shape(ref)
|
151
|
-
if s['type'] == 'structure'
|
152
|
-
!ddb_av?(ref)
|
153
|
-
else
|
154
|
-
s['type'] == 'list' || s['type'] == 'map'
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def ddb_av?(ref)
|
159
|
-
s = shape(ref)
|
160
|
-
case s['type']
|
161
|
-
when 'list' then ddb_av?(s['member'])
|
162
|
-
when 'structure' then ref['shape'] == 'AttributeValue'
|
163
|
-
else false
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
module AwsSdkCodeGenerator
|
4
|
-
module Generators
|
5
|
-
class TypesModule < Dsl::Module
|
6
|
-
|
7
|
-
include Helper
|
8
|
-
|
9
|
-
# @option options [required, Hash] :api
|
10
|
-
def initialize(options)
|
11
|
-
@api = options.fetch(:api)
|
12
|
-
super('Types')
|
13
|
-
input_shapes = compute_input_shapes(@api)
|
14
|
-
structures.each do |shape_name, shape|
|
15
|
-
add(StructureTypeClass.new(
|
16
|
-
name: shape_name,
|
17
|
-
api: @api,
|
18
|
-
used_as_input: input_shapes.include?(shape_name)
|
19
|
-
))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def compute_input_shapes(api)
|
26
|
-
inputs = Set.new
|
27
|
-
(api['operations'] || {}).each do |_, operation|
|
28
|
-
visit_inputs(operation['input'], inputs) if operation['input']
|
29
|
-
end
|
30
|
-
inputs
|
31
|
-
end
|
32
|
-
|
33
|
-
def visit_inputs(shape_ref, inputs)
|
34
|
-
return if inputs.include?(shape_ref['shape']) # recursion
|
35
|
-
inputs << shape_ref['shape']
|
36
|
-
s = shape(shape_ref)
|
37
|
-
case s['type']
|
38
|
-
when 'structure'
|
39
|
-
s['members'].each_pair do |_, member_ref|
|
40
|
-
visit_inputs(member_ref, inputs)
|
41
|
-
end
|
42
|
-
when 'list'
|
43
|
-
visit_inputs(s['member'], inputs)
|
44
|
-
when 'map'
|
45
|
-
visit_inputs(s['key'], inputs)
|
46
|
-
visit_inputs(s['value'], inputs)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
module AwsSdkCodeGenerator
|
2
|
-
module Generators
|
3
|
-
class WaiterClass < Dsl::Class
|
4
|
-
|
5
|
-
# @option options [required, String] :waiter_name
|
6
|
-
# @option options [required, Hash] :waiter
|
7
|
-
def initialize(options)
|
8
|
-
waiter = options.fetch(:waiter)
|
9
|
-
client_method = underscore(waiter['operation'])
|
10
|
-
super(options.fetch(:waiter_name))
|
11
|
-
code <<-CODE
|
12
|
-
# @param [Hash] options
|
13
|
-
# @option options [required, Client] :client
|
14
|
-
# @option options [Integer] :max_attempts (#{waiter['maxAttempts']})
|
15
|
-
# @option options [Integer] :delay (#{waiter['delay']})
|
16
|
-
# @option options [Proc] :before_attempt
|
17
|
-
# @option options [Proc] :before_wait
|
18
|
-
def initialize(options)
|
19
|
-
@client = options.fetch(:client)
|
20
|
-
@waiter = Aws::Waiters::Waiter.new({
|
21
|
-
max_attempts: #{waiter['maxAttempts']},
|
22
|
-
delay: #{waiter['delay']},
|
23
|
-
poller: Aws::Waiters::Poller.new(#{poller_args(waiter)} )
|
24
|
-
}.merge(options))
|
25
|
-
end
|
26
|
-
|
27
|
-
# @option (see Client##{client_method})
|
28
|
-
# @return (see Client##{client_method})
|
29
|
-
def wait(params = {})
|
30
|
-
@waiter.wait(client: @client, params: params)
|
31
|
-
end
|
32
|
-
|
33
|
-
# @api private
|
34
|
-
attr_reader :waiter
|
35
|
-
CODE
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def poller_args(hash)
|
41
|
-
hash = hash.dup
|
42
|
-
hash.delete('delay')
|
43
|
-
hash.delete('maxAttempts')
|
44
|
-
hash[:operation_name] = Underscore.underscore(hash.delete('operation')).to_sym
|
45
|
-
hash[:acceptors] = hash.delete('acceptors').map do |acceptor|
|
46
|
-
if acceptor['argument']
|
47
|
-
acceptor['argument'] = Underscore.underscore_jmespath(acceptor['argument'])
|
48
|
-
end
|
49
|
-
acceptor
|
50
|
-
end
|
51
|
-
formatter = HashFormatter.new(
|
52
|
-
wrap: false,
|
53
|
-
inline: false,
|
54
|
-
quote_strings: true
|
55
|
-
)
|
56
|
-
lines = formatter.format(hash).lines
|
57
|
-
lines.map { |line| " #{line}" }.join
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module AwsSdkCodeGenerator
|
2
|
-
module Generators
|
3
|
-
class WaitersModule < Dsl::Module
|
4
|
-
|
5
|
-
include Helper
|
6
|
-
|
7
|
-
# @option options [required, Module] :parent
|
8
|
-
# @option options [required, Hash, nil] :waiters
|
9
|
-
def initialize(options)
|
10
|
-
waiters = options.fetch(:waiters)
|
11
|
-
super('Waiters', parent: options.fetch(:parent))
|
12
|
-
require_statement('aws-sdk-core/waiters')
|
13
|
-
waiters['waiters'].each do |waiter_name, waiter|
|
14
|
-
add(WaiterClass.new(waiter_name: waiter_name, waiter: waiter))
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|