aws-sdk-code-generator 0.2.4.pre → 0.4.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 +253 -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 +12 -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,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
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
|
7
|
+
module {{module_name}}
|
8
|
+
module Endpoints
|
9
|
+
|
10
|
+
{{#endpoint_classes}}
|
11
|
+
class {{name}}
|
12
|
+
def self.build(context)
|
13
|
+
{{#has_endpoint_built_in?}}
|
14
|
+
unless context.config.regional_endpoint
|
15
|
+
endpoint = context.config.endpoint.to_s
|
16
|
+
end
|
17
|
+
{{/has_endpoint_built_in?}}
|
18
|
+
{{module_name}}::EndpointParameters.new(
|
19
|
+
{{#parameters}}
|
20
|
+
{{#static_string?}}
|
21
|
+
{{key}}: "{{{value}}}",
|
22
|
+
{{/static_string?}}
|
23
|
+
{{^static_string?}}
|
24
|
+
{{key}}: {{{value}}},
|
25
|
+
{{/static_string?}}
|
26
|
+
{{/parameters}}
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
{{/endpoint_classes}}
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
|
7
|
+
module {{module_name}}
|
8
|
+
module Plugins
|
9
|
+
class Endpoints < Seahorse::Client::Plugin
|
10
|
+
option(
|
11
|
+
:endpoint_provider,
|
12
|
+
doc_type: '{{module_name}}::EndpointProvider',
|
13
|
+
docstring: 'The endpoint provider used to resolve endpoints. Any '\
|
14
|
+
'object that responds to `#resolve_endpoint(parameters)` '\
|
15
|
+
'where `parameters` is a Struct similar to '\
|
16
|
+
'`{{module_name}}::EndpointParameters`'
|
17
|
+
) do |cfg|
|
18
|
+
{{module_name}}::EndpointProvider.new
|
19
|
+
end
|
20
|
+
|
21
|
+
{{#endpoint_options}}
|
22
|
+
option(
|
23
|
+
:{{name}},
|
24
|
+
doc_type: '{{doc_type}}',
|
25
|
+
default: {{{default}}},
|
26
|
+
docstring: "{{{docstring}}}")
|
27
|
+
|
28
|
+
{{/endpoint_options}}
|
29
|
+
# @api private
|
30
|
+
class Handler < Seahorse::Client::Handler
|
31
|
+
def call(context)
|
32
|
+
# If endpoint was discovered, do not resolve or apply the endpoint.
|
33
|
+
unless context[:discovered_endpoint]
|
34
|
+
params = parameters_for_operation(context)
|
35
|
+
endpoint = context.config.endpoint_provider.resolve_endpoint(params)
|
36
|
+
|
37
|
+
context.http_request.endpoint = endpoint.url
|
38
|
+
apply_endpoint_headers(context, endpoint.headers)
|
39
|
+
end
|
40
|
+
|
41
|
+
context[:endpoint_params] = params
|
42
|
+
context[:auth_scheme] =
|
43
|
+
Aws::Endpoints.resolve_auth_scheme(context, endpoint)
|
44
|
+
|
45
|
+
@handler.call(context)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def apply_endpoint_headers(context, headers)
|
51
|
+
headers.each do |key, values|
|
52
|
+
value = values
|
53
|
+
.compact
|
54
|
+
.map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
|
55
|
+
.join(',')
|
56
|
+
|
57
|
+
context.http_request.headers[key] = value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def parameters_for_operation(context)
|
62
|
+
case context.operation_name
|
63
|
+
{{#endpoint_classes}}
|
64
|
+
when :{{operation_name}}
|
65
|
+
{{module_name}}::Endpoints::{{class_name}}.build(context)
|
66
|
+
{{/endpoint_classes}}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_handlers(handlers, _config)
|
72
|
+
handlers.add(Handler, step: :build, priority: 75)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/templates/gemspec.mustache
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = 'Apache-2.0'
|
15
15
|
spec.email = ['{{email}}']
|
16
16
|
spec.require_paths = ['lib']
|
17
|
-
spec.files = Dir
|
17
|
+
spec.files = Dir{{{files}}}
|
18
18
|
|
19
19
|
{{#metadata}}
|
20
20
|
spec.metadata = {
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
{{#generated_src_warning}}
|
4
|
+
{{generated_src_warning}}
|
5
|
+
{{/generated_src_warning}}
|
6
|
+
|
7
|
+
require_relative 'spec_helper'
|
8
|
+
|
9
|
+
module {{module_name}}
|
10
|
+
describe EndpointProvider do
|
11
|
+
subject { {{module_name}}::EndpointProvider.new }
|
12
|
+
|
13
|
+
{{#endpoint_tests}}
|
14
|
+
context '{{documentation}}' do
|
15
|
+
let(:expected) do
|
16
|
+
{{{expect}}}
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'produces the expected output from the EndpointProvider' do
|
20
|
+
params = EndpointParameters.new(**{{{params}}})
|
21
|
+
{{#expect_error?}}
|
22
|
+
expect do
|
23
|
+
subject.resolve_endpoint(params)
|
24
|
+
end.to raise_error(ArgumentError, expected['error'])
|
25
|
+
{{/expect_error?}}
|
26
|
+
{{^expect_error?}}
|
27
|
+
endpoint = subject.resolve_endpoint(params)
|
28
|
+
expect(endpoint.url).to eq(expected['endpoint']['url'])
|
29
|
+
expect(endpoint.headers).to eq(expected['endpoint']['headers'] || {})
|
30
|
+
expect(endpoint.properties).to eq(expected['endpoint']['properties'] || {})
|
31
|
+
{{/expect_error?}}
|
32
|
+
end
|
33
|
+
{{#operation_inputs}}
|
34
|
+
|
35
|
+
it 'produces the correct output from the client when calling {{operation_name}}' do
|
36
|
+
client = Client.new(
|
37
|
+
{{#client_params}}
|
38
|
+
{{param}}: {{{value}}},
|
39
|
+
{{/client_params}}
|
40
|
+
stub_responses: true
|
41
|
+
)
|
42
|
+
{{#expect_error?}}
|
43
|
+
expect do
|
44
|
+
client.{{operation_name}}(
|
45
|
+
{{#operation_params}}
|
46
|
+
{{param}}: {{{value}}},
|
47
|
+
{{/operation_params}}
|
48
|
+
)
|
49
|
+
end.to raise_error(ArgumentError, expected['error'])
|
50
|
+
{{/expect_error?}}
|
51
|
+
{{^expect_error?}}
|
52
|
+
{{#expect_auth?}}
|
53
|
+
expect_auth({{{expected_auth}}})
|
54
|
+
{{/expect_auth?}}
|
55
|
+
resp = client.{{operation_name}}(
|
56
|
+
{{#operation_params}}
|
57
|
+
{{param}}: {{{value}}},
|
58
|
+
{{/operation_params}}
|
59
|
+
)
|
60
|
+
expected_uri = URI.parse(expected['endpoint']['url'])
|
61
|
+
expect(resp.context.http_request.endpoint.to_s).to include(expected_uri.host)
|
62
|
+
expect(resp.context.http_request.endpoint.to_s).to include(expected_uri.scheme)
|
63
|
+
expect(resp.context.http_request.endpoint.to_s).to include(expected_uri.path)
|
64
|
+
{{#expect_headers?}}
|
65
|
+
{{#expected_headers}}
|
66
|
+
expect(resp.context.http_request.headers['{{param}}']).to eq({{{value}}})
|
67
|
+
{{/expected_headers}}
|
68
|
+
{{/expect_headers?}}
|
69
|
+
{{/expect_error?}}
|
70
|
+
end
|
71
|
+
{{/operation_inputs}}
|
72
|
+
end
|
73
|
+
|
74
|
+
{{/endpoint_tests}}
|
75
|
+
end
|
76
|
+
end
|
@@ -3,7 +3,12 @@
|
|
3
3
|
{{#generated_src_warning}}
|
4
4
|
{{generated_src_warning}}
|
5
5
|
{{/generated_src_warning}}
|
6
|
+
{{#included_in_core}}
|
7
|
+
require_relative '../../shared_spec_helper'
|
8
|
+
{{/included_in_core}}
|
9
|
+
{{^included_in_core}}
|
6
10
|
require_relative '../../aws-sdk-core/spec/shared_spec_helper'
|
11
|
+
{{/included_in_core}}
|
7
12
|
|
8
13
|
$:.unshift(File.expand_path('../../lib', __FILE__))
|
9
14
|
{{#gem_dependencies}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-code-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/aws-sdk-code-generator/client_operation_list.rb
|
54
54
|
- lib/aws-sdk-code-generator/client_response_structure_example.rb
|
55
55
|
- lib/aws-sdk-code-generator/code_builder.rb
|
56
|
+
- lib/aws-sdk-code-generator/codegenerated_plugin.rb
|
56
57
|
- lib/aws-sdk-code-generator/crosslink.rb
|
57
58
|
- lib/aws-sdk-code-generator/docstring.rb
|
58
59
|
- lib/aws-sdk-code-generator/error_list.rb
|
@@ -99,6 +100,10 @@ files:
|
|
99
100
|
- lib/aws-sdk-code-generator/views/client_api_module.rb
|
100
101
|
- lib/aws-sdk-code-generator/views/client_class.rb
|
101
102
|
- lib/aws-sdk-code-generator/views/docstring.rb
|
103
|
+
- lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb
|
104
|
+
- lib/aws-sdk-code-generator/views/endpoint_provider_class.rb
|
105
|
+
- lib/aws-sdk-code-generator/views/endpoints_module.rb
|
106
|
+
- lib/aws-sdk-code-generator/views/endpoints_plugin.rb
|
102
107
|
- lib/aws-sdk-code-generator/views/errors_module.rb
|
103
108
|
- lib/aws-sdk-code-generator/views/event_streams_module.rb
|
104
109
|
- lib/aws-sdk-code-generator/views/features/env.rb
|
@@ -109,6 +114,7 @@ files:
|
|
109
114
|
- lib/aws-sdk-code-generator/views/resource_class.rb
|
110
115
|
- lib/aws-sdk-code-generator/views/root_resource_class.rb
|
111
116
|
- lib/aws-sdk-code-generator/views/service_module.rb
|
117
|
+
- lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb
|
112
118
|
- lib/aws-sdk-code-generator/views/spec/spec_helper.rb
|
113
119
|
- lib/aws-sdk-code-generator/views/types_module.rb
|
114
120
|
- lib/aws-sdk-code-generator/views/version.rb
|
@@ -123,6 +129,10 @@ files:
|
|
123
129
|
- templates/client_class.mustache
|
124
130
|
- templates/code.mustache
|
125
131
|
- templates/documentation.mustache
|
132
|
+
- templates/endpoint_parameters_class.mustache
|
133
|
+
- templates/endpoint_provider_class.mustache
|
134
|
+
- templates/endpoints_module.mustache
|
135
|
+
- templates/endpoints_plugin.mustache
|
126
136
|
- templates/errors_module.mustache
|
127
137
|
- templates/event_streams_module.mustache
|
128
138
|
- templates/features/env.mustache
|
@@ -135,6 +145,7 @@ files:
|
|
135
145
|
- templates/resource_class.mustache
|
136
146
|
- templates/root_resource_class.mustache
|
137
147
|
- templates/service_module.mustache
|
148
|
+
- templates/spec/endpoint_provider_spec_class.mustache
|
138
149
|
- templates/spec/spec_helper.mustache
|
139
150
|
- templates/types_module.mustache
|
140
151
|
- templates/version.mustache
|
@@ -158,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
169
|
- !ruby/object:Gem::Version
|
159
170
|
version: 1.3.1
|
160
171
|
requirements: []
|
161
|
-
rubygems_version: 3.2.
|
172
|
+
rubygems_version: 3.2.22
|
162
173
|
signing_key:
|
163
174
|
specification_version: 4
|
164
175
|
summary: AWS SDK for Ruby - Code Generator
|