aws-sdk-code-generator 0.4.0.pre → 0.5.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/client_constructor.rb +2 -1
- data/lib/aws-sdk-code-generator/code_builder.rb +52 -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/plugin_list.rb +2 -1
- 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 +21 -0
- data/lib/aws-sdk-code-generator/views/async_client_class.rb +5 -1
- data/lib/aws-sdk-code-generator/views/client_api_module.rb +29 -4
- data/lib/aws-sdk-code-generator/views/client_class.rb +5 -1
- data/lib/aws-sdk-code-generator/views/event_streams_module.rb +7 -1
- data/lib/aws-sdk-code-generator/views/features/smoke.rb +99 -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/spec/endpoint_provider_spec_class.rb +5 -1
- data/lib/aws-sdk-code-generator/views/types_module.rb +8 -9
- data/lib/aws-sdk-code-generator.rb +17 -1
- data/templates/client_api_module.mustache +7 -0
- data/templates/client_class.mustache +0 -45
- data/templates/endpoints_module.mustache +1 -0
- data/templates/endpoints_plugin.mustache +4 -2
- 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 +3 -1
- data/templates/spec/endpoint_provider_spec_class.mustache +10 -0
- metadata +24 -5
- data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +0 -26
- data/templates/features/smoke_step_definitions.mustache +0 -31
@@ -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
|
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
|
@@ -0,0 +1,257 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module RBS
|
6
|
+
class TypesModule < View
|
7
|
+
|
8
|
+
include Helper
|
9
|
+
|
10
|
+
# @option options [required, Service] :service
|
11
|
+
def initialize(options)
|
12
|
+
@service = options.fetch(:service)
|
13
|
+
@api = @service.api
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String|nil]
|
17
|
+
def generated_src_warning
|
18
|
+
return if @service.protocol == 'api-gateway'
|
19
|
+
GENERATED_SRC_WARNING
|
20
|
+
end
|
21
|
+
|
22
|
+
def module_name
|
23
|
+
@service.module_name
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Array<StructClass>]
|
27
|
+
def structures
|
28
|
+
@service.api['shapes'].each do |_, shape|
|
29
|
+
if shape['eventstream']
|
30
|
+
# add internal exception_event ctrait to all exceptions
|
31
|
+
# exceptions will not have the event trait.
|
32
|
+
shape['members'].each do |name, ref|
|
33
|
+
if !!@service.api['shapes'][ref['shape']]['exception']
|
34
|
+
@service.api['shapes'][ref['shape']]['exception_event'] = true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
@service.api['shapes'].inject([]) do |list, (shape_name, shape)|
|
40
|
+
# APIG model can have input/output shape with downcase and '__'
|
41
|
+
if @service.protocol == 'api-gateway'
|
42
|
+
shape_name = lstrip_prefix(upcase_first(shape_name))
|
43
|
+
end
|
44
|
+
# eventstream shape will be inheriting from enumerator
|
45
|
+
if shape['eventstream']
|
46
|
+
list
|
47
|
+
elsif shape['type'] == 'structure' && !shape['document']
|
48
|
+
struct_members = struct_members(shape)
|
49
|
+
sensitive_params = struct_members.select(&:sensitive).map do |m|
|
50
|
+
m.member_name.to_sym
|
51
|
+
end
|
52
|
+
list << StructClass.new(
|
53
|
+
class_name: shape_name,
|
54
|
+
members: struct_members,
|
55
|
+
sensitive_params: sensitive_params,
|
56
|
+
documentation: struct_class_docs(shape_name, shape),
|
57
|
+
union: shape['union']
|
58
|
+
)
|
59
|
+
else
|
60
|
+
list
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# return [Array<EventStreamClass>]
|
66
|
+
def eventstreams
|
67
|
+
@service.api['shapes'].inject([]) do |list, (shape_name, shape)|
|
68
|
+
if shape['eventstream']
|
69
|
+
list << EventStreamClass.new(
|
70
|
+
class_name: shape_name,
|
71
|
+
types: struct_members(shape),
|
72
|
+
documentation: eventstream_class_docs(shape_name, shape)
|
73
|
+
)
|
74
|
+
else
|
75
|
+
list
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def struct_members(shape)
|
83
|
+
return if shape['members'].nil?
|
84
|
+
members = shape['members'].map do |member_name, member_ref|
|
85
|
+
sensitive = !!(member_ref['sensitive'] ||
|
86
|
+
@api['shapes'][member_ref['shape']]['sensitive'])
|
87
|
+
StructMember.new(
|
88
|
+
member_name: underscore(member_name),
|
89
|
+
sensitive: sensitive,
|
90
|
+
returns: AwsSdkCodeGenerator::RBS.to_type(member_ref, @api)
|
91
|
+
)
|
92
|
+
end
|
93
|
+
if shape['event'] || shape['exception_event']
|
94
|
+
members << StructMember.new(
|
95
|
+
member_name: 'event_type',
|
96
|
+
returns: 'untyped'
|
97
|
+
)
|
98
|
+
end
|
99
|
+
members
|
100
|
+
end
|
101
|
+
|
102
|
+
def struct_class_docs(shape_name, shape)
|
103
|
+
nil
|
104
|
+
end
|
105
|
+
|
106
|
+
def eventstream_class_docs(shape_name, shape)
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
def eventstream_docs(shape_name)
|
111
|
+
nil
|
112
|
+
end
|
113
|
+
|
114
|
+
def output_example_docs(shape_name, shape)
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
|
118
|
+
def input_example_docs(shape_name, shape)
|
119
|
+
nil
|
120
|
+
end
|
121
|
+
|
122
|
+
def attribute_macros_docs(shape_name)
|
123
|
+
nil
|
124
|
+
end
|
125
|
+
|
126
|
+
def idempotency_token?(member_ref)
|
127
|
+
member_ref['idempotencyToken'] || shape(member_ref)['idempotencyToken']
|
128
|
+
end
|
129
|
+
|
130
|
+
def idempotency_token_msg
|
131
|
+
"<p><b>A suitable default value is auto-generated.</b> You should normally not need to pass this option.</p>"
|
132
|
+
end
|
133
|
+
|
134
|
+
def visit_shapes(shape_ref, shapes)
|
135
|
+
return if shapes.include?(shape_ref['shape']) # recursion
|
136
|
+
shapes << shape_ref['shape']
|
137
|
+
s = shape(shape_ref)
|
138
|
+
raise "cannot locate shape #{shape_ref['shape']}" if s.nil?
|
139
|
+
case s['type']
|
140
|
+
when 'structure'
|
141
|
+
return if s['members'].nil?
|
142
|
+
s['members'].each_pair do |_, member_ref|
|
143
|
+
visit_shapes(member_ref, shapes)
|
144
|
+
end
|
145
|
+
when 'list'
|
146
|
+
visit_shapes(s['member'], shapes)
|
147
|
+
when 'map'
|
148
|
+
visit_shapes(s['key'], shapes)
|
149
|
+
visit_shapes(s['value'], shapes)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def shape(shape_ref)
|
154
|
+
Api.resolve(shape_ref, @api)[1]
|
155
|
+
end
|
156
|
+
|
157
|
+
class EventStreamClass
|
158
|
+
|
159
|
+
def initialize(options)
|
160
|
+
@class_name = options.fetch(:class_name)
|
161
|
+
@types = options.fetch(:types)
|
162
|
+
@documentation = options.fetch(:documentation)
|
163
|
+
if @types.nil? || @types.empty?
|
164
|
+
@empty = true
|
165
|
+
else
|
166
|
+
@empty = false
|
167
|
+
@types.last.last = true
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# @return [String]
|
172
|
+
attr_accessor :class_name
|
173
|
+
|
174
|
+
# @return [Array<StructMember>]
|
175
|
+
attr_accessor :types
|
176
|
+
|
177
|
+
# @return [String, nil]
|
178
|
+
attr_accessor :documentation
|
179
|
+
|
180
|
+
# @return [Boolean]
|
181
|
+
def empty?
|
182
|
+
@empty
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
class StructClass
|
188
|
+
|
189
|
+
def initialize(options)
|
190
|
+
@class_name = options.fetch(:class_name)
|
191
|
+
@members = options.fetch(:members)
|
192
|
+
@documentation = options.fetch(:documentation)
|
193
|
+
@sensitive_params = options.fetch(:sensitive_params)
|
194
|
+
@union = options.fetch(:union)
|
195
|
+
@members << StructMember.new(
|
196
|
+
member_name: :unknown,
|
197
|
+
returns: 'untyped' # FIXME
|
198
|
+
) if @union
|
199
|
+
if @members.nil? || @members.empty?
|
200
|
+
@empty = true
|
201
|
+
else
|
202
|
+
@empty = false
|
203
|
+
@members.last.last = true
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# @return [String]
|
208
|
+
attr_accessor :class_name
|
209
|
+
|
210
|
+
# @return [Array<StructMember>]
|
211
|
+
attr_accessor :members
|
212
|
+
|
213
|
+
# @return [String, nil]
|
214
|
+
attr_accessor :documentation
|
215
|
+
|
216
|
+
# @return [Array<Symbol>]
|
217
|
+
attr_accessor :sensitive_params
|
218
|
+
|
219
|
+
# @return [Boolean]
|
220
|
+
def union?
|
221
|
+
@union
|
222
|
+
end
|
223
|
+
|
224
|
+
# @return [Boolean]
|
225
|
+
def empty?
|
226
|
+
@empty
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
class StructMember
|
231
|
+
def initialize(member_name:, sensitive: false, returns:)
|
232
|
+
@member_name = member_name
|
233
|
+
@member_class_name = AwsSdkCodeGenerator::Helper::pascal_case(@member_name)
|
234
|
+
@sensitive = sensitive
|
235
|
+
@returns = returns
|
236
|
+
@last = false
|
237
|
+
end
|
238
|
+
|
239
|
+
# @return [String]
|
240
|
+
attr_accessor :member_name
|
241
|
+
|
242
|
+
# @return [Boolean]
|
243
|
+
attr_accessor :sensitive
|
244
|
+
|
245
|
+
# @return [String]
|
246
|
+
attr_accessor :member_class_name
|
247
|
+
|
248
|
+
# @return [String]
|
249
|
+
attr_accessor :returns
|
250
|
+
|
251
|
+
# @return [Boolean]
|
252
|
+
attr_accessor :last
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module RBS
|
6
|
+
class WaitersModule < View
|
7
|
+
attr_reader :service_name
|
8
|
+
attr_reader :waiters
|
9
|
+
|
10
|
+
def initialize(service_name:, api:, waiters:)
|
11
|
+
@service_name = service_name
|
12
|
+
@waiters = AwsSdkCodeGenerator::RBS::Waiter.build_list(api: api, waiters: waiters)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [String|nil]
|
16
|
+
def generated_src_warning
|
17
|
+
GENERATED_SRC_WARNING
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -90,6 +90,10 @@ module AwsSdkCodeGenerator
|
|
90
90
|
!@expect['endpoint']['properties']['authSchemes'].empty?
|
91
91
|
end
|
92
92
|
|
93
|
+
def s3_express_auth?
|
94
|
+
expect_auth? && expected_auth['name'] == 'sigv4-s3express'
|
95
|
+
end
|
96
|
+
|
93
97
|
def expected_headers
|
94
98
|
@expect['endpoint']['headers'].map { |k,v| Param.new(k, v.join(",")) }
|
95
99
|
end
|
@@ -137,7 +141,7 @@ module AwsSdkCodeGenerator
|
|
137
141
|
case value
|
138
142
|
when Hash
|
139
143
|
value.each_with_object({}) do |(k, v), o|
|
140
|
-
o[Underscore.underscore(k)] = transform_operation_values(v)
|
144
|
+
o[Underscore.underscore(k).to_sym] = transform_operation_values(v)
|
141
145
|
end
|
142
146
|
when Array
|
143
147
|
value.map { |v| transform_operation_values(v) }
|
@@ -28,14 +28,13 @@ module AwsSdkCodeGenerator
|
|
28
28
|
|
29
29
|
# @return [Array<StructClass>]
|
30
30
|
def structures
|
31
|
-
|
32
|
-
if
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
31
|
+
@service.api['shapes'].each do |_, shape|
|
32
|
+
if shape['eventstream']
|
33
|
+
# add internal exception_event ctrait to all exceptions
|
34
|
+
# exceptions will not have the event trait.
|
35
|
+
shape['members'].each do |name, ref|
|
36
|
+
if !!@service.api['shapes'][ref['shape']]['exception']
|
37
|
+
@service.api['shapes'][ref['shape']]['exception_event'] = true
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
@@ -93,7 +92,7 @@ module AwsSdkCodeGenerator
|
|
93
92
|
sensitive: sensitive
|
94
93
|
)
|
95
94
|
end
|
96
|
-
if shape['event']
|
95
|
+
if shape['event'] || shape['exception_event']
|
97
96
|
members << StructMember.new(member_name: 'event_type')
|
98
97
|
end
|
99
98
|
members
|
@@ -50,7 +50,6 @@ require_relative 'aws-sdk-code-generator/views/docstring'
|
|
50
50
|
require_relative 'aws-sdk-code-generator/views/errors_module'
|
51
51
|
require_relative 'aws-sdk-code-generator/views/features/env'
|
52
52
|
require_relative 'aws-sdk-code-generator/views/features/step_definitions'
|
53
|
-
require_relative 'aws-sdk-code-generator/views/features/smoke_step_definitions'
|
54
53
|
require_relative 'aws-sdk-code-generator/views/features/smoke'
|
55
54
|
require_relative 'aws-sdk-code-generator/views/gemspec'
|
56
55
|
require_relative 'aws-sdk-code-generator/views/resource_class'
|
@@ -76,6 +75,23 @@ require_relative 'aws-sdk-code-generator/yard_option_tag'
|
|
76
75
|
require_relative 'aws-sdk-code-generator/code_builder'
|
77
76
|
require_relative 'aws-sdk-code-generator/gem_builder'
|
78
77
|
|
78
|
+
# RBS
|
79
|
+
require_relative 'aws-sdk-code-generator/rbs'
|
80
|
+
require_relative 'aws-sdk-code-generator/rbs/error_list'
|
81
|
+
require_relative 'aws-sdk-code-generator/rbs/method_signature'
|
82
|
+
require_relative 'aws-sdk-code-generator/rbs/keyword_argument_builder'
|
83
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_action'
|
84
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_association'
|
85
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_batch_action'
|
86
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_client_request'
|
87
|
+
require_relative 'aws-sdk-code-generator/rbs/waiter'
|
88
|
+
require_relative 'aws-sdk-code-generator/views/rbs/client_class'
|
89
|
+
require_relative 'aws-sdk-code-generator/views/rbs/errors_module'
|
90
|
+
require_relative 'aws-sdk-code-generator/views/rbs/resource_class'
|
91
|
+
require_relative 'aws-sdk-code-generator/views/rbs/root_resource_class'
|
92
|
+
require_relative 'aws-sdk-code-generator/views/rbs/types_module'
|
93
|
+
require_relative 'aws-sdk-code-generator/views/rbs/waiters_module'
|
94
|
+
|
79
95
|
module AwsSdkCodeGenerator
|
80
96
|
|
81
97
|
GENERATED_SRC_WARNING = <<-WARNING_TXT
|