aws-sdk-code-generator 0.4.0.pre → 0.6.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aws-sdk-code-generator/api.rb +2 -1
- data/lib/aws-sdk-code-generator/client_constructor.rb +2 -1
- data/lib/aws-sdk-code-generator/client_operation_documentation.rb +2 -1
- data/lib/aws-sdk-code-generator/client_operation_list.rb +4 -0
- data/lib/aws-sdk-code-generator/code_builder.rb +54 -2
- data/lib/aws-sdk-code-generator/endpoint_parameter.rb +190 -0
- data/lib/aws-sdk-code-generator/eventstream_example.rb +34 -34
- data/lib/aws-sdk-code-generator/gem_builder.rb +3 -5
- data/lib/aws-sdk-code-generator/helper.rb +11 -1
- data/lib/aws-sdk-code-generator/plugin_list.rb +5 -2
- data/lib/aws-sdk-code-generator/rbs/error_list.rb +38 -0
- data/lib/aws-sdk-code-generator/rbs/keyword_argument_builder.rb +159 -0
- data/lib/aws-sdk-code-generator/rbs/method_signature.rb +11 -0
- data/lib/aws-sdk-code-generator/rbs/resource_action.rb +39 -0
- data/lib/aws-sdk-code-generator/rbs/resource_association.rb +50 -0
- data/lib/aws-sdk-code-generator/rbs/resource_batch_action.rb +59 -0
- data/lib/aws-sdk-code-generator/rbs/resource_client_request.rb +40 -0
- data/lib/aws-sdk-code-generator/rbs/waiter.rb +53 -0
- data/lib/aws-sdk-code-generator/rbs.rb +40 -0
- data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +3 -1
- data/lib/aws-sdk-code-generator/resource_client_request.rb +3 -1
- data/lib/aws-sdk-code-generator/resource_waiter.rb +6 -5
- data/lib/aws-sdk-code-generator/service.rb +85 -16
- data/lib/aws-sdk-code-generator/views/async_client_class.rb +5 -1
- data/lib/aws-sdk-code-generator/views/client_api_module.rb +58 -16
- data/lib/aws-sdk-code-generator/views/client_class.rb +5 -1
- data/lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb +6 -50
- data/lib/aws-sdk-code-generator/views/endpoint_provider_class.rb +9 -0
- data/lib/aws-sdk-code-generator/views/endpoints_module.rb +18 -124
- data/lib/aws-sdk-code-generator/views/endpoints_plugin.rb +46 -4
- data/lib/aws-sdk-code-generator/views/errors_module.rb +21 -0
- data/lib/aws-sdk-code-generator/views/event_streams_module.rb +7 -1
- data/lib/aws-sdk-code-generator/views/features/smoke.rb +100 -23
- data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +1 -4
- data/lib/aws-sdk-code-generator/views/gemspec.rb +13 -3
- data/lib/aws-sdk-code-generator/views/rbs/client_class.rb +172 -0
- data/lib/aws-sdk-code-generator/views/rbs/errors_module.rb +28 -0
- data/lib/aws-sdk-code-generator/views/rbs/resource_class.rb +95 -0
- data/lib/aws-sdk-code-generator/views/rbs/root_resource_class.rb +30 -0
- data/lib/aws-sdk-code-generator/views/rbs/types_module.rb +257 -0
- data/lib/aws-sdk-code-generator/views/rbs/waiters_module.rb +22 -0
- data/lib/aws-sdk-code-generator/views/resource_class.rb +22 -0
- data/lib/aws-sdk-code-generator/views/root_resource_class.rb +19 -0
- data/lib/aws-sdk-code-generator/views/service_module.rb +41 -27
- data/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +25 -12
- data/lib/aws-sdk-code-generator/views/types_module.rb +34 -11
- data/lib/aws-sdk-code-generator.rb +29 -1
- data/templates/async_client_class.mustache +6 -1
- data/templates/client_api_module.mustache +14 -0
- data/templates/client_class.mustache +10 -47
- data/templates/endpoint_parameters_class.mustache +16 -13
- data/templates/endpoints_module.mustache +19 -11
- data/templates/endpoints_plugin.mustache +38 -20
- data/templates/errors_module.mustache +5 -0
- data/templates/features/smoke.mustache +11 -15
- data/templates/features/step_definitions.mustache +0 -5
- data/templates/gemspec.mustache +5 -2
- data/templates/rbs/client_class.mustache +39 -0
- data/templates/rbs/errors_module.mustache +17 -0
- data/templates/rbs/resource_class.mustache +71 -0
- data/templates/rbs/root_resource_class.mustache +26 -0
- data/templates/rbs/types_module.mustache +37 -0
- data/templates/rbs/waiters_module.mustache +17 -0
- data/templates/resource_class.mustache +8 -1
- data/templates/root_resource_class.mustache +5 -0
- data/templates/service_module.mustache +13 -3
- data/templates/spec/endpoint_provider_spec_class.mustache +11 -1
- data/templates/types_module.mustache +4 -0
- metadata +27 -7
- data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +0 -26
- data/templates/features/smoke_step_definitions.mustache +0 -31
@@ -10,35 +10,25 @@ module AwsSdkCodeGenerator
|
|
10
10
|
def initialize(options)
|
11
11
|
service = options.fetch(:service)
|
12
12
|
@custom = service.protocol == 'api-gateway'
|
13
|
-
@
|
13
|
+
@service_name = service.name
|
14
|
+
@service_module = service.module_name
|
14
15
|
|
15
16
|
# This will only be called if this is defined
|
16
17
|
smoke_json = service.smoke_tests
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
h[:error_expectation] = "I expect an error was not raised"
|
29
|
-
h[:scenario_string] = "Call #{service.module_name}::Client##{h[:operation]} and expect it to succeed"
|
30
|
-
end
|
31
|
-
h[:param_hash] = test["input"].inject({}) do |acc, kv|
|
32
|
-
raw_key, value = kv
|
33
|
-
key = underscore(raw_key)
|
34
|
-
acc[key] = value
|
35
|
-
acc
|
36
|
-
end.to_json
|
37
|
-
h
|
18
|
+
@smoke_tests = smoke_json['testCases'].map do |test|
|
19
|
+
SmokeTest.new(
|
20
|
+
service: service,
|
21
|
+
id: test['id'],
|
22
|
+
operation_name: test['operationName'],
|
23
|
+
input: test['input'],
|
24
|
+
expectation: test['expectation'],
|
25
|
+
config: test['config'],
|
26
|
+
tags: test['tags']
|
27
|
+
)
|
38
28
|
end
|
39
29
|
end
|
40
30
|
|
41
|
-
attr_reader :
|
31
|
+
attr_reader :service_name, :smoke_tests, :service_module
|
42
32
|
|
43
33
|
# @return [String|nil]
|
44
34
|
def generated_src_warning
|
@@ -46,6 +36,93 @@ module AwsSdkCodeGenerator
|
|
46
36
|
GENERATED_SRC_WARNING
|
47
37
|
end
|
48
38
|
|
39
|
+
class SmokeTest < View
|
40
|
+
def initialize(options)
|
41
|
+
@service = options.fetch(:service)
|
42
|
+
@id = options.fetch(:id)
|
43
|
+
@operation_name = underscore(options.fetch(:operation_name))
|
44
|
+
@input = options.fetch(:input)
|
45
|
+
@expectation = expectation_str(options.fetch(:expectation))
|
46
|
+
@config = options.fetch(:config)
|
47
|
+
|
48
|
+
tags = options.fetch(:tags) || []
|
49
|
+
tags = tags.map { |t| "@#{t}" }.join(' ')
|
50
|
+
@tags = "@#{@service.identifier} @smoke #{tags}".strip
|
51
|
+
end
|
52
|
+
|
53
|
+
attr_reader :id, :operation_name, :expectation, :tags
|
54
|
+
|
55
|
+
def param_hash
|
56
|
+
deep_underscore(@input).to_json
|
57
|
+
end
|
58
|
+
|
59
|
+
def config_hash
|
60
|
+
@config.each_with_object({}) do |(raw_key, raw_value), acc|
|
61
|
+
key, value = config_map(raw_key, raw_value)
|
62
|
+
acc[key] = value unless key.nil?
|
63
|
+
end.to_json
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def deep_underscore(input)
|
69
|
+
case input
|
70
|
+
when Hash
|
71
|
+
input.each_with_object({}) do |(key, value), acc|
|
72
|
+
acc[underscore(key)] = deep_underscore(value)
|
73
|
+
end
|
74
|
+
when Array
|
75
|
+
input.map { |value| deep_underscore(value) }
|
76
|
+
else
|
77
|
+
input
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def config_map(raw_key, raw_value)
|
82
|
+
case raw_key
|
83
|
+
# generic
|
84
|
+
when 'region' then ['region', raw_value]
|
85
|
+
when 'sigv4aRegionSet' then nil # TODO
|
86
|
+
when 'uri' then ['endpoint', raw_value]
|
87
|
+
when 'useFips' then ['use_fips_endpoint', raw_value]
|
88
|
+
when 'useDualstack' then ['use_dualstack_endpoint', raw_value]
|
89
|
+
# service specific
|
90
|
+
when 'useGlobalEndpoint'
|
91
|
+
value = raw_value == 'true' ? 'legacy' : 'regional'
|
92
|
+
case @service.name
|
93
|
+
when 'S3'
|
94
|
+
['s3_us_east_1_regional_endpoint', value]
|
95
|
+
when 'STS'
|
96
|
+
['sts_regional_endpoints', value]
|
97
|
+
end
|
98
|
+
# s3 specific
|
99
|
+
when 'useAccelerate' then ['use_accelerate_endpoint', raw_value]
|
100
|
+
when 'useArnRegion' then ['s3_use_arn_region', raw_value]
|
101
|
+
when 'useMultiRegionAccessPoints'
|
102
|
+
value = raw_value == 'true' ? 'false' : 'true'
|
103
|
+
['s3_disable_multiregion_access_points', value]
|
104
|
+
when 'forcePathStyle' then ['force_path_style', raw_value]
|
105
|
+
when 'useAccountIdRouting' then nil # TODO
|
106
|
+
else
|
107
|
+
# catch all, possible code generated config options
|
108
|
+
[underscore(raw_key), raw_value]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def expectation_str(expectation)
|
113
|
+
if expectation.key?('success')
|
114
|
+
'I expect an error was not raised'
|
115
|
+
elsif expectation.key?('failure')
|
116
|
+
if (error_id = expectation['failure']['errorId'])
|
117
|
+
error_class = "#{@service.module_name}::Errors::#{error_id}"
|
118
|
+
"I expect a '#{error_class}' was raised"
|
119
|
+
else
|
120
|
+
'I expect an error was raised'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
49
126
|
end
|
50
127
|
end
|
51
128
|
end
|
@@ -11,12 +11,9 @@ module AwsSdkCodeGenerator
|
|
11
11
|
service = options.fetch(:service)
|
12
12
|
@var_name = service.identifier
|
13
13
|
@module_name = service.module_name
|
14
|
-
if service.smoke_tests
|
15
|
-
@client_endpoint = service.smoke_tests['defaultEndpoint']
|
16
|
-
end
|
17
14
|
end
|
18
15
|
|
19
|
-
attr_reader :var_name, :module_name
|
16
|
+
attr_reader :var_name, :module_name
|
20
17
|
|
21
18
|
end
|
22
19
|
end
|
@@ -43,7 +43,7 @@ module AwsSdkCodeGenerator
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def files
|
46
|
-
['LICENSE.txt', 'CHANGELOG.md', 'VERSION', 'lib/**/*.rb']
|
46
|
+
['LICENSE.txt', 'CHANGELOG.md', 'VERSION', 'lib/**/*.rb', 'sig/**/*.rbs']
|
47
47
|
end
|
48
48
|
|
49
49
|
# @return [String]
|
@@ -54,7 +54,9 @@ module AwsSdkCodeGenerator
|
|
54
54
|
if @service.short_name != @service.full_name
|
55
55
|
abbreviation = " (#{@service.short_name})"
|
56
56
|
end
|
57
|
-
desc =
|
57
|
+
desc = ''
|
58
|
+
desc += '[DEPRECATED] ' if @service.deprecated?
|
59
|
+
desc += "Official AWS Ruby gem for #{@service.full_name}#{abbreviation}. "
|
58
60
|
desc += 'This gem is part of the AWS SDK for Ruby.'
|
59
61
|
end
|
60
62
|
desc
|
@@ -72,7 +74,15 @@ module AwsSdkCodeGenerator
|
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
|
-
|
77
|
+
def deprecated?
|
78
|
+
@service.deprecated?
|
79
|
+
end
|
80
|
+
|
81
|
+
Dependency = Struct.new(:gem, :version) do
|
82
|
+
def gem_version
|
83
|
+
[gem, version].compact.map { |s| "'#{s}'"}.join(', ')
|
84
|
+
end
|
85
|
+
end
|
76
86
|
|
77
87
|
end
|
78
88
|
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module RBS
|
6
|
+
class ClientClass < View
|
7
|
+
SKIP_MEMBERS = Set.new(%w[
|
8
|
+
context
|
9
|
+
data
|
10
|
+
error
|
11
|
+
checksum_validated
|
12
|
+
on
|
13
|
+
on_success
|
14
|
+
])
|
15
|
+
|
16
|
+
def initialize(options)
|
17
|
+
@options = options
|
18
|
+
@service_name = options.fetch(:service_name)
|
19
|
+
@api = options.fetch(:api)
|
20
|
+
@aws_sdk_core_lib_path = options.fetch(:aws_sdk_core_lib_path)
|
21
|
+
@plugins = PluginList.new(options)
|
22
|
+
@codegenerated_plugins = options.fetch(:codegenerated_plugins)
|
23
|
+
@waiters = AwsSdkCodeGenerator::RBS::Waiter.build_list(api: @api, waiters:options.fetch(:waiters))
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String|nil]
|
27
|
+
def generated_src_warning
|
28
|
+
GENERATED_SRC_WARNING
|
29
|
+
end
|
30
|
+
|
31
|
+
def service_name
|
32
|
+
@service_name
|
33
|
+
end
|
34
|
+
|
35
|
+
def client_option(indent: ' ' * 20)
|
36
|
+
plugin_options = documented_plugin_options(@plugins) + documented_plugin_options(@codegenerated_plugins)
|
37
|
+
[
|
38
|
+
'',
|
39
|
+
"#{indent} #{build_keyword_arguments(plugin_options).join(",\n#{indent} ")}",
|
40
|
+
indent,
|
41
|
+
].join("\n")
|
42
|
+
end
|
43
|
+
|
44
|
+
def operations
|
45
|
+
shapes = @api["shapes"]
|
46
|
+
@api["operations"].map do |name, body|
|
47
|
+
method_name = Underscore.underscore(name)
|
48
|
+
indent = " " * (12 + method_name.length)
|
49
|
+
input_shape_name = body.dig("input", "shape")
|
50
|
+
arguments = nil
|
51
|
+
include_required = false
|
52
|
+
if input_shape_name
|
53
|
+
input_shape = shapes[input_shape_name]
|
54
|
+
builder = AwsSdkCodeGenerator::RBS::KeywordArgumentBuilder.new(
|
55
|
+
api: @api,
|
56
|
+
shape: input_shape,
|
57
|
+
newline: true,
|
58
|
+
)
|
59
|
+
arguments = builder.format(indent: indent)
|
60
|
+
include_required = input_shape["required"]&.empty?&.!
|
61
|
+
end
|
62
|
+
if AwsSdkCodeGenerator::Helper.operation_streaming?(body, @api)
|
63
|
+
block = " ?{ (*untyped) -> void }"
|
64
|
+
end
|
65
|
+
if output_shape_name = body.dig("output", "shape")
|
66
|
+
output_shape = shapes[output_shape_name]
|
67
|
+
data = AwsSdkCodeGenerator::RBS.to_type(body.fetch( "output"), @api)
|
68
|
+
interface = "_#{name}ResponseSuccess"
|
69
|
+
else
|
70
|
+
output_shape = nil
|
71
|
+
data = "::Aws::EmptyStructure"
|
72
|
+
interface = empty_interface = "::Seahorse::Client::_ResponseSuccess[::Aws::EmptyStructure]"
|
73
|
+
end
|
74
|
+
returns_members = output_shape&.[]("members")&.inject([]) do |a, (member_name, member_ref)|
|
75
|
+
member_name_underscore = Underscore.underscore(member_name)
|
76
|
+
next a if SKIP_MEMBERS.include?(member_name_underscore)
|
77
|
+
a << {
|
78
|
+
method_name: member_name_underscore,
|
79
|
+
returns: AwsSdkCodeGenerator::RBS.to_type(member_ref, @api),
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
{
|
84
|
+
method_name: method_name,
|
85
|
+
signature: AwsSdkCodeGenerator::RBS::MethodSignature.new(
|
86
|
+
method_name: method_name,
|
87
|
+
overloads: [
|
88
|
+
"(#{arguments})#{block} -> #{interface}",
|
89
|
+
"(#{include_required ? "" : "?"}Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options)#{block} -> #{interface}",
|
90
|
+
]).signature,
|
91
|
+
interface: interface,
|
92
|
+
data: data,
|
93
|
+
returns_members: returns_members,
|
94
|
+
empty_structure: output_shape.nil?
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def waiters?
|
100
|
+
@waiters.size > 0
|
101
|
+
end
|
102
|
+
|
103
|
+
def waiters_first
|
104
|
+
[@waiters.first]
|
105
|
+
end
|
106
|
+
|
107
|
+
def waiters_others
|
108
|
+
@waiters[1..-1]
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def documented_plugin_options(plugins)
|
114
|
+
i = 0
|
115
|
+
plugins.map(&:options).flatten.select(&:documented?).sort_by do |opt|
|
116
|
+
[opt.required ? 'a' : 'b', opt.name, i += 1]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def build_keyword_arguments(plugins)
|
121
|
+
buffer = plugins.map do |opt|
|
122
|
+
if opt.rbs_type
|
123
|
+
opt.rbs_type
|
124
|
+
else
|
125
|
+
case opt.doc_type
|
126
|
+
when "Boolean"
|
127
|
+
"bool"
|
128
|
+
when nil
|
129
|
+
"untyped"
|
130
|
+
else
|
131
|
+
opt.doc_type.to_s
|
132
|
+
end
|
133
|
+
end.yield_self do |type|
|
134
|
+
[opt.name, "?#{opt.name}: #{type}", opt.doc_type]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
# Find duplicated key
|
138
|
+
grouped = buffer.group_by { |name, _| name }
|
139
|
+
grouped.transform_values(&:count).find_all { |_, c| 1 < c }.each do |name,|
|
140
|
+
case name
|
141
|
+
when :endpoint, :endpoint_provider, :retry_limit, :disable_s3_express_session_auth, :account_id_endpoint_mode
|
142
|
+
# ok
|
143
|
+
else
|
144
|
+
warn("Duplicate client option in #{@service_name}: `#{grouped[name].map { |g| g.values_at(0, 2) }}`", uplevel: 0)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
buffer.uniq! { |b| b[0] }
|
148
|
+
buffer.map! { |b| b[1] }
|
149
|
+
buffer.concat([
|
150
|
+
# from mustache
|
151
|
+
"?http_proxy: String",
|
152
|
+
"?http_open_timeout: (Float | Integer)",
|
153
|
+
"?http_read_timeout: (Float | Integer)",
|
154
|
+
"?http_idle_timeout: (Float | Integer)",
|
155
|
+
"?http_continue_timeout: (Float | Integer)",
|
156
|
+
"?ssl_timeout: (Float | Integer | nil)",
|
157
|
+
"?http_wire_trace: bool",
|
158
|
+
"?ssl_verify_peer: bool",
|
159
|
+
"?ssl_ca_bundle: String",
|
160
|
+
"?ssl_ca_directory: String",
|
161
|
+
# from object
|
162
|
+
"?ssl_ca_store: String",
|
163
|
+
"?on_chunk_received: Proc",
|
164
|
+
"?on_chunk_sent: Proc",
|
165
|
+
"?raise_response_errors: bool",
|
166
|
+
])
|
167
|
+
buffer
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module RBS
|
6
|
+
class ErrorsModule < View
|
7
|
+
attr_reader :errors
|
8
|
+
|
9
|
+
def initialize(service:)
|
10
|
+
@service = service
|
11
|
+
@errors = AwsSdkCodeGenerator::RBS::ErrorList.new(
|
12
|
+
api: service.api,
|
13
|
+
module_name: service.module_name
|
14
|
+
).to_a
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [String|nil]
|
18
|
+
def generated_src_warning
|
19
|
+
GENERATED_SRC_WARNING
|
20
|
+
end
|
21
|
+
|
22
|
+
def service_name
|
23
|
+
@service.name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module RBS
|
6
|
+
class ResourceClass < View
|
7
|
+
attr_reader :service_name
|
8
|
+
attr_reader :class_name
|
9
|
+
attr_reader :identifiers
|
10
|
+
attr_reader :data_attributes
|
11
|
+
attr_reader :shape
|
12
|
+
attr_reader :exists_waiters
|
13
|
+
attr_reader :waiters
|
14
|
+
attr_reader :actions
|
15
|
+
attr_reader :associations
|
16
|
+
attr_reader :batch_actions
|
17
|
+
|
18
|
+
def initialize(service_name:, class_name:, resource:, api:, paginators:)
|
19
|
+
@class_name = class_name
|
20
|
+
@resource = resource
|
21
|
+
@service_name = service_name
|
22
|
+
@identifiers = ResourceIdentifier.build_list(resource)
|
23
|
+
@data_attributes = if @resource["shape"]
|
24
|
+
data_attribute_names = AwsSdkCodeGenerator::ResourceAttribute.send(:data_attribute_names, @resource, api)
|
25
|
+
data_attribute_names.map do |member_name, member_ref|
|
26
|
+
AwsSdkCodeGenerator::RBS::MethodSignature.new(
|
27
|
+
method_name: Underscore.underscore(member_name),
|
28
|
+
overloads: ["() -> #{AwsSdkCodeGenerator::RBS.to_type(member_ref, api)}"]
|
29
|
+
)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
@shape = @resource["shape"]
|
35
|
+
@exists_waiters = @resource.fetch("waiters", []).any? { |name, _| name == "Exists" }
|
36
|
+
@waiters = @resource.fetch("waiters", []).map do |waiter_name, waiter_body|
|
37
|
+
AwsSdkCodeGenerator::RBS::MethodSignature.new(
|
38
|
+
method_name: "wait_until_#{Underscore.underscore(waiter_name)}",
|
39
|
+
overloads: [
|
40
|
+
"(?max_attempts: Integer, ?delay: Numeric, ?before_attempt: (^(Integer attempts) -> void), ?before_wait: (^(Integer attempts, untyped response) -> void)) ?{ (untyped waiter) -> void } -> #{class_name}",
|
41
|
+
"(?Hash[Symbol, untyped]) ?{ (untyped waiter) -> void } -> #{class_name}",
|
42
|
+
],
|
43
|
+
)
|
44
|
+
end
|
45
|
+
@actions = AwsSdkCodeGenerator::RBS::ResourceAction.build_method_signature_list(resource: @resource, api: api)
|
46
|
+
@associations = AwsSdkCodeGenerator::RBS::ResourceAssociation.build_method_signature_list(resource: @resource, api: api, paginators: paginators)
|
47
|
+
@batch_actions = AwsSdkCodeGenerator::RBS::ResourceBatchAction.build_method_signature_list(resource: @resource, api: api)
|
48
|
+
avoid_duplicate_methods
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [String|nil]
|
52
|
+
def generated_src_warning
|
53
|
+
GENERATED_SRC_WARNING
|
54
|
+
end
|
55
|
+
|
56
|
+
def initialize_signature
|
57
|
+
initialize_overloads =
|
58
|
+
if @identifiers.empty?
|
59
|
+
[]
|
60
|
+
else
|
61
|
+
positional = @identifiers.map { |id| "#{id.type} #{id.name}" } << "Hash[Symbol, untyped] options"
|
62
|
+
keyword = @identifiers.map { |id| "#{id.name}: #{id.type}" } << "?client: Client"
|
63
|
+
[
|
64
|
+
"(#{positional.join(', ')}) -> void",
|
65
|
+
"(#{keyword.join(', ')}) -> void"
|
66
|
+
]
|
67
|
+
end
|
68
|
+
initialize_overloads << "(Hash[Symbol, untyped] args) -> void"
|
69
|
+
"def initialize: #{initialize_overloads.join("\n | ")}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def load?
|
73
|
+
@resource["load"]
|
74
|
+
end
|
75
|
+
|
76
|
+
def load_or_shape?
|
77
|
+
load? or !!shape
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# `Aws::RDS::DBEngineVersion` has a duplicated method named `engine`.
|
83
|
+
# This is a rare case and should be patched minimally.
|
84
|
+
def avoid_duplicate_methods
|
85
|
+
overrided_method_names = @actions.map(&:method_name).to_set + @associations.map(&:method_name).to_set
|
86
|
+
@identifiers.each do |identifier|
|
87
|
+
if identifier.alias && overrided_method_names.include?(identifier.alias)
|
88
|
+
identifier.alias = nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module RBS
|
6
|
+
class RootResourceClass < View
|
7
|
+
attr_reader :actions
|
8
|
+
attr_reader :associations
|
9
|
+
attr_reader :service_name
|
10
|
+
|
11
|
+
def initialize(client_class:, api:, resources:, service_name:, paginators:)
|
12
|
+
@client_class = client_class
|
13
|
+
@service_name = service_name
|
14
|
+
resource = resources&.[]("service") || {}
|
15
|
+
@actions = AwsSdkCodeGenerator::RBS::ResourceAction.build_method_signature_list(resource: resource, api: api)
|
16
|
+
@associations = AwsSdkCodeGenerator::RBS::ResourceAssociation.build_method_signature_list(resource: resource, api: api, paginators: paginators)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [String|nil]
|
20
|
+
def generated_src_warning
|
21
|
+
GENERATED_SRC_WARNING
|
22
|
+
end
|
23
|
+
|
24
|
+
def client_option
|
25
|
+
@client_class.client_option(indent: ' ' * 22)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|