aws-sdk-code-generator 0.4.0.pre → 0.6.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -27,23 +27,26 @@ module AwsSdkCodeGenerator
|
|
27
27
|
SHAPE_KEYS = {
|
28
28
|
# keep
|
29
29
|
'flattened' => true,
|
30
|
-
'timestampFormat' => true,
|
30
|
+
'timestampFormat' => true,
|
31
31
|
'xmlNamespace' => true,
|
32
|
-
'streaming' => true,
|
33
|
-
'requiresLength' => true,
|
34
|
-
'union' => false, # should remain false
|
32
|
+
'streaming' => true,
|
33
|
+
'requiresLength' => true,
|
34
|
+
'union' => false, # handled separately - should remain false
|
35
35
|
'document' => true,
|
36
36
|
'jsonvalue' => true,
|
37
|
+
'error' => true,
|
38
|
+
'locationName' => true,
|
39
|
+
# ignore
|
37
40
|
# event stream modeling
|
38
41
|
'event' => false,
|
39
42
|
'eventstream' => false,
|
40
43
|
'eventheader' => false,
|
41
44
|
'eventpayload' => false,
|
42
|
-
#
|
45
|
+
'exceptionEvent' => false, # internal, exceptions cannot be events
|
46
|
+
# other
|
43
47
|
'synthetic' => false,
|
44
48
|
'box' => false,
|
45
49
|
'fault' => false,
|
46
|
-
'error' => false,
|
47
50
|
'deprecated' => false,
|
48
51
|
'deprecatedMessage' => false,
|
49
52
|
'type' => false,
|
@@ -51,7 +54,6 @@ module AwsSdkCodeGenerator
|
|
51
54
|
'members' => false,
|
52
55
|
'member' => false,
|
53
56
|
'key' => false,
|
54
|
-
'locationName' => false,
|
55
57
|
'value' => false,
|
56
58
|
'required' => false,
|
57
59
|
'enum' => false,
|
@@ -67,27 +69,29 @@ module AwsSdkCodeGenerator
|
|
67
69
|
}
|
68
70
|
|
69
71
|
METADATA_KEYS = {
|
70
|
-
# keep
|
72
|
+
# keep
|
71
73
|
'endpointPrefix' => true,
|
72
74
|
'signatureVersion' => true,
|
75
|
+
'auth' => true,
|
73
76
|
'signingName' => true,
|
74
77
|
'serviceFullName' => true,
|
75
78
|
'protocol' => true,
|
79
|
+
'protocols' => true,
|
76
80
|
'targetPrefix' => true,
|
77
81
|
'jsonVersion' => true,
|
78
82
|
'errorPrefix' => true,
|
79
|
-
'timestampFormat' => true,
|
83
|
+
'timestampFormat' => true,
|
80
84
|
'xmlNamespace' => true,
|
81
|
-
'protocolSettings' => {},
|
85
|
+
'protocolSettings' => {},
|
82
86
|
'serviceId' => true,
|
83
87
|
'apiVersion' => true,
|
84
88
|
'checksumFormat' => true,
|
85
89
|
'globalEndpoint' => true,
|
86
90
|
'serviceAbbreviation' => true,
|
87
91
|
'uid' => true,
|
88
|
-
'awsQueryCompatible' => true,
|
92
|
+
'awsQueryCompatible' => true,
|
89
93
|
# ignore
|
90
|
-
'ripServiceName' =>
|
94
|
+
'ripServiceName' => false
|
91
95
|
}
|
92
96
|
|
93
97
|
# @option options [required, Service] :service
|
@@ -98,6 +102,7 @@ module AwsSdkCodeGenerator
|
|
98
102
|
# @return [String|nil]
|
99
103
|
def generated_src_warning
|
100
104
|
return if @service.protocol == 'api-gateway'
|
105
|
+
|
101
106
|
GENERATED_SRC_WARNING
|
102
107
|
end
|
103
108
|
|
@@ -187,7 +192,11 @@ module AwsSdkCodeGenerator
|
|
187
192
|
value: @service.api['metadata'][key].inspect
|
188
193
|
}
|
189
194
|
elsif METADATA_KEYS[key].nil?
|
190
|
-
|
195
|
+
AwsSdkCodeGenerator.warn(
|
196
|
+
@service.service_id,
|
197
|
+
:invalid_key,
|
198
|
+
"unhandled metadata key `#{key}`"
|
199
|
+
)
|
191
200
|
end
|
192
201
|
end
|
193
202
|
metadata
|
@@ -204,12 +213,18 @@ module AwsSdkCodeGenerator
|
|
204
213
|
if operation.key?('httpChecksum')
|
205
214
|
operation['httpChecksum']['requestAlgorithmMember'] = underscore(operation['httpChecksum']['requestAlgorithmMember']) if operation['httpChecksum']['requestAlgorithmMember']
|
206
215
|
operation['httpChecksum']['requestValidationModeMember'] = underscore(operation['httpChecksum']['requestValidationModeMember']) if operation['httpChecksum']['requestValidationModeMember']
|
207
|
-
|
208
216
|
o.http_checksum = operation['httpChecksum'].inject([]) do |a, (k, v)|
|
209
217
|
a << { key: k.inspect, value: v.inspect }
|
210
218
|
a
|
211
219
|
end
|
212
220
|
end
|
221
|
+
|
222
|
+
if operation.key?('requestcompression')
|
223
|
+
o.request_compression = operation['requestcompression'].each_with_object([]) do |(k, v), arr|
|
224
|
+
arr << { key: k.inspect, value: v.inspect }
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
213
228
|
%w(input output).each do |key|
|
214
229
|
if operation[key]
|
215
230
|
o.shape_references << "o.#{key} = #{operation_ref(operation[key])}"
|
@@ -240,6 +255,8 @@ module AwsSdkCodeGenerator
|
|
240
255
|
end
|
241
256
|
o.authorizer = operation['authorizer'] if operation.key?('authorizer')
|
242
257
|
o.authtype = operation['authtype'] if operation.key?('authtype')
|
258
|
+
o.unsigned_payload = operation['unsignedPayload'] if operation.key?('unsignedPayload')
|
259
|
+
o.auth = operation['auth'] if operation.key?('auth')
|
243
260
|
o.require_apikey = operation['requiresApiKey'] if operation.key?('requiresApiKey')
|
244
261
|
o.pager = pager(operation_name)
|
245
262
|
o.async = @service.protocol_settings['h2'] == 'eventstream' &&
|
@@ -250,6 +267,7 @@ module AwsSdkCodeGenerator
|
|
250
267
|
|
251
268
|
def apig_authorizer
|
252
269
|
return nil unless @service.api.key? 'authorizers'
|
270
|
+
|
253
271
|
@service.api['authorizers'].map do |name, authorizer|
|
254
272
|
Authorizer.new.tap do |a|
|
255
273
|
a.name = name
|
@@ -298,9 +316,16 @@ module AwsSdkCodeGenerator
|
|
298
316
|
args << "name: '#{shape_name}'"
|
299
317
|
shape.each_pair do |key, value|
|
300
318
|
if SHAPE_KEYS[key]
|
319
|
+
# only query protocols have custom error code
|
320
|
+
next if @service.protocol != 'query' && key == 'error'
|
321
|
+
|
301
322
|
args << "#{key}: #{value.inspect}"
|
302
323
|
elsif SHAPE_KEYS[key].nil?
|
303
|
-
|
324
|
+
AwsSdkCodeGenerator.warn(
|
325
|
+
@service.service_id,
|
326
|
+
:invalid_key,
|
327
|
+
"unhandled shape key `#{key}` on `#{shape_name}`"
|
328
|
+
)
|
304
329
|
end
|
305
330
|
end
|
306
331
|
args.join(', ')
|
@@ -491,8 +516,16 @@ module AwsSdkCodeGenerator
|
|
491
516
|
options = {}
|
492
517
|
metadata.each_pair do |key, value|
|
493
518
|
next if key == 'resultWrapper'
|
519
|
+
|
494
520
|
if key == 'locationName'
|
495
|
-
options[:location_name] =
|
521
|
+
options[:location_name] =
|
522
|
+
# use the xmlName on shape if defined
|
523
|
+
if (@service.protocol == 'rest-xml') &&
|
524
|
+
(shape_location_name = @service.api['shapes'][shape_name]['locationName'])
|
525
|
+
shape_location_name.inspect
|
526
|
+
else
|
527
|
+
value.inspect
|
528
|
+
end
|
496
529
|
else
|
497
530
|
options[:metadata] ||= {}
|
498
531
|
options[:metadata][key] = value.inspect
|
@@ -551,6 +584,9 @@ module AwsSdkCodeGenerator
|
|
551
584
|
# @return [Hash]
|
552
585
|
attr_accessor :http_checksum
|
553
586
|
|
587
|
+
# @return [Hash]
|
588
|
+
attr_accessor :request_compression
|
589
|
+
|
554
590
|
# @return [Array<String>]
|
555
591
|
attr_accessor :shape_references
|
556
592
|
|
@@ -572,6 +608,12 @@ module AwsSdkCodeGenerator
|
|
572
608
|
# @return [String,nil]
|
573
609
|
attr_accessor :authtype
|
574
610
|
|
611
|
+
# @return [Boolean,nil]
|
612
|
+
attr_accessor :unsigned_payload
|
613
|
+
|
614
|
+
# @return [Array<String>]
|
615
|
+
attr_accessor :auth
|
616
|
+
|
575
617
|
# @return [Boolean]
|
576
618
|
attr_accessor :endpoint_trait
|
577
619
|
|
@@ -27,10 +27,14 @@ module AwsSdkCodeGenerator
|
|
27
27
|
@gem_version = options.fetch(:gem_version)
|
28
28
|
@plugins = PluginList.new(options)
|
29
29
|
@codegenerated_plugins = options.fetch(:codegenerated_plugins, [])
|
30
|
+
@default_plugins = Seahorse::Client::Base.plugins.map do |plugin|
|
31
|
+
PluginList::Plugin.new(class_name: plugin.name, options: plugin.options, path: '')
|
32
|
+
end
|
30
33
|
@client_constructor = ClientConstructor.new(
|
31
34
|
options.merge(
|
32
35
|
plugins: @plugins,
|
33
|
-
codegenerated_plugins: @codegenerated_plugins
|
36
|
+
codegenerated_plugins: @codegenerated_plugins,
|
37
|
+
default_plugins: @default_plugins))
|
34
38
|
@operations = ClientOperationList.new(options).to_a
|
35
39
|
@waiters = Waiter.build_list(options[:waiters])
|
36
40
|
@custom = options.fetch(:custom)
|
@@ -9,7 +9,7 @@ module AwsSdkCodeGenerator
|
|
9
9
|
@service = options.fetch(:service)
|
10
10
|
if (parameters = @service.endpoint_rules&.fetch('parameters'))
|
11
11
|
@parameters = parameters.map do |k,p|
|
12
|
-
EndpointParameter.new(k, p)
|
12
|
+
EndpointParameter.new(k, p, @service)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -17,6 +17,11 @@ module AwsSdkCodeGenerator
|
|
17
17
|
# @return [Array<EndpointParameter>]
|
18
18
|
attr_reader :parameters
|
19
19
|
|
20
|
+
# @return [Array<EndpointParameter>]
|
21
|
+
def config_parameters
|
22
|
+
parameters.select { |p| p.source == 'config' }
|
23
|
+
end
|
24
|
+
|
20
25
|
# @return [String|nil]
|
21
26
|
def generated_src_warning
|
22
27
|
return if @service.protocol == 'api-gateway'
|
@@ -26,55 +31,6 @@ module AwsSdkCodeGenerator
|
|
26
31
|
def module_name
|
27
32
|
@service.module_name
|
28
33
|
end
|
29
|
-
|
30
|
-
class EndpointParameter
|
31
|
-
def initialize(name, definition={})
|
32
|
-
@name = name
|
33
|
-
@type = definition['type']
|
34
|
-
@built_in = definition['builtIn']
|
35
|
-
@default = definition['default']
|
36
|
-
@required = definition['required']
|
37
|
-
@documentation = "# @!attribute #{underscore_name}\n"
|
38
|
-
if definition['documentation']
|
39
|
-
@documentation += " # #{definition['documentation']}\n"
|
40
|
-
end
|
41
|
-
if deprecated = definition['deprecated']
|
42
|
-
@documentation += " #\n # @deprecated\n"
|
43
|
-
if deprecated['message']
|
44
|
-
@documentation += " # #{deprecated['message']}\n"
|
45
|
-
end
|
46
|
-
if deprecated['since']
|
47
|
-
@documentation += " # Since: #{deprecated['since']}\n"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
@documentation += " #\n # @return [#{@type}]\n #"
|
51
|
-
end
|
52
|
-
|
53
|
-
# @return [String]
|
54
|
-
attr_reader :name
|
55
|
-
|
56
|
-
# @return [String]
|
57
|
-
attr_reader :documentation
|
58
|
-
|
59
|
-
# @return [Boolean]
|
60
|
-
attr_reader :required
|
61
|
-
|
62
|
-
# @return [String,Boolean]
|
63
|
-
attr_reader :default
|
64
|
-
|
65
|
-
def default?
|
66
|
-
!@default.nil?
|
67
|
-
end
|
68
|
-
|
69
|
-
def boolean_default?
|
70
|
-
default? && (@default == true || @default == false)
|
71
|
-
end
|
72
|
-
|
73
|
-
def underscore_name
|
74
|
-
Underscore.underscore(name)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
34
|
end
|
79
35
|
end
|
80
36
|
end
|
@@ -9,6 +9,11 @@ module AwsSdkCodeGenerator
|
|
9
9
|
def initialize(options)
|
10
10
|
@service = options.fetch(:service)
|
11
11
|
@endpoint_rules = @service.endpoint_rules
|
12
|
+
# Used to collect metrics in the generated endpoint provider
|
13
|
+
@has_account_id_endpoint_mode =
|
14
|
+
@endpoint_rules['parameters'].find do |_, param|
|
15
|
+
param['builtIn'] == 'AWS::Auth::AccountIdEndpointMode'
|
16
|
+
end
|
12
17
|
|
13
18
|
version = @endpoint_rules['version']
|
14
19
|
return if version&.match(/^\d+\.\d+$/) # && version == '1.0'
|
@@ -76,6 +81,10 @@ module AwsSdkCodeGenerator
|
|
76
81
|
if endpoint['properties']
|
77
82
|
res << ", properties: #{templated_hash_to_s(endpoint['properties'])}"
|
78
83
|
end
|
84
|
+
if @has_account_id_endpoint_mode
|
85
|
+
account_id_endpoint = endpoint['url'].include?('{AccountId}')
|
86
|
+
res << ", metadata: { account_id_endpoint: #{account_id_endpoint} }"
|
87
|
+
end
|
79
88
|
res << ")\n"
|
80
89
|
indent(res.string, levels)
|
81
90
|
end
|
@@ -10,11 +10,12 @@ module AwsSdkCodeGenerator
|
|
10
10
|
@parameters = @service.endpoint_rules.fetch('parameters', {})
|
11
11
|
|
12
12
|
@endpoint_classes = @service.api['operations'].each.with_object([]) do
|
13
|
-
|(name, op),
|
14
|
-
|
13
|
+
|(name, op), classes|
|
14
|
+
endpoint_class = EndpointClass.new(
|
15
15
|
name: name,
|
16
16
|
parameters: endpoint_parameters_for_operation(op)
|
17
17
|
)
|
18
|
+
classes << endpoint_class unless endpoint_class.parameters.empty?
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -31,147 +32,40 @@ module AwsSdkCodeGenerator
|
|
31
32
|
@service.module_name
|
32
33
|
end
|
33
34
|
|
35
|
+
def operation_specific_parameters?
|
36
|
+
@endpoint_classes.empty?
|
37
|
+
end
|
38
|
+
|
34
39
|
class EndpointClass
|
35
40
|
def initialize(options)
|
36
41
|
@name = options[:name]
|
42
|
+
@operation = Underscore.underscore(@name)
|
37
43
|
@parameters = options[:parameters]
|
38
44
|
end
|
39
45
|
|
40
46
|
# @return [String]
|
41
47
|
attr_reader :name
|
42
48
|
|
43
|
-
# @return [Array<EndpointParameter>]
|
44
|
-
attr_reader :parameters
|
45
|
-
|
46
|
-
def has_endpoint_built_in?
|
47
|
-
parameters.any? { |p| p.param_data['builtIn'] == 'SDK::Endpoint' }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class EndpointParameter
|
52
|
-
def initialize(options)
|
53
|
-
@key = options[:key]
|
54
|
-
@value = options[:value]
|
55
|
-
@source = options[:source]
|
56
|
-
@param_data = options[:param_data]
|
57
|
-
end
|
58
|
-
|
59
|
-
# @return [String]
|
60
|
-
attr_accessor :key
|
61
|
-
|
62
|
-
# @return [String]
|
63
|
-
attr_accessor :value
|
64
|
-
|
65
49
|
# @return [String]
|
66
|
-
|
50
|
+
attr_reader :operation
|
67
51
|
|
68
|
-
# @return [
|
69
|
-
|
70
|
-
|
71
|
-
def static_string?
|
72
|
-
@source == 'staticContextParam' && value.is_a?(String)
|
73
|
-
end
|
52
|
+
# @return [Array<EndpointParameter>]
|
53
|
+
attr_reader :parameters
|
74
54
|
end
|
75
55
|
|
76
|
-
|
77
56
|
private
|
78
57
|
|
79
58
|
def endpoint_parameters_for_operation(operation)
|
80
|
-
@parameters.each.with_object([]) do |(param_name, param_data),
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
key: Underscore.underscore(param_name),
|
87
|
-
value: value,
|
88
|
-
source: source,
|
89
|
-
param_data: param_data
|
59
|
+
@parameters.each.with_object([]) do |(param_name, param_data), parameters|
|
60
|
+
p = EndpointParameter.new(
|
61
|
+
param_name,
|
62
|
+
param_data,
|
63
|
+
@service,
|
64
|
+
operation
|
90
65
|
)
|
66
|
+
parameters << p if p.source == 'operation'
|
91
67
|
end
|
92
68
|
end
|
93
|
-
|
94
|
-
# Most to least
|
95
|
-
# staticContextParams
|
96
|
-
# contextParam
|
97
|
-
# clientContextParams
|
98
|
-
# Built-In Bindings
|
99
|
-
# Built-in binding default values
|
100
|
-
def endpoint_parameter_value(operation, param_name, param_data)
|
101
|
-
value, source = [
|
102
|
-
static_context_param(operation, param_name), 'staticContextParam'
|
103
|
-
]
|
104
|
-
value, source = [
|
105
|
-
context_param_value(operation, param_name), 'contextParam'
|
106
|
-
] unless value
|
107
|
-
value, source = [
|
108
|
-
client_context_param_value(param_name, param_data),
|
109
|
-
'clientContextParam'
|
110
|
-
] unless value
|
111
|
-
value, source = [
|
112
|
-
built_in_client_context_param_value(param_data), 'builtIn'
|
113
|
-
] unless value
|
114
|
-
|
115
|
-
[value || 'nil', source]
|
116
|
-
end
|
117
|
-
|
118
|
-
def client_context_param_value(param_name, param_data)
|
119
|
-
if @service.api['clientContextParams']&.key?(param_name) &&
|
120
|
-
!param_data['builtIn']
|
121
|
-
"context.config.#{Underscore.underscore(param_name)}"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def built_in_client_context_param_value(param_data)
|
126
|
-
case param_data['builtIn']
|
127
|
-
when 'AWS::Region'
|
128
|
-
'context.config.region'
|
129
|
-
when 'AWS::UseFIPS'
|
130
|
-
'context.config.use_fips_endpoint'
|
131
|
-
when 'AWS::UseDualStack'
|
132
|
-
if @service.name == 'S3' || @service.name == 'S3Control'
|
133
|
-
'context[:use_dualstack_endpoint]'
|
134
|
-
else
|
135
|
-
'context.config.use_dualstack_endpoint'
|
136
|
-
end
|
137
|
-
when 'AWS::STS::UseGlobalEndpoint'
|
138
|
-
"context.config.sts_regional_endpoints == 'legacy'"
|
139
|
-
when 'AWS::S3::UseGlobalEndpoint'
|
140
|
-
"context.config.s3_us_east_1_regional_endpoint == 'legacy'"
|
141
|
-
when 'AWS::S3::Accelerate'
|
142
|
-
if @service.name == 'S3' || @service.name == 'S3Control'
|
143
|
-
'context[:use_accelerate_endpoint]'
|
144
|
-
else
|
145
|
-
'context.config.use_accelerate_endpoint'
|
146
|
-
end
|
147
|
-
when 'AWS::S3::ForcePathStyle'
|
148
|
-
'context.config.force_path_style'
|
149
|
-
when 'AWS::S3::UseArnRegion', 'AWS::S3Control::UseArnRegion'
|
150
|
-
'context.config.s3_use_arn_region'
|
151
|
-
when 'AWS::S3::DisableMultiRegionAccessPoints'
|
152
|
-
'context.config.s3_disable_multiregion_access_points'
|
153
|
-
when 'SDK::Endpoint'
|
154
|
-
'endpoint'
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def context_param_value(operation, param_name)
|
159
|
-
return nil unless operation['input']
|
160
|
-
|
161
|
-
input_shape = operation['input']['shape']
|
162
|
-
members = @service.api['shapes'][input_shape].fetch('members', {})
|
163
|
-
members.detect do |(member_name, member)|
|
164
|
-
context_param = member.fetch('contextParam', {})
|
165
|
-
if context_param.fetch('name', nil) == param_name
|
166
|
-
break "context.params[:#{Underscore.underscore(member_name)}]"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def static_context_param(operation, param_name)
|
172
|
-
operation.fetch('staticContextParams', {})
|
173
|
-
.fetch(param_name, {}).fetch('value', nil)
|
174
|
-
end
|
175
69
|
end
|
176
70
|
end
|
177
71
|
end
|
@@ -6,15 +6,25 @@ module AwsSdkCodeGenerator
|
|
6
6
|
# @option options [required, Service] :service
|
7
7
|
def initialize(options)
|
8
8
|
@service = options.fetch(:service)
|
9
|
-
|
10
|
-
|
9
|
+
endpoint_parameters = @service.endpoint_rules.fetch('parameters', {})
|
10
|
+
|
11
|
+
# HACK: AccountIdEndpointMode should likely be a client context
|
12
|
+
# param, but it's a built in that should be per-service.
|
13
|
+
@endpoint_options = []
|
14
|
+
endpoint_parameters.each do |_key, data|
|
15
|
+
next unless data['builtIn'] == 'AWS::Auth::AccountIdEndpointMode'
|
11
16
|
|
12
|
-
@endpoint_options
|
17
|
+
@endpoint_options << account_id_endpoint_mode_option
|
18
|
+
@account_id_endpoint_mode = true
|
19
|
+
end
|
20
|
+
|
21
|
+
if (client_options = @service.api['clientContextParams'])
|
22
|
+
client_options.each do |name, _data|
|
13
23
|
param_data = endpoint_parameters[name]
|
14
24
|
|
15
25
|
next if param_data['builtIn']
|
16
26
|
|
17
|
-
|
27
|
+
@endpoint_options << EndpointOption.new(
|
18
28
|
name: Underscore.underscore(name),
|
19
29
|
docstring: param_data['documentation'],
|
20
30
|
doc_type: param_data['type'],
|
@@ -22,6 +32,7 @@ module AwsSdkCodeGenerator
|
|
22
32
|
)
|
23
33
|
end
|
24
34
|
end
|
35
|
+
|
25
36
|
@endpoint_classes = @service.api['operations'].each.with_object([]) do
|
26
37
|
|(op, _api), array|
|
27
38
|
array << EndpointClass.new(
|
@@ -47,6 +58,37 @@ module AwsSdkCodeGenerator
|
|
47
58
|
@service.module_name
|
48
59
|
end
|
49
60
|
|
61
|
+
def has_account_id_endpoint_mode?
|
62
|
+
@account_id_endpoint_mode
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def account_id_endpoint_mode_option
|
68
|
+
docstring = <<-DOCSTRING.chomp
|
69
|
+
The account ID endpoint mode to use. This can be one of the following values:
|
70
|
+
* `preferred` - The default behavior. Use the account ID endpoint if
|
71
|
+
available, otherwise use the standard endpoint.
|
72
|
+
* `disabled` - Never use the account ID endpoint. Only use the standard
|
73
|
+
endpoint.
|
74
|
+
* `required` - Always use the account ID endpoint. If the account ID
|
75
|
+
cannot be retrieved from credentials, an error is raised.
|
76
|
+
DOCSTRING
|
77
|
+
|
78
|
+
default = <<-DEFAULT.chomp
|
79
|
+
value = ENV['AWS_ACCOUNT_ID_ENDPOINT_MODE']
|
80
|
+
value ||= Aws.shared_config.account_id_endpoint_mode(profile: cfg.profile)
|
81
|
+
value || 'preferred'
|
82
|
+
DEFAULT
|
83
|
+
|
84
|
+
EndpointOption.new(
|
85
|
+
name: 'account_id_endpoint_mode',
|
86
|
+
docstring: docstring,
|
87
|
+
doc_type: 'String',
|
88
|
+
default: default
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
50
92
|
class EndpointClass
|
51
93
|
def initialize(options)
|
52
94
|
@operation_name = options[:operation_name]
|
@@ -23,10 +23,31 @@ module AwsSdkCodeGenerator
|
|
23
23
|
GENERATED_SRC_WARNING
|
24
24
|
end
|
25
25
|
|
26
|
+
# @return [String]
|
26
27
|
def module_name
|
27
28
|
@service.module_name
|
28
29
|
end
|
29
30
|
|
31
|
+
# @return [Boolean]
|
32
|
+
def customization_file_exists?
|
33
|
+
File.exist?(
|
34
|
+
File.join(
|
35
|
+
Helper.gem_lib_path(gem_name), "#{customization_file_path}.rb"
|
36
|
+
)
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def customization_file_path
|
42
|
+
"#{gem_name}/customizations/errors"
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
# @return [String]
|
48
|
+
def gem_name
|
49
|
+
"aws-sdk-#{module_name.split('::').last.downcase}"
|
50
|
+
end
|
30
51
|
end
|
31
52
|
end
|
32
53
|
end
|
@@ -99,9 +99,15 @@ module AwsSdkCodeGenerator
|
|
99
99
|
).to_s
|
100
100
|
end
|
101
101
|
param_hash_str = Docstring.join_docstrings([option_tags], block_comment: false)
|
102
|
+
param_hash =
|
103
|
+
if param_hash_str.nil?
|
104
|
+
'# This event has no members'
|
105
|
+
else
|
106
|
+
Docstring.indent(param_hash_str, ' ')
|
107
|
+
end
|
102
108
|
m << EventEntry.new(
|
103
109
|
name: underscore(n),
|
104
|
-
param_hash:
|
110
|
+
param_hash: param_hash
|
105
111
|
)
|
106
112
|
m
|
107
113
|
end
|