@@ -8,8 +8,12 @@ class PluginList
8
8
def initialize ( options )
9
9
@aws_sdk_core_lib_path = options . fetch ( :aws_sdk_core_lib_path )
10
10
@plugins = compute_plugins ( options )
11
+ @client_plugins = compute_client_plugins ( options )
11
12
end
12
13
14
+ # @return [Array<Plugin>]
15
+ attr_reader :client_plugins
16
+
13
17
# @return [Enumerable<Plugin>]
14
18
def each ( &block )
15
19
@plugins . each ( &block )
@@ -27,44 +31,74 @@ def compute_plugins(options)
27
31
plugins . delete ( plugin_name )
28
32
end
29
33
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
32
37
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 )
37
42
end
38
43
end
39
44
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
+
40
74
def default_plugins
41
75
{
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"
68
102
}
69
103
end
70
104
@@ -82,18 +116,18 @@ def default_async_plugins
82
116
83
117
def protocol_plugins ( protocol )
84
118
{
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" } ,
91
125
'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"
97
131
} ,
98
132
nil => { }
99
133
} [ protocol ]
@@ -107,7 +141,7 @@ def protocol_plugins(protocol)
107
141
def signature_plugins ( options )
108
142
if !options [ :legacy_endpoints ]
109
143
{
110
- 'Aws::Plugins::Sign' => "#{ core_plugins } /sign.rb"
144
+ 'Aws::Plugins::Sign' => "#{ core_plugins_path } /sign.rb"
111
145
}
112
146
else
113
147
auth_types = [ options . fetch ( :signature_version ) ]
@@ -116,36 +150,27 @@ def signature_plugins(options)
116
150
auth_types . each do |auth_type |
117
151
case auth_type
118
152
when 'v4'
119
- plugins [ 'Aws::Plugins::SignatureV4' ] = "#{ core_plugins } /signature_v4.rb"
153
+ plugins [ 'Aws::Plugins::SignatureV4' ] = "#{ core_plugins_path } /signature_v4.rb"
120
154
when 'v2'
121
- plugins [ 'Aws::Plugins::SignatureV2' ] = "#{ core_plugins } /signature_v2.rb"
155
+ plugins [ 'Aws::Plugins::SignatureV2' ] = "#{ core_plugins_path } /signature_v2.rb"
122
156
when 'bearer'
123
- plugins [ 'Aws::Plugins::BearerAuthorization' ] = "#{ core_plugins } /bearer_authorization.rb"
157
+ plugins [ 'Aws::Plugins::BearerAuthorization' ] = "#{ core_plugins_path } /bearer_authorization.rb"
124
158
end
125
159
end
126
160
plugins
127
161
end
128
162
end
129
163
130
- def core_plugins
164
+ def core_plugins_path
131
165
File . join ( @aws_sdk_core_lib_path , 'aws-sdk-core/plugins' )
132
166
end
133
167
134
- def seahorse_plugins
168
+ def seahorse_plugins_path
135
169
File . join ( @aws_sdk_core_lib_path , 'seahorse/client/plugins' )
136
170
end
137
171
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
-
144
172
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 )
149
174
end
150
175
151
176
class Plugin
0 commit comments