@@ -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
0 commit comments