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
@@ -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']]['exceptionEvent'] = 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['exceptionEvent']
|
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
|
@@ -106,8 +106,30 @@ module AwsSdkCodeGenerator
|
|
106
106
|
@identifiers.size > 0
|
107
107
|
end
|
108
108
|
|
109
|
+
# @return [Boolean]
|
110
|
+
def customization_file_exists?
|
111
|
+
File.exist?(
|
112
|
+
File.join(
|
113
|
+
Helper.gem_lib_path(gem_name), "#{resource_customization}.rb"
|
114
|
+
)
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
# @return [String]
|
119
|
+
def resource_customization
|
120
|
+
"#{gem_name}/customizations/#{underscored_name}"
|
121
|
+
end
|
122
|
+
|
109
123
|
private
|
110
124
|
|
125
|
+
def gem_name
|
126
|
+
"aws-sdk-#{module_name.split('::').last.downcase}"
|
127
|
+
end
|
128
|
+
|
129
|
+
def underscored_name
|
130
|
+
class_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
|
131
|
+
end
|
132
|
+
|
111
133
|
def build_associations(options)
|
112
134
|
ResourceAssociation.build_list(
|
113
135
|
class_name: options.fetch(:class_name),
|
@@ -53,6 +53,25 @@ module AwsSdkCodeGenerator
|
|
53
53
|
actions? || associations?
|
54
54
|
end
|
55
55
|
|
56
|
+
# @return [Boolean]
|
57
|
+
def customization_file_exists?
|
58
|
+
File.exist?(
|
59
|
+
File.join(
|
60
|
+
Helper.gem_lib_path(gem_name), "#{customization_file_path}.rb"
|
61
|
+
)
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [String]
|
66
|
+
def customization_file_path
|
67
|
+
"#{gem_name}/customizations/resource"
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def gem_name
|
73
|
+
"aws-sdk-#{module_name.split('::').last.downcase}"
|
74
|
+
end
|
56
75
|
end
|
57
76
|
end
|
58
77
|
end
|
@@ -11,9 +11,12 @@ module AwsSdkCodeGenerator
|
|
11
11
|
def initialize(options)
|
12
12
|
@service = options.fetch(:service)
|
13
13
|
@prefix = options.fetch(:prefix)
|
14
|
-
@codegenerated_plugins = options.fetch(:codegenerated_plugins)
|
14
|
+
@codegenerated_plugins = options.fetch(:codegenerated_plugins) || []
|
15
15
|
end
|
16
16
|
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :prefix
|
19
|
+
|
17
20
|
# @return [String|nil]
|
18
21
|
def generated_src_warning
|
19
22
|
return if @service.protocol == 'api-gateway'
|
@@ -60,47 +63,57 @@ module AwsSdkCodeGenerator
|
|
60
63
|
@service.included_in_core?
|
61
64
|
end
|
62
65
|
|
63
|
-
# @return [
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
# @return [String]
|
67
|
+
def service_identifier
|
68
|
+
@service.identifier
|
69
|
+
end
|
70
|
+
|
71
|
+
# @return [Array<Hash>] list of autoload path hashes with :path, :class_name and
|
72
|
+
# :is_plugin keys.
|
73
|
+
def autoloads
|
74
|
+
paths = []
|
75
|
+
paths << auto_load("#{@prefix}/types", :Types)
|
76
|
+
paths << auto_load("#{@prefix}/client_api", :ClientApi)
|
68
77
|
|
69
78
|
# these must be required before the client
|
70
|
-
|
71
|
-
|
79
|
+
paths += @codegenerated_plugins.map do |p|
|
80
|
+
auto_load(p.path, p.class_name.split('::').last, true)
|
72
81
|
end
|
73
82
|
|
74
|
-
paths << "#{@prefix}/client"
|
75
|
-
paths << "#{@prefix}/errors"
|
76
|
-
paths << "#{@prefix}/waiters" if @service.waiters
|
77
|
-
paths << "#{@prefix}/resource"
|
83
|
+
paths << auto_load("#{@prefix}/client", :Client)
|
84
|
+
paths << auto_load("#{@prefix}/errors", :Errors)
|
85
|
+
paths << auto_load("#{@prefix}/waiters", :Waiters) if @service.waiters
|
86
|
+
paths << auto_load("#{@prefix}/resource", :Resource)
|
78
87
|
|
79
88
|
unless @service.legacy_endpoints?
|
80
|
-
paths << "#{@prefix}/endpoint_parameters"
|
81
|
-
paths << "#{@prefix}/endpoint_provider"
|
82
|
-
paths << "#{@prefix}/endpoints"
|
89
|
+
paths << auto_load("#{@prefix}/endpoint_parameters", :EndpointParameters)
|
90
|
+
paths << auto_load("#{@prefix}/endpoint_provider", :EndpointProvider)
|
91
|
+
paths << auto_load("#{@prefix}/endpoints", :Endpoints)
|
83
92
|
end
|
84
93
|
|
85
94
|
if @service.resources && @service.resources['resources']
|
86
95
|
@service.resources['resources'].keys.each do |resource_name|
|
87
96
|
path = "#{@prefix}/#{underscore(resource_name)}"
|
88
|
-
|
89
|
-
raise "resource path conflict for `#{resource_name}'"
|
90
|
-
else
|
91
|
-
paths << path
|
92
|
-
end
|
97
|
+
paths << auto_load(path, resource_name)
|
93
98
|
end
|
94
99
|
end
|
95
|
-
paths << "#{@prefix}/customizations"
|
96
100
|
if @service.api['metadata']['protocolSettings'] &&
|
97
|
-
|
98
|
-
paths << "#{@prefix}/async_client"
|
99
|
-
paths << "#{@prefix}/event_streams"
|
101
|
+
@service.api['metadata']['protocolSettings']['h2'] == 'eventstream'
|
102
|
+
paths << auto_load("#{@prefix}/async_client", :AsyncClient)
|
103
|
+
paths << auto_load("#{@prefix}/event_streams", :EventStreams)
|
100
104
|
elsif eventstream_shape?
|
101
|
-
paths << "#{@prefix}/event_streams"
|
105
|
+
paths << auto_load("#{@prefix}/event_streams", :EventStreams)
|
102
106
|
end
|
103
|
-
|
107
|
+
|
108
|
+
paths
|
109
|
+
end
|
110
|
+
|
111
|
+
def auto_load(path, class_name, is_plugin = false)
|
112
|
+
{
|
113
|
+
file_path: path,
|
114
|
+
class_name: class_name,
|
115
|
+
is_plugin: is_plugin
|
116
|
+
}
|
104
117
|
end
|
105
118
|
|
106
119
|
def example_var_name
|
@@ -108,7 +121,8 @@ module AwsSdkCodeGenerator
|
|
108
121
|
end
|
109
122
|
|
110
123
|
def example_operation_name
|
111
|
-
raise
|
124
|
+
raise 'no operations found for the service' if @service.api['operations'].empty?
|
125
|
+
|
112
126
|
underscore(@service.api['operations'].keys.first)
|
113
127
|
end
|
114
128
|
|
@@ -51,9 +51,9 @@ module AwsSdkCodeGenerator
|
|
51
51
|
operation_name: Underscore.underscore(
|
52
52
|
operation_inputs_test['operationName']
|
53
53
|
),
|
54
|
-
operation_params: operation_inputs_test['operationParams'] ||
|
55
|
-
built_in_params: operation_inputs_test['builtInParams'] ||
|
56
|
-
client_params: operation_inputs_test['clientParams'] ||
|
54
|
+
operation_params: operation_inputs_test['operationParams'] || {},
|
55
|
+
built_in_params: operation_inputs_test['builtInParams'] || {},
|
56
|
+
client_params: operation_inputs_test['clientParams'] || {}
|
57
57
|
)
|
58
58
|
end
|
59
59
|
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
|
@@ -113,12 +117,13 @@ module AwsSdkCodeGenerator
|
|
113
117
|
@client_params = options[:client_params].map do |k,v|
|
114
118
|
Param.new(Underscore.underscore(k), v)
|
115
119
|
end
|
116
|
-
|
117
120
|
@client_params += options[:built_in_params].map do |k,v|
|
118
121
|
built_in_to_param(k, v)
|
119
122
|
end
|
120
|
-
# the expected default of UseGlobalEndpoint
|
121
|
-
|
123
|
+
# the expected default of UseGlobalEndpoint in rules
|
124
|
+
# does not match the Ruby SDK's default value
|
125
|
+
if @service.identifier == 's3' &&
|
126
|
+
!options[:built_in_params].include?('AWS::S3::UseGlobalEndpoint')
|
122
127
|
@client_params << built_in_to_param('AWS::S3::UseGlobalEndpoint', false)
|
123
128
|
end
|
124
129
|
end
|
@@ -137,7 +142,7 @@ module AwsSdkCodeGenerator
|
|
137
142
|
case value
|
138
143
|
when Hash
|
139
144
|
value.each_with_object({}) do |(k, v), o|
|
140
|
-
o[Underscore.underscore(k)] = transform_operation_values(v)
|
145
|
+
o[Underscore.underscore(k).to_sym] = transform_operation_values(v)
|
141
146
|
end
|
142
147
|
when Array
|
143
148
|
value.map { |v| transform_operation_values(v) }
|
@@ -154,6 +159,14 @@ module AwsSdkCodeGenerator
|
|
154
159
|
Param.new('use_fips_endpoint', value)
|
155
160
|
when 'AWS::UseDualStack'
|
156
161
|
Param.new('use_dualstack_endpoint', value)
|
162
|
+
when 'AWS::Auth::AccountId'
|
163
|
+
Param.new(
|
164
|
+
'credentials',
|
165
|
+
"Aws::Credentials.new('stubbed-akid', 'stubbed-secret', account_id: '#{value}')",
|
166
|
+
true
|
167
|
+
)
|
168
|
+
when 'AWS::Auth::AccountIdEndpointMode'
|
169
|
+
Param.new('account_id_endpoint_mode', value)
|
157
170
|
when 'AWS::STS::UseGlobalEndpoint'
|
158
171
|
Param.new('sts_regional_endpoints', value ? 'legacy' : 'regional')
|
159
172
|
when 'AWS::S3::UseGlobalEndpoint'
|
@@ -162,9 +175,7 @@ module AwsSdkCodeGenerator
|
|
162
175
|
Param.new('use_accelerate_endpoint', value)
|
163
176
|
when 'AWS::S3::ForcePathStyle'
|
164
177
|
Param.new('force_path_style', value)
|
165
|
-
when 'AWS::S3::UseArnRegion'
|
166
|
-
Param.new('s3_use_arn_region', value)
|
167
|
-
when 'AWS::S3Control::UseArnRegion'
|
178
|
+
when 'AWS::S3::UseArnRegion', 'AWS::S3Control::UseArnRegion'
|
168
179
|
Param.new('s3_use_arn_region', value)
|
169
180
|
when 'AWS::S3::DisableMultiRegionAccessPoints'
|
170
181
|
Param.new('s3_disable_multiregion_access_points', value)
|
@@ -177,14 +188,16 @@ module AwsSdkCodeGenerator
|
|
177
188
|
end
|
178
189
|
|
179
190
|
class Param
|
180
|
-
def initialize(param, value)
|
191
|
+
def initialize(param, value, literal = false)
|
181
192
|
@param = param
|
182
193
|
@value = value
|
194
|
+
@literal = literal
|
183
195
|
end
|
196
|
+
|
184
197
|
attr_accessor :param
|
185
198
|
|
186
199
|
def value
|
187
|
-
if @value.is_a?
|
200
|
+
if @value.is_a?(String) && !@literal
|
188
201
|
"'#{@value}'"
|
189
202
|
else
|
190
203
|
@value
|
@@ -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']]['exceptionEvent'] = true
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
@@ -81,19 +80,43 @@ module AwsSdkCodeGenerator
|
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
83
|
+
# @return [Array<String>]
|
84
|
+
def types_customizations
|
85
|
+
Dir.glob(File.join(Helper.gem_lib_path(gem_name), "#{gem_name}/customizations/types", '*.rb')).map do |file|
|
86
|
+
filename = File.basename(file, '.rb')
|
87
|
+
"#{gem_name}/customizations/types/#{filename}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
84
91
|
private
|
85
92
|
|
93
|
+
def gem_name
|
94
|
+
"aws-sdk-#{module_name.split('::').last.downcase}"
|
95
|
+
end
|
96
|
+
|
86
97
|
def struct_members(shape)
|
87
98
|
return if shape['members'].nil?
|
88
99
|
members = shape['members'].map do |member_name, member_ref|
|
100
|
+
member_target = @api['shapes'][member_ref['shape']]
|
89
101
|
sensitive = !!(member_ref['sensitive'] ||
|
90
|
-
|
102
|
+
member_target['sensitive'])
|
103
|
+
|
104
|
+
case member_target["type"]
|
105
|
+
when 'map'
|
106
|
+
key_shape = @api['shapes'][member_target['key']['shape']]
|
107
|
+
value_shape = @api['shapes'][member_target['value']['shape']]
|
108
|
+
sensitive ||= !!(key_shape['sensitive'] || value_shape['sensitive'])
|
109
|
+
when 'list'
|
110
|
+
list_member = @api['shapes'][member_target['member']['shape']]
|
111
|
+
sensitive ||= !!(list_member['sensitive'])
|
112
|
+
end
|
113
|
+
|
91
114
|
StructMember.new(
|
92
115
|
member_name: underscore(member_name),
|
93
116
|
sensitive: sensitive
|
94
117
|
)
|
95
118
|
end
|
96
|
-
if shape['event']
|
119
|
+
if shape['event'] || shape['exceptionEvent']
|
97
120
|
members << StructMember.new(member_name: 'event_type')
|
98
121
|
end
|
99
122
|
members
|
@@ -181,7 +204,7 @@ module AwsSdkCodeGenerator
|
|
181
204
|
|
182
205
|
def see_also_tag(shape_name)
|
183
206
|
uid = @api['metadata']['uid']
|
184
|
-
if @
|
207
|
+
if @service.protocol != 'api-gateway' && Crosslink.taggable?(uid)
|
185
208
|
Crosslink.tag_string(uid, shape_name)
|
186
209
|
end
|
187
210
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'aws-sdk-core'
|
4
|
+
|
3
5
|
require_relative 'aws-sdk-code-generator/api'
|
4
6
|
require_relative 'aws-sdk-code-generator/apply_docs'
|
5
7
|
require_relative 'aws-sdk-code-generator/codegenerated_plugin'
|
@@ -10,6 +12,7 @@ require_relative 'aws-sdk-code-generator/error_list'
|
|
10
12
|
require_relative 'aws-sdk-code-generator/client_response_structure_example'
|
11
13
|
require_relative 'aws-sdk-code-generator/crosslink'
|
12
14
|
require_relative 'aws-sdk-code-generator/docstring'
|
15
|
+
require_relative 'aws-sdk-code-generator/endpoint_parameter'
|
13
16
|
require_relative 'aws-sdk-code-generator/hash_formatter'
|
14
17
|
require_relative 'aws-sdk-code-generator/helper'
|
15
18
|
require_relative 'aws-sdk-code-generator/plugin_list'
|
@@ -50,7 +53,6 @@ require_relative 'aws-sdk-code-generator/views/docstring'
|
|
50
53
|
require_relative 'aws-sdk-code-generator/views/errors_module'
|
51
54
|
require_relative 'aws-sdk-code-generator/views/features/env'
|
52
55
|
require_relative 'aws-sdk-code-generator/views/features/step_definitions'
|
53
|
-
require_relative 'aws-sdk-code-generator/views/features/smoke_step_definitions'
|
54
56
|
require_relative 'aws-sdk-code-generator/views/features/smoke'
|
55
57
|
require_relative 'aws-sdk-code-generator/views/gemspec'
|
56
58
|
require_relative 'aws-sdk-code-generator/views/resource_class'
|
@@ -76,6 +78,23 @@ require_relative 'aws-sdk-code-generator/yard_option_tag'
|
|
76
78
|
require_relative 'aws-sdk-code-generator/code_builder'
|
77
79
|
require_relative 'aws-sdk-code-generator/gem_builder'
|
78
80
|
|
81
|
+
# RBS
|
82
|
+
require_relative 'aws-sdk-code-generator/rbs'
|
83
|
+
require_relative 'aws-sdk-code-generator/rbs/error_list'
|
84
|
+
require_relative 'aws-sdk-code-generator/rbs/method_signature'
|
85
|
+
require_relative 'aws-sdk-code-generator/rbs/keyword_argument_builder'
|
86
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_action'
|
87
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_association'
|
88
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_batch_action'
|
89
|
+
require_relative 'aws-sdk-code-generator/rbs/resource_client_request'
|
90
|
+
require_relative 'aws-sdk-code-generator/rbs/waiter'
|
91
|
+
require_relative 'aws-sdk-code-generator/views/rbs/client_class'
|
92
|
+
require_relative 'aws-sdk-code-generator/views/rbs/errors_module'
|
93
|
+
require_relative 'aws-sdk-code-generator/views/rbs/resource_class'
|
94
|
+
require_relative 'aws-sdk-code-generator/views/rbs/root_resource_class'
|
95
|
+
require_relative 'aws-sdk-code-generator/views/rbs/types_module'
|
96
|
+
require_relative 'aws-sdk-code-generator/views/rbs/waiters_module'
|
97
|
+
|
79
98
|
module AwsSdkCodeGenerator
|
80
99
|
|
81
100
|
GENERATED_SRC_WARNING = <<-WARNING_TXT
|
@@ -87,4 +106,13 @@ module AwsSdkCodeGenerator
|
|
87
106
|
# WARNING ABOUT GENERATED CODE
|
88
107
|
WARNING_TXT
|
89
108
|
|
109
|
+
@warnings = []
|
110
|
+
|
111
|
+
class << self
|
112
|
+
attr_reader :warnings
|
113
|
+
def warn(service, type, message)
|
114
|
+
Kernel.warn(message)
|
115
|
+
@warnings << { service: service, type: type, message: message }
|
116
|
+
end
|
117
|
+
end
|
90
118
|
end
|