aws-sdk-code-generator 0.2.4.pre → 0.3.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/client_constructor.rb +4 -1
- data/lib/aws-sdk-code-generator/client_operation_documentation.rb +10 -4
- data/lib/aws-sdk-code-generator/code_builder.rb +78 -9
- data/lib/aws-sdk-code-generator/codegenerated_plugin.rb +34 -0
- data/lib/aws-sdk-code-generator/gem_builder.rb +4 -5
- data/lib/aws-sdk-code-generator/plugin_list.rb +29 -9
- data/lib/aws-sdk-code-generator/service.rb +22 -0
- data/lib/aws-sdk-code-generator/views/async_client_class.rb +6 -2
- data/lib/aws-sdk-code-generator/views/client_api_module.rb +18 -2
- data/lib/aws-sdk-code-generator/views/client_class.rb +7 -2
- data/lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb +80 -0
- data/lib/aws-sdk-code-generator/views/endpoint_provider_class.rb +34 -0
- data/lib/aws-sdk-code-generator/views/endpoints_module.rb +177 -0
- data/lib/aws-sdk-code-generator/views/endpoints_plugin.rb +85 -0
- data/lib/aws-sdk-code-generator/views/gemspec.rb +4 -0
- data/lib/aws-sdk-code-generator/views/service_module.rb +15 -1
- data/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +198 -0
- data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -4
- data/lib/aws-sdk-code-generator/views/types_module.rb +8 -7
- data/lib/aws-sdk-code-generator.rb +6 -0
- data/templates/async_client_class.mustache +2 -2
- data/templates/client_api_module.mustache +7 -0
- data/templates/client_class.mustache +4 -1
- data/templates/endpoint_parameters_class.mustache +50 -0
- data/templates/endpoint_provider_class.mustache +30 -0
- data/templates/endpoints_module.mustache +33 -0
- data/templates/endpoints_plugin.mustache +76 -0
- data/templates/gemspec.mustache +1 -1
- data/templates/spec/endpoint_provider_spec_class.mustache +76 -0
- data/templates/spec/spec_helper.mustache +5 -0
- metadata +14 -3
@@ -0,0 +1,177 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
class EndpointsModule < View
|
6
|
+
# @option options [required, Service] :service
|
7
|
+
def initialize(options)
|
8
|
+
@service = options.fetch(:service)
|
9
|
+
|
10
|
+
@parameters = @service.endpoint_rules.fetch('parameters', {})
|
11
|
+
|
12
|
+
@endpoint_classes = @service.api['operations'].each.with_object([]) do
|
13
|
+
|(name, op), array|
|
14
|
+
array << EndpointClass.new(
|
15
|
+
name: name,
|
16
|
+
parameters: endpoint_parameters_for_operation(op)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Array<EndpointClass>]
|
22
|
+
attr_reader :endpoint_classes
|
23
|
+
|
24
|
+
# @return [String|nil]
|
25
|
+
def generated_src_warning
|
26
|
+
return if @service.protocol == 'api-gateway'
|
27
|
+
GENERATED_SRC_WARNING
|
28
|
+
end
|
29
|
+
|
30
|
+
def module_name
|
31
|
+
@service.module_name
|
32
|
+
end
|
33
|
+
|
34
|
+
class EndpointClass
|
35
|
+
def initialize(options)
|
36
|
+
@name = options[:name]
|
37
|
+
@parameters = options[:parameters]
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
attr_reader :name
|
42
|
+
|
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
|
+
# @return [String]
|
66
|
+
attr_accessor :source
|
67
|
+
|
68
|
+
# @return [Hash]
|
69
|
+
attr_accessor :param_data
|
70
|
+
|
71
|
+
def static_string?
|
72
|
+
@source == 'staticContextParam' && value.is_a?(String)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def endpoint_parameters_for_operation(operation)
|
80
|
+
@parameters.each.with_object([]) do |(param_name, param_data), endpoint_parameters|
|
81
|
+
value, source = endpoint_parameter_value(
|
82
|
+
operation, param_name, param_data
|
83
|
+
)
|
84
|
+
|
85
|
+
endpoint_parameters << EndpointParameter.new(
|
86
|
+
key: Underscore.underscore(param_name),
|
87
|
+
value: value,
|
88
|
+
source: source,
|
89
|
+
param_data: param_data
|
90
|
+
)
|
91
|
+
end
|
92
|
+
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
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
class EndpointsPlugin < View
|
6
|
+
# @option options [required, Service] :service
|
7
|
+
def initialize(options)
|
8
|
+
@service = options.fetch(:service)
|
9
|
+
if (client_options = @service.api['clientContextParams'])
|
10
|
+
endpoint_parameters = @service.endpoint_rules.fetch('parameters', {})
|
11
|
+
|
12
|
+
@endpoint_options = client_options.each.with_object([]) do |(name, _data), array|
|
13
|
+
param_data = endpoint_parameters[name]
|
14
|
+
|
15
|
+
next if param_data['builtIn']
|
16
|
+
|
17
|
+
array << EndpointOption.new(
|
18
|
+
name: Underscore.underscore(name),
|
19
|
+
docstring: param_data['documentation'],
|
20
|
+
doc_type: param_data['type'],
|
21
|
+
default: param_data['default']
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
@endpoint_classes = @service.api['operations'].each.with_object([]) do
|
26
|
+
|(op, _api), array|
|
27
|
+
array << EndpointClass.new(
|
28
|
+
operation_name: Underscore.underscore(op),
|
29
|
+
class_name: op
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Array<EndpointClass>]
|
35
|
+
attr_reader :endpoint_classes
|
36
|
+
|
37
|
+
# @return [Array<EndpointOption>, nil]
|
38
|
+
attr_reader :endpoint_options
|
39
|
+
|
40
|
+
# @return [String|nil]
|
41
|
+
def generated_src_warning
|
42
|
+
return if @service.protocol == 'api-gateway'
|
43
|
+
GENERATED_SRC_WARNING
|
44
|
+
end
|
45
|
+
|
46
|
+
def module_name
|
47
|
+
@service.module_name
|
48
|
+
end
|
49
|
+
|
50
|
+
class EndpointClass
|
51
|
+
def initialize(options)
|
52
|
+
@operation_name = options[:operation_name]
|
53
|
+
@class_name = options[:class_name]
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [String]
|
57
|
+
attr_reader :operation_name
|
58
|
+
|
59
|
+
# @return [String]
|
60
|
+
attr_reader :class_name
|
61
|
+
end
|
62
|
+
|
63
|
+
class EndpointOption
|
64
|
+
def initialize(options)
|
65
|
+
@name = options[:name]
|
66
|
+
@doc_type = options[:doc_type]
|
67
|
+
@default = options[:default].nil? ? 'nil' : options[:default]
|
68
|
+
@docstring = options[:docstring]
|
69
|
+
end
|
70
|
+
|
71
|
+
# @return [String]
|
72
|
+
attr_reader :name
|
73
|
+
|
74
|
+
# @return [String]
|
75
|
+
attr_reader :doc_type
|
76
|
+
|
77
|
+
# @return [Boolean,String]
|
78
|
+
attr_reader :default
|
79
|
+
|
80
|
+
# @return [String]
|
81
|
+
attr_reader :docstring
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -11,6 +11,7 @@ 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
15
|
end
|
15
16
|
|
16
17
|
# @return [String|nil]
|
@@ -56,7 +57,7 @@ module AwsSdkCodeGenerator
|
|
56
57
|
# This is required to support backwards compatibility for SSO which was
|
57
58
|
# moved from the aws-sdk-sso gem into aws-sdk-core.
|
58
59
|
def require_core_guard?
|
59
|
-
|
60
|
+
@service.included_in_core?
|
60
61
|
end
|
61
62
|
|
62
63
|
# @return [Array<String>]
|
@@ -64,10 +65,23 @@ module AwsSdkCodeGenerator
|
|
64
65
|
paths = Set.new
|
65
66
|
paths << "#{@prefix}/types"
|
66
67
|
paths << "#{@prefix}/client_api"
|
68
|
+
|
69
|
+
# these must be required before the client
|
70
|
+
if @codegenerated_plugins
|
71
|
+
paths += @codegenerated_plugins.map { | p| p.path }
|
72
|
+
end
|
73
|
+
|
67
74
|
paths << "#{@prefix}/client"
|
68
75
|
paths << "#{@prefix}/errors"
|
69
76
|
paths << "#{@prefix}/waiters" if @service.waiters
|
70
77
|
paths << "#{@prefix}/resource"
|
78
|
+
|
79
|
+
unless @service.legacy_endpoints?
|
80
|
+
paths << "#{@prefix}/endpoint_parameters"
|
81
|
+
paths << "#{@prefix}/endpoint_provider"
|
82
|
+
paths << "#{@prefix}/endpoints"
|
83
|
+
end
|
84
|
+
|
71
85
|
if @service.resources && @service.resources['resources']
|
72
86
|
@service.resources['resources'].keys.each do |resource_name|
|
73
87
|
path = "#{@prefix}/#{underscore(resource_name)}"
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AwsSdkCodeGenerator
|
4
|
+
module Views
|
5
|
+
module Spec
|
6
|
+
class EndpointProviderSpecClass < View
|
7
|
+
|
8
|
+
# @param [Hash] options
|
9
|
+
# @option options [required, Service] :service
|
10
|
+
def initialize(options)
|
11
|
+
@service = options.fetch(:service)
|
12
|
+
test_cases = @service.endpoint_tests.fetch('testCases', [])
|
13
|
+
@endpoint_tests = test_cases.map do |endpoint_test|
|
14
|
+
EndpointProviderTest.new(
|
15
|
+
service: @service,
|
16
|
+
documentation: endpoint_test['documentation'],
|
17
|
+
params: endpoint_test['params'],
|
18
|
+
tags: endpoint_test['tags'],
|
19
|
+
expect: endpoint_test['expect'],
|
20
|
+
operation_inputs: endpoint_test['operationInputs']
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Array<EndpointProviderTest>]
|
26
|
+
attr_reader :endpoint_tests
|
27
|
+
|
28
|
+
# @return [String|nil]
|
29
|
+
def generated_src_warning
|
30
|
+
return if @service.protocol == 'api-gateway'
|
31
|
+
GENERATED_SRC_WARNING
|
32
|
+
end
|
33
|
+
|
34
|
+
def module_name
|
35
|
+
@service.module_name
|
36
|
+
end
|
37
|
+
|
38
|
+
class EndpointProviderTest
|
39
|
+
def initialize(options)
|
40
|
+
@service = options[:service]
|
41
|
+
@documentation = options[:documentation]
|
42
|
+
@params = options[:params]&.map do |key, value|
|
43
|
+
[Underscore.underscore(key).to_sym, value]
|
44
|
+
end.to_h
|
45
|
+
@tags = options[:tags]
|
46
|
+
@expect = options[:expect]
|
47
|
+
operation_inputs = options[:operation_inputs] || []
|
48
|
+
@operation_inputs = operation_inputs.map do |operation_inputs_test|
|
49
|
+
OperationInputsTest.new(
|
50
|
+
service: @service,
|
51
|
+
operation_name: Underscore.underscore(
|
52
|
+
operation_inputs_test['operationName']
|
53
|
+
),
|
54
|
+
operation_params: operation_inputs_test['operationParams'] || [],
|
55
|
+
built_in_params: operation_inputs_test['builtInParams'] || [],
|
56
|
+
client_params: operation_inputs_test['clientParams'] || []
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [String]
|
62
|
+
attr_reader :documentation
|
63
|
+
|
64
|
+
# @return [Hash<Symbol, String>]
|
65
|
+
attr_reader :params
|
66
|
+
|
67
|
+
# @return [Array<String>]
|
68
|
+
attr_reader :tags
|
69
|
+
|
70
|
+
# @return [Hash]
|
71
|
+
attr_reader :expect
|
72
|
+
|
73
|
+
# # @return [Array<OperationInput>]
|
74
|
+
attr_reader :operation_inputs
|
75
|
+
|
76
|
+
def expect_error?
|
77
|
+
!@expect['error'].nil?
|
78
|
+
end
|
79
|
+
|
80
|
+
def expected_auth
|
81
|
+
if expect_auth?
|
82
|
+
@expect['endpoint']['properties']['authSchemes'].first
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def expect_auth?
|
87
|
+
@expect['endpoint'] &&
|
88
|
+
@expect['endpoint']['properties'] &&
|
89
|
+
@expect['endpoint']['properties']['authSchemes'] &&
|
90
|
+
!@expect['endpoint']['properties']['authSchemes'].empty?
|
91
|
+
end
|
92
|
+
|
93
|
+
def expected_headers
|
94
|
+
@expect['endpoint']['headers'].map { |k,v| Param.new(k, v.join(",")) }
|
95
|
+
end
|
96
|
+
|
97
|
+
def expect_headers?
|
98
|
+
@expect['endpoint'] &&
|
99
|
+
@expect['endpoint']['headers'] &&
|
100
|
+
!@expect['endpoint']['headers'].empty?
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
class OperationInputsTest
|
106
|
+
|
107
|
+
def initialize(options)
|
108
|
+
@service = options[:service]
|
109
|
+
@operation_name = options[:operation_name]
|
110
|
+
@operation_params = options[:operation_params].map do |k,v|
|
111
|
+
Param.new(Underscore.underscore(k), transform_operation_values(v))
|
112
|
+
end
|
113
|
+
@client_params = options[:client_params].map do |k,v|
|
114
|
+
Param.new(Underscore.underscore(k), v)
|
115
|
+
end
|
116
|
+
|
117
|
+
@client_params += options[:built_in_params].map do |k,v|
|
118
|
+
built_in_to_param(k, v)
|
119
|
+
end
|
120
|
+
# the expected default of UseGlobalEndpoint does not match the SDK's default value
|
121
|
+
if @service.identifier == 's3' && !options[:built_in_params].include?('AWS::S3::UseGlobalEndpoint')
|
122
|
+
@client_params << built_in_to_param('AWS::S3::UseGlobalEndpoint', false)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# @return String
|
127
|
+
attr_reader :operation_name
|
128
|
+
|
129
|
+
# @return [Hash<String, String>]
|
130
|
+
attr_reader :operation_params
|
131
|
+
|
132
|
+
# @return [Hash<String, String>]
|
133
|
+
attr_reader :client_params
|
134
|
+
|
135
|
+
private
|
136
|
+
def transform_operation_values(value)
|
137
|
+
case value
|
138
|
+
when Hash
|
139
|
+
value.each_with_object({}) do |(k, v), o|
|
140
|
+
o[Underscore.underscore(k)] = transform_operation_values(v)
|
141
|
+
end
|
142
|
+
when Array
|
143
|
+
value.map { |v| transform_operation_values(v) }
|
144
|
+
else
|
145
|
+
value
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def built_in_to_param(built_in, value)
|
150
|
+
case built_in
|
151
|
+
when 'AWS::Region'
|
152
|
+
Param.new('region', value)
|
153
|
+
when 'AWS::UseFIPS'
|
154
|
+
Param.new('use_fips_endpoint', value)
|
155
|
+
when 'AWS::UseDualStack'
|
156
|
+
Param.new('use_dualstack_endpoint', value)
|
157
|
+
when 'AWS::STS::UseGlobalEndpoint'
|
158
|
+
Param.new('sts_regional_endpoints', value ? 'legacy' : 'regional')
|
159
|
+
when 'AWS::S3::UseGlobalEndpoint'
|
160
|
+
Param.new('s3_us_east_1_regional_endpoint', value ? 'legacy' : 'regional')
|
161
|
+
when 'AWS::S3::Accelerate'
|
162
|
+
Param.new('use_accelerate_endpoint', value)
|
163
|
+
when 'AWS::S3::ForcePathStyle'
|
164
|
+
Param.new('force_path_style', value)
|
165
|
+
when 'AWS::S3::UseArnRegion'
|
166
|
+
Param.new('s3_use_arn_region', value)
|
167
|
+
when 'AWS::S3Control::UseArnRegion'
|
168
|
+
Param.new('s3_use_arn_region', value)
|
169
|
+
when 'AWS::S3::DisableMultiRegionAccessPoints'
|
170
|
+
Param.new('s3_disable_multiregion_access_points', value)
|
171
|
+
when 'SDK::Endpoint'
|
172
|
+
Param.new('endpoint', value)
|
173
|
+
else
|
174
|
+
raise ArgumentError, "#{built_in} not supported."
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
class Param
|
180
|
+
def initialize(param, value)
|
181
|
+
@param = param
|
182
|
+
@value = value
|
183
|
+
end
|
184
|
+
attr_accessor :param
|
185
|
+
|
186
|
+
def value
|
187
|
+
if @value.is_a? String
|
188
|
+
"'#{@value}'"
|
189
|
+
else
|
190
|
+
@value
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -9,13 +9,14 @@ module AwsSdkCodeGenerator
|
|
9
9
|
|
10
10
|
# @param [Hash] options
|
11
11
|
# @option options [required, Service] :service
|
12
|
+
# @option options[required, String] :aws_sdk_core_lib_path
|
12
13
|
def initialize(options)
|
13
|
-
service = options.fetch(:service)
|
14
|
-
@gem_name = service.gem_name
|
15
|
-
@gem_dependencies = service.gem_dependencies.map do |gem_name, _|
|
14
|
+
@service = options.fetch(:service)
|
15
|
+
@gem_name = @service.gem_name
|
16
|
+
@gem_dependencies = @service.gem_dependencies.map do |gem_name, _|
|
16
17
|
{ dependency: gem_name }
|
17
18
|
end
|
18
|
-
@custom = service.protocol == 'api-gateway'
|
19
|
+
@custom = @service.protocol == 'api-gateway'
|
19
20
|
end
|
20
21
|
|
21
22
|
attr_reader :gem_name
|
@@ -27,6 +28,10 @@ module AwsSdkCodeGenerator
|
|
27
28
|
GENERATED_SRC_WARNING
|
28
29
|
end
|
29
30
|
|
31
|
+
def included_in_core
|
32
|
+
@service.included_in_core?
|
33
|
+
end
|
34
|
+
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -141,13 +141,14 @@ module AwsSdkCodeGenerator
|
|
141
141
|
elsif shape['union']
|
142
142
|
"@note #{shape_name} is a union - when making an API calls you"\
|
143
143
|
' must set exactly one of the members.'
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
144
|
+
# This doc block is no longer useful, but keeping for records
|
145
|
+
# else
|
146
|
+
# note = "@note When making an API call, you may pass #{shape_name}\n"
|
147
|
+
# note += " data as a hash:\n\n"
|
148
|
+
# note += ' ' + SyntaxExampleHash.new(
|
149
|
+
# shape: shape(shape_name),
|
150
|
+
# api: @service.api,
|
151
|
+
# ).format(' ')
|
151
152
|
end
|
152
153
|
end
|
153
154
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'aws-sdk-code-generator/api'
|
4
4
|
require_relative 'aws-sdk-code-generator/apply_docs'
|
5
|
+
require_relative 'aws-sdk-code-generator/codegenerated_plugin'
|
5
6
|
require_relative 'aws-sdk-code-generator/client_constructor'
|
6
7
|
require_relative 'aws-sdk-code-generator/client_operation_documentation'
|
7
8
|
require_relative 'aws-sdk-code-generator/client_operation_list'
|
@@ -53,9 +54,14 @@ require_relative 'aws-sdk-code-generator/views/features/smoke_step_definitions'
|
|
53
54
|
require_relative 'aws-sdk-code-generator/views/features/smoke'
|
54
55
|
require_relative 'aws-sdk-code-generator/views/gemspec'
|
55
56
|
require_relative 'aws-sdk-code-generator/views/resource_class'
|
57
|
+
require_relative 'aws-sdk-code-generator/views/endpoint_parameters_class'
|
58
|
+
require_relative 'aws-sdk-code-generator/views/endpoint_provider_class'
|
59
|
+
require_relative 'aws-sdk-code-generator/views/endpoints_module'
|
60
|
+
require_relative 'aws-sdk-code-generator/views/endpoints_plugin'
|
56
61
|
require_relative 'aws-sdk-code-generator/views/root_resource_class'
|
57
62
|
require_relative 'aws-sdk-code-generator/views/service_module'
|
58
63
|
require_relative 'aws-sdk-code-generator/views/spec/spec_helper'
|
64
|
+
require_relative 'aws-sdk-code-generator/views/spec/endpoint_provider_spec_class'
|
59
65
|
require_relative 'aws-sdk-code-generator/views/types_module'
|
60
66
|
require_relative 'aws-sdk-code-generator/views/event_streams_module'
|
61
67
|
require_relative 'aws-sdk-code-generator/views/authorizer_class'
|
@@ -66,11 +66,11 @@ module {{module_name}}
|
|
66
66
|
|
67
67
|
{{#eventstream_input}}
|
68
68
|
req.context[:input_event_stream_handler] = input_event_stream_handler
|
69
|
-
req.handlers.add(Aws::Binary::EncodeHandler, priority:
|
69
|
+
req.handlers.add(Aws::Binary::EncodeHandler, priority: 55)
|
70
70
|
{{/eventstream_input}}
|
71
71
|
{{#eventstream_output}}
|
72
72
|
req.context[:output_event_stream_handler] = output_event_stream_handler
|
73
|
-
req.handlers.add(Aws::Binary::DecodeHandler, priority:
|
73
|
+
req.handlers.add(Aws::Binary::DecodeHandler, priority: 55)
|
74
74
|
{{/eventstream_output}}
|
75
75
|
|
76
76
|
req.send_request(options{{{block_option}}})
|
@@ -44,6 +44,13 @@ module {{module_name}}
|
|
44
44
|
{{#http_checksum_required}}
|
45
45
|
o.http_checksum_required = true
|
46
46
|
{{/http_checksum_required}}
|
47
|
+
{{#http_checksum}}
|
48
|
+
o.http_checksum = {
|
49
|
+
{{#http_checksum}}
|
50
|
+
{{{key}}} => {{{value}}},
|
51
|
+
{{/http_checksum}}
|
52
|
+
}
|
53
|
+
{{/http_checksum}}
|
47
54
|
{{#deprecated}}
|
48
55
|
o.deprecated = true
|
49
56
|
{{/deprecated}}
|
@@ -45,7 +45,7 @@ module {{module_name}}
|
|
45
45
|
# seconds to wait when opening a HTTP session before raising a
|
46
46
|
# `Timeout::Error`.
|
47
47
|
#
|
48
|
-
# @option options [
|
48
|
+
# @option options [Float] :http_read_timeout (60) The default
|
49
49
|
# number of seconds to wait for response data. This value can
|
50
50
|
# safely be set per-request on the session.
|
51
51
|
#
|
@@ -61,6 +61,9 @@ module {{module_name}}
|
|
61
61
|
# disables this behaviour. This value can safely be set per
|
62
62
|
# request on the session.
|
63
63
|
#
|
64
|
+
# @option options [Float] :ssl_timeout (nil) Sets the SSL timeout
|
65
|
+
# in seconds.
|
66
|
+
#
|
64
67
|
# @option options [Boolean] :http_wire_trace (false) When `true`,
|
65
68
|
# HTTP debug output will be sent to the `:logger`.
|
66
69
|
#
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
module {{module_name}}
|
7
|
+
# Endpoint parameters used to influence endpoints per request.
|
8
|
+
#
|
9
|
+
{{#parameters}}
|
10
|
+
{{documentation}}
|
11
|
+
{{/parameters}}
|
12
|
+
EndpointParameters = Struct.new(
|
13
|
+
{{#parameters}}
|
14
|
+
:{{underscore_name}},
|
15
|
+
{{/parameters}}
|
16
|
+
{{^parameters}}
|
17
|
+
nil
|
18
|
+
{{/parameters}}
|
19
|
+
) do
|
20
|
+
include Aws::Structure
|
21
|
+
|
22
|
+
# @api private
|
23
|
+
class << self
|
24
|
+
PARAM_MAP = {
|
25
|
+
{{#parameters}}
|
26
|
+
'{{name}}' => :{{underscore_name}},
|
27
|
+
{{/parameters}}
|
28
|
+
}.freeze
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(options = {})
|
32
|
+
{{#parameters}}
|
33
|
+
self[:{{underscore_name}}] = options[:{{underscore_name}}]
|
34
|
+
{{#default?}}
|
35
|
+
{{#boolean_default?}}
|
36
|
+
self[:{{underscore_name}}] = {{default}} if self[:{{underscore_name}}].nil?
|
37
|
+
{{/boolean_default?}}
|
38
|
+
{{^boolean_default?}}
|
39
|
+
self[:{{underscore_name}}] ||= '{{default}}' if self[:{{underscore_name}}].nil?
|
40
|
+
{{/boolean_default?}}
|
41
|
+
{{/default?}}
|
42
|
+
{{#required}}
|
43
|
+
if self[:{{underscore_name}}].nil?
|
44
|
+
raise ArgumentError, "Missing required EndpointParameter: :{{underscore_name}}"
|
45
|
+
end
|
46
|
+
{{/required}}
|
47
|
+
{{/parameters}}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|