Skip to content

Commit 74feea5

Browse files
authored
Ensure that client plugin options doc are generated (#3223)
1 parent abe3418 commit 74feea5

File tree

5 files changed

+100
-73
lines changed

5 files changed

+100
-73
lines changed

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/client_constructor.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ class ClientConstructor
55

66
# @option options [required, PluginList] :plugins
77
# @option options [required, Array<CodegeneratedPlugin>] :codegenerated_plugins
8-
8+
# @option options [Array<PluginList::Plugin] :client_plugins
99
def initialize(options)
10-
plugin_options = documented_plugin_options(options.fetch(:plugins)) +
10+
plugin_options =
11+
documented_plugin_options(options.fetch(:plugins)) +
1112
documented_plugin_options(options.fetch(:codegenerated_plugins)) +
12-
documented_plugin_options(options.fetch(:default_plugins, []))
13+
documented_plugin_options(options.fetch(:client_plugins, []))
1314
documentation = {}
1415
plugin_options.each do |option|
1516
documentation[option.name] = YardOptionTag.new(

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/plugin_list.rb

Lines changed: 84 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ class PluginList
88
def initialize(options)
99
@aws_sdk_core_lib_path = options.fetch(:aws_sdk_core_lib_path)
1010
@plugins = compute_plugins(options)
11+
@client_plugins = compute_client_plugins(options)
1112
end
1213

14+
# @return [Array<Plugin>]
15+
attr_reader :client_plugins
16+
1317
# @return [Enumerable<Plugin>]
1418
def each(&block)
1519
@plugins.each(&block)
@@ -27,44 +31,74 @@ def compute_plugins(options)
2731
plugins.delete(plugin_name)
2832
end
2933
plugins.map do |class_name, path|
30-
path = File.absolute_path(path)
31-
Kernel.require(path)
34+
compute_plugin(class_name, path)
35+
end
36+
end
3237

33-
Plugin.new(
34-
class_name: class_name,
35-
options: const_get(class_name).options,
36-
path: path)
38+
def compute_client_plugins(options)
39+
plugins = options[:async_client] ? async_client_plugins : base_client_plugins
40+
plugins.map do |class_name, path|
41+
compute_plugin(class_name, path)
3742
end
3843
end
3944

45+
def compute_plugin(class_name, path)
46+
path = File.absolute_path(path)
47+
Kernel.require(path)
48+
49+
Plugin.new(
50+
class_name: class_name,
51+
options: const_get(class_name).options,
52+
path: path
53+
)
54+
end
55+
56+
def async_client_plugins
57+
{
58+
'Seahorse::Client::Plugins::Endpoint' => "#{seahorse_plugins_path}/endpoint.rb",
59+
'Seahorse::Client::Plugins::H2' => "#{seahorse_plugins_path}/h2.rb",
60+
'Seahorse::Client::Plugins::ResponseTarget' => "#{seahorse_plugins_path}/response_target.rb",
61+
}
62+
end
63+
64+
def base_client_plugins
65+
{
66+
'Seahorse::Client::Plugins::Endpoint' => "#{seahorse_plugins_path}/endpoint.rb",
67+
'Seahorse::Client::Plugins::NetHttp' => "#{seahorse_plugins_path}/h2.rb",
68+
'Seahorse::Client::Plugins::RaiseResponseErrors' => "#{seahorse_plugins_path}/raise_response_errors.rb",
69+
'Seahorse::Client::Plugins::ResponseTarget' => "#{seahorse_plugins_path}/response_target.rb",
70+
'Seahorse::Client::Plugins::RequestCallback' => "#{seahorse_plugins_path}/request_callback.rb",
71+
}
72+
end
73+
4074
def default_plugins
4175
{
42-
'Seahorse::Client::Plugins::ContentLength' => "#{seahorse_plugins}/content_length.rb",
43-
'Aws::Plugins::CredentialsConfiguration' => "#{core_plugins}/credentials_configuration.rb",
44-
'Aws::Plugins::Logging' => "#{core_plugins}/logging.rb",
45-
'Aws::Plugins::ParamConverter' => "#{core_plugins}/param_converter.rb",
46-
'Aws::Plugins::ParamValidator' => "#{core_plugins}/param_validator.rb",
47-
'Aws::Plugins::UserAgent' => "#{core_plugins}/user_agent.rb",
48-
'Aws::Plugins::HelpfulSocketErrors' => "#{core_plugins}/helpful_socket_errors.rb",
49-
'Aws::Plugins::RetryErrors' => "#{core_plugins}/retry_errors.rb",
50-
'Aws::Plugins::GlobalConfiguration' => "#{core_plugins}/global_configuration.rb",
51-
'Aws::Plugins::RegionalEndpoint' => "#{core_plugins}/regional_endpoint.rb",
52-
'Aws::Plugins::EndpointDiscovery' => "#{core_plugins}/endpoint_discovery.rb",
53-
'Aws::Plugins::EndpointPattern' => "#{core_plugins}/endpoint_pattern.rb",
54-
'Aws::Plugins::ResponsePaging' => "#{core_plugins}/response_paging.rb",
55-
'Aws::Plugins::StubResponses' => "#{core_plugins}/stub_responses.rb",
56-
'Aws::Plugins::IdempotencyToken' => "#{core_plugins}/idempotency_token.rb",
57-
'Aws::Plugins::InvocationId' => "#{core_plugins}/invocation_id.rb",
58-
'Aws::Plugins::JsonvalueConverter' => "#{core_plugins}/jsonvalue_converter.rb",
59-
'Aws::Plugins::ClientMetricsPlugin' => "#{core_plugins}/client_metrics_plugin.rb",
60-
'Aws::Plugins::ClientMetricsSendPlugin' => "#{core_plugins}/client_metrics_send_plugin.rb",
61-
'Aws::Plugins::TransferEncoding' => "#{core_plugins}/transfer_encoding.rb",
62-
'Aws::Plugins::HttpChecksum' => "#{core_plugins}/http_checksum.rb",
63-
'Aws::Plugins::ChecksumAlgorithm' => "#{core_plugins}/checksum_algorithm.rb",
64-
'Aws::Plugins::RequestCompression' => "#{core_plugins}/request_compression.rb",
65-
'Aws::Plugins::DefaultsMode' => "#{core_plugins}/defaults_mode.rb",
66-
'Aws::Plugins::RecursionDetection' => "#{core_plugins}/recursion_detection.rb",
67-
'Aws::Plugins::Telemetry' => "#{core_plugins}/telemetry.rb"
76+
'Seahorse::Client::Plugins::ContentLength' => "#{seahorse_plugins_path}/content_length.rb",
77+
'Aws::Plugins::CredentialsConfiguration' => "#{core_plugins_path}/credentials_configuration.rb",
78+
'Aws::Plugins::Logging' => "#{core_plugins_path}/logging.rb",
79+
'Aws::Plugins::ParamConverter' => "#{core_plugins_path}/param_converter.rb",
80+
'Aws::Plugins::ParamValidator' => "#{core_plugins_path}/param_validator.rb",
81+
'Aws::Plugins::UserAgent' => "#{core_plugins_path}/user_agent.rb",
82+
'Aws::Plugins::HelpfulSocketErrors' => "#{core_plugins_path}/helpful_socket_errors.rb",
83+
'Aws::Plugins::RetryErrors' => "#{core_plugins_path}/retry_errors.rb",
84+
'Aws::Plugins::GlobalConfiguration' => "#{core_plugins_path}/global_configuration.rb",
85+
'Aws::Plugins::RegionalEndpoint' => "#{core_plugins_path}/regional_endpoint.rb",
86+
'Aws::Plugins::EndpointDiscovery' => "#{core_plugins_path}/endpoint_discovery.rb",
87+
'Aws::Plugins::EndpointPattern' => "#{core_plugins_path}/endpoint_pattern.rb",
88+
'Aws::Plugins::ResponsePaging' => "#{core_plugins_path}/response_paging.rb",
89+
'Aws::Plugins::StubResponses' => "#{core_plugins_path}/stub_responses.rb",
90+
'Aws::Plugins::IdempotencyToken' => "#{core_plugins_path}/idempotency_token.rb",
91+
'Aws::Plugins::InvocationId' => "#{core_plugins_path}/invocation_id.rb",
92+
'Aws::Plugins::JsonvalueConverter' => "#{core_plugins_path}/jsonvalue_converter.rb",
93+
'Aws::Plugins::ClientMetricsPlugin' => "#{core_plugins_path}/client_metrics_plugin.rb",
94+
'Aws::Plugins::ClientMetricsSendPlugin' => "#{core_plugins_path}/client_metrics_send_plugin.rb",
95+
'Aws::Plugins::TransferEncoding' => "#{core_plugins_path}/transfer_encoding.rb",
96+
'Aws::Plugins::HttpChecksum' => "#{core_plugins_path}/http_checksum.rb",
97+
'Aws::Plugins::ChecksumAlgorithm' => "#{core_plugins_path}/checksum_algorithm.rb",
98+
'Aws::Plugins::RequestCompression' => "#{core_plugins_path}/request_compression.rb",
99+
'Aws::Plugins::DefaultsMode' => "#{core_plugins_path}/defaults_mode.rb",
100+
'Aws::Plugins::RecursionDetection' => "#{core_plugins_path}/recursion_detection.rb",
101+
'Aws::Plugins::Telemetry' => "#{core_plugins_path}/telemetry.rb"
68102
}
69103
end
70104

@@ -82,18 +116,18 @@ def default_async_plugins
82116

83117
def protocol_plugins(protocol)
84118
{
85-
'json' => { 'Aws::Plugins::Protocols::JsonRpc' => "#{core_plugins}/protocols/json_rpc.rb" },
86-
'rest-json' => { 'Aws::Plugins::Protocols::RestJson' => "#{core_plugins}/protocols/rest_json.rb" },
87-
'rest-xml' => { 'Aws::Plugins::Protocols::RestXml' => "#{core_plugins}/protocols/rest_xml.rb" },
88-
'query' => { 'Aws::Plugins::Protocols::Query' => "#{core_plugins}/protocols/query.rb" },
89-
'ec2' => { 'Aws::Plugins::Protocols::EC2' => "#{core_plugins}/protocols/ec2.rb" },
90-
'smithy-rpc-v2-cbor' => { 'Aws::Plugins::Protocols::RpcV2' => "#{core_plugins}/protocols/rpc_v2.rb" },
119+
'json' => { 'Aws::Plugins::Protocols::JsonRpc' => "#{core_plugins_path}/protocols/json_rpc.rb" },
120+
'rest-json' => { 'Aws::Plugins::Protocols::RestJson' => "#{core_plugins_path}/protocols/rest_json.rb" },
121+
'rest-xml' => { 'Aws::Plugins::Protocols::RestXml' => "#{core_plugins_path}/protocols/rest_xml.rb" },
122+
'query' => { 'Aws::Plugins::Protocols::Query' => "#{core_plugins_path}/protocols/query.rb" },
123+
'ec2' => { 'Aws::Plugins::Protocols::EC2' => "#{core_plugins_path}/protocols/ec2.rb" },
124+
'smithy-rpc-v2-cbor' => { 'Aws::Plugins::Protocols::RpcV2' => "#{core_plugins_path}/protocols/rpc_v2.rb" },
91125
'api-gateway' => {
92-
'Aws::Plugins::Protocols::ApiGateway' => "#{core_plugins}/protocols/api_gateway.rb",
93-
'Aws::Plugins::ApiKey' => "#{core_plugins}/api_key.rb",
94-
'Aws::Plugins::APIGUserAgent' => "#{core_plugins}/apig_user_agent.rb",
95-
'Aws::Plugins::APIGAuthorizerToken' => "#{core_plugins}/apig_authorizer_token.rb",
96-
'Aws::Plugins::APIGCredentialsConfiguration' => "#{core_plugins}/apig_credentials_configuration.rb"
126+
'Aws::Plugins::Protocols::ApiGateway' => "#{core_plugins_path}/protocols/api_gateway.rb",
127+
'Aws::Plugins::ApiKey' => "#{core_plugins_path}/api_key.rb",
128+
'Aws::Plugins::APIGUserAgent' => "#{core_plugins_path}/apig_user_agent.rb",
129+
'Aws::Plugins::APIGAuthorizerToken' => "#{core_plugins_path}/apig_authorizer_token.rb",
130+
'Aws::Plugins::APIGCredentialsConfiguration' => "#{core_plugins_path}/apig_credentials_configuration.rb"
97131
},
98132
nil => {}
99133
}[protocol]
@@ -107,7 +141,7 @@ def protocol_plugins(protocol)
107141
def signature_plugins(options)
108142
if !options[:legacy_endpoints]
109143
{
110-
'Aws::Plugins::Sign' => "#{core_plugins}/sign.rb"
144+
'Aws::Plugins::Sign' => "#{core_plugins_path}/sign.rb"
111145
}
112146
else
113147
auth_types = [options.fetch(:signature_version)]
@@ -116,36 +150,27 @@ def signature_plugins(options)
116150
auth_types.each do |auth_type|
117151
case auth_type
118152
when 'v4'
119-
plugins['Aws::Plugins::SignatureV4'] = "#{core_plugins}/signature_v4.rb"
153+
plugins['Aws::Plugins::SignatureV4'] = "#{core_plugins_path}/signature_v4.rb"
120154
when 'v2'
121-
plugins['Aws::Plugins::SignatureV2'] = "#{core_plugins}/signature_v2.rb"
155+
plugins['Aws::Plugins::SignatureV2'] = "#{core_plugins_path}/signature_v2.rb"
122156
when 'bearer'
123-
plugins['Aws::Plugins::BearerAuthorization'] = "#{core_plugins}/bearer_authorization.rb"
157+
plugins['Aws::Plugins::BearerAuthorization'] = "#{core_plugins_path}/bearer_authorization.rb"
124158
end
125159
end
126160
plugins
127161
end
128162
end
129163

130-
def core_plugins
164+
def core_plugins_path
131165
File.join(@aws_sdk_core_lib_path, 'aws-sdk-core/plugins')
132166
end
133167

134-
def seahorse_plugins
168+
def seahorse_plugins_path
135169
File.join(@aws_sdk_core_lib_path, 'seahorse/client/plugins')
136170
end
137171

138-
def core_lib
139-
# TODO : may need to register the default plugins directory rather
140-
# than have the hard-coded here as a relative path
141-
File.expand_path('../../../../../gems/aws-sdk-core/lib', __FILE__)
142-
end
143-
144172
def const_get(class_name)
145-
const_names = class_name.split('::')
146-
const_names.inject(Kernel) do |const, const_name|
147-
const.const_get(const_name)
148-
end
173+
Object.const_get(class_name)
149174
end
150175

151176
class Plugin

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/async_client_class.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ def initialize(options)
2424
@gem_version = options.fetch(:gem_version)
2525
@plugins = PluginList.new(options)
2626
@codegenerated_plugins = options.fetch(:codegenerated_plugins, [])
27-
@default_plugins = Seahorse::Client::AsyncBase.plugins.map do |plugin|
28-
PluginList::Plugin.new(class_name: plugin.name, options: plugin.options, path: '')
29-
end
27+
@client_plugins = @plugins.client_plugins
3028
@client_constructor = ClientConstructor.new(
3129
options.merge(
3230
plugins: @plugins,
3331
codegenerated_plugins: @codegenerated_plugins,
34-
default_plugins: @default_plugins))
32+
client_plugins: @client_plugins
33+
)
34+
)
3535
@operations = ClientOperationList.new(options).to_a
3636
end
3737

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/client_class.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def initialize(options)
2727
@gem_version = options.fetch(:gem_version)
2828
@plugins = PluginList.new(options)
2929
@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+
@client_plugins = @plugins.client_plugins
3331
@client_constructor = ClientConstructor.new(
3432
options.merge(
3533
plugins: @plugins,
3634
codegenerated_plugins: @codegenerated_plugins,
37-
default_plugins: @default_plugins))
35+
client_plugins: @client_plugins
36+
)
37+
)
3838
@operations = ClientOperationList.new(options).to_a
3939
@waiters = Waiter.build_list(options[:waiters])
4040
@custom = options.fetch(:custom)
@@ -96,7 +96,6 @@ def waiters_markdown_table
9696
def authorizer?
9797
@custom
9898
end
99-
10099
end
101100
end
102101
end

build_tools/services.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
module BuildTools
66
class ServiceEnumerator
7-
87
include Enumerable
98

109
MANIFEST_PATH = File.expand_path('../../services.json', __FILE__)
@@ -42,6 +41,10 @@ def each(&block)
4241
services.values.each(&block)
4342
end
4443

44+
def reset
45+
@services = nil
46+
end
47+
4548
private
4649

4750
def services
@@ -186,5 +189,4 @@ def eventstream?(api)
186189
end
187190

188191
Services = ServiceEnumerator.new
189-
190192
end

0 commit comments

Comments
 (0)