aws-sdk-sqs 1.67.0 → 1.89.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +110 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-sqs/client.rb +206 -105
- data/lib/aws-sdk-sqs/client_api.rb +8 -1
- data/lib/aws-sdk-sqs/customizations.rb +5 -1
- data/lib/aws-sdk-sqs/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-sqs/endpoints.rb +2 -320
- data/lib/aws-sdk-sqs/message.rb +3 -3
- data/lib/aws-sdk-sqs/plugins/endpoints.rb +23 -60
- data/lib/aws-sdk-sqs/plugins/md5s.rb +84 -35
- data/lib/aws-sdk-sqs/queue.rb +72 -30
- data/lib/aws-sdk-sqs/resource.rb +3 -6
- data/lib/aws-sdk-sqs/types.rb +70 -28
- data/lib/aws-sdk-sqs.rb +17 -13
- data/sig/client.rbs +367 -0
- data/sig/errors.rbs +98 -0
- data/sig/message.rbs +73 -0
- data/sig/queue.rbs +164 -0
- data/sig/resource.rbs +108 -0
- data/sig/types.rbs +472 -0
- data/sig/waiters.rbs +13 -0
- metadata +18 -11
@@ -52,15 +52,18 @@ module Aws::SQS
|
|
52
52
|
self[:region] = options[:region]
|
53
53
|
self[:use_dual_stack] = options[:use_dual_stack]
|
54
54
|
self[:use_dual_stack] = false if self[:use_dual_stack].nil?
|
55
|
-
if self[:use_dual_stack].nil?
|
56
|
-
raise ArgumentError, "Missing required EndpointParameter: :use_dual_stack"
|
57
|
-
end
|
58
55
|
self[:use_fips] = options[:use_fips]
|
59
56
|
self[:use_fips] = false if self[:use_fips].nil?
|
60
|
-
if self[:use_fips].nil?
|
61
|
-
raise ArgumentError, "Missing required EndpointParameter: :use_fips"
|
62
|
-
end
|
63
57
|
self[:endpoint] = options[:endpoint]
|
64
58
|
end
|
59
|
+
|
60
|
+
def self.create(config, options={})
|
61
|
+
new({
|
62
|
+
region: config.region,
|
63
|
+
use_dual_stack: config.use_dualstack_endpoint,
|
64
|
+
use_fips: config.use_fips_endpoint,
|
65
|
+
endpoint: (config.endpoint.to_s unless config.regional_endpoint),
|
66
|
+
}.merge(options))
|
67
|
+
end
|
65
68
|
end
|
66
69
|
end
|
@@ -12,327 +12,9 @@ module Aws::SQS
|
|
12
12
|
# @api private
|
13
13
|
module Endpoints
|
14
14
|
|
15
|
-
class AddPermission
|
16
|
-
def self.build(context)
|
17
|
-
unless context.config.regional_endpoint
|
18
|
-
endpoint = context.config.endpoint.to_s
|
19
|
-
end
|
20
|
-
Aws::SQS::EndpointParameters.new(
|
21
|
-
region: context.config.region,
|
22
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
23
|
-
use_fips: context.config.use_fips_endpoint,
|
24
|
-
endpoint: endpoint,
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class CancelMessageMoveTask
|
30
|
-
def self.build(context)
|
31
|
-
unless context.config.regional_endpoint
|
32
|
-
endpoint = context.config.endpoint.to_s
|
33
|
-
end
|
34
|
-
Aws::SQS::EndpointParameters.new(
|
35
|
-
region: context.config.region,
|
36
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
37
|
-
use_fips: context.config.use_fips_endpoint,
|
38
|
-
endpoint: endpoint,
|
39
|
-
)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class ChangeMessageVisibility
|
44
|
-
def self.build(context)
|
45
|
-
unless context.config.regional_endpoint
|
46
|
-
endpoint = context.config.endpoint.to_s
|
47
|
-
end
|
48
|
-
Aws::SQS::EndpointParameters.new(
|
49
|
-
region: context.config.region,
|
50
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
51
|
-
use_fips: context.config.use_fips_endpoint,
|
52
|
-
endpoint: endpoint,
|
53
|
-
)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class ChangeMessageVisibilityBatch
|
58
|
-
def self.build(context)
|
59
|
-
unless context.config.regional_endpoint
|
60
|
-
endpoint = context.config.endpoint.to_s
|
61
|
-
end
|
62
|
-
Aws::SQS::EndpointParameters.new(
|
63
|
-
region: context.config.region,
|
64
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
65
|
-
use_fips: context.config.use_fips_endpoint,
|
66
|
-
endpoint: endpoint,
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class CreateQueue
|
72
|
-
def self.build(context)
|
73
|
-
unless context.config.regional_endpoint
|
74
|
-
endpoint = context.config.endpoint.to_s
|
75
|
-
end
|
76
|
-
Aws::SQS::EndpointParameters.new(
|
77
|
-
region: context.config.region,
|
78
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
79
|
-
use_fips: context.config.use_fips_endpoint,
|
80
|
-
endpoint: endpoint,
|
81
|
-
)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
class DeleteMessage
|
86
|
-
def self.build(context)
|
87
|
-
unless context.config.regional_endpoint
|
88
|
-
endpoint = context.config.endpoint.to_s
|
89
|
-
end
|
90
|
-
Aws::SQS::EndpointParameters.new(
|
91
|
-
region: context.config.region,
|
92
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
93
|
-
use_fips: context.config.use_fips_endpoint,
|
94
|
-
endpoint: endpoint,
|
95
|
-
)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
class DeleteMessageBatch
|
100
|
-
def self.build(context)
|
101
|
-
unless context.config.regional_endpoint
|
102
|
-
endpoint = context.config.endpoint.to_s
|
103
|
-
end
|
104
|
-
Aws::SQS::EndpointParameters.new(
|
105
|
-
region: context.config.region,
|
106
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
107
|
-
use_fips: context.config.use_fips_endpoint,
|
108
|
-
endpoint: endpoint,
|
109
|
-
)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
class DeleteQueue
|
114
|
-
def self.build(context)
|
115
|
-
unless context.config.regional_endpoint
|
116
|
-
endpoint = context.config.endpoint.to_s
|
117
|
-
end
|
118
|
-
Aws::SQS::EndpointParameters.new(
|
119
|
-
region: context.config.region,
|
120
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
121
|
-
use_fips: context.config.use_fips_endpoint,
|
122
|
-
endpoint: endpoint,
|
123
|
-
)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
class GetQueueAttributes
|
128
|
-
def self.build(context)
|
129
|
-
unless context.config.regional_endpoint
|
130
|
-
endpoint = context.config.endpoint.to_s
|
131
|
-
end
|
132
|
-
Aws::SQS::EndpointParameters.new(
|
133
|
-
region: context.config.region,
|
134
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
135
|
-
use_fips: context.config.use_fips_endpoint,
|
136
|
-
endpoint: endpoint,
|
137
|
-
)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
class GetQueueUrl
|
142
|
-
def self.build(context)
|
143
|
-
unless context.config.regional_endpoint
|
144
|
-
endpoint = context.config.endpoint.to_s
|
145
|
-
end
|
146
|
-
Aws::SQS::EndpointParameters.new(
|
147
|
-
region: context.config.region,
|
148
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
149
|
-
use_fips: context.config.use_fips_endpoint,
|
150
|
-
endpoint: endpoint,
|
151
|
-
)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
class ListDeadLetterSourceQueues
|
156
|
-
def self.build(context)
|
157
|
-
unless context.config.regional_endpoint
|
158
|
-
endpoint = context.config.endpoint.to_s
|
159
|
-
end
|
160
|
-
Aws::SQS::EndpointParameters.new(
|
161
|
-
region: context.config.region,
|
162
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
163
|
-
use_fips: context.config.use_fips_endpoint,
|
164
|
-
endpoint: endpoint,
|
165
|
-
)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
class ListMessageMoveTasks
|
170
|
-
def self.build(context)
|
171
|
-
unless context.config.regional_endpoint
|
172
|
-
endpoint = context.config.endpoint.to_s
|
173
|
-
end
|
174
|
-
Aws::SQS::EndpointParameters.new(
|
175
|
-
region: context.config.region,
|
176
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
177
|
-
use_fips: context.config.use_fips_endpoint,
|
178
|
-
endpoint: endpoint,
|
179
|
-
)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
class ListQueueTags
|
184
|
-
def self.build(context)
|
185
|
-
unless context.config.regional_endpoint
|
186
|
-
endpoint = context.config.endpoint.to_s
|
187
|
-
end
|
188
|
-
Aws::SQS::EndpointParameters.new(
|
189
|
-
region: context.config.region,
|
190
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
191
|
-
use_fips: context.config.use_fips_endpoint,
|
192
|
-
endpoint: endpoint,
|
193
|
-
)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
class ListQueues
|
198
|
-
def self.build(context)
|
199
|
-
unless context.config.regional_endpoint
|
200
|
-
endpoint = context.config.endpoint.to_s
|
201
|
-
end
|
202
|
-
Aws::SQS::EndpointParameters.new(
|
203
|
-
region: context.config.region,
|
204
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
205
|
-
use_fips: context.config.use_fips_endpoint,
|
206
|
-
endpoint: endpoint,
|
207
|
-
)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
class PurgeQueue
|
212
|
-
def self.build(context)
|
213
|
-
unless context.config.regional_endpoint
|
214
|
-
endpoint = context.config.endpoint.to_s
|
215
|
-
end
|
216
|
-
Aws::SQS::EndpointParameters.new(
|
217
|
-
region: context.config.region,
|
218
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
219
|
-
use_fips: context.config.use_fips_endpoint,
|
220
|
-
endpoint: endpoint,
|
221
|
-
)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
class ReceiveMessage
|
226
|
-
def self.build(context)
|
227
|
-
unless context.config.regional_endpoint
|
228
|
-
endpoint = context.config.endpoint.to_s
|
229
|
-
end
|
230
|
-
Aws::SQS::EndpointParameters.new(
|
231
|
-
region: context.config.region,
|
232
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
233
|
-
use_fips: context.config.use_fips_endpoint,
|
234
|
-
endpoint: endpoint,
|
235
|
-
)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
class RemovePermission
|
240
|
-
def self.build(context)
|
241
|
-
unless context.config.regional_endpoint
|
242
|
-
endpoint = context.config.endpoint.to_s
|
243
|
-
end
|
244
|
-
Aws::SQS::EndpointParameters.new(
|
245
|
-
region: context.config.region,
|
246
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
247
|
-
use_fips: context.config.use_fips_endpoint,
|
248
|
-
endpoint: endpoint,
|
249
|
-
)
|
250
|
-
end
|
251
|
-
end
|
252
15
|
|
253
|
-
|
254
|
-
|
255
|
-
unless context.config.regional_endpoint
|
256
|
-
endpoint = context.config.endpoint.to_s
|
257
|
-
end
|
258
|
-
Aws::SQS::EndpointParameters.new(
|
259
|
-
region: context.config.region,
|
260
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
261
|
-
use_fips: context.config.use_fips_endpoint,
|
262
|
-
endpoint: endpoint,
|
263
|
-
)
|
264
|
-
end
|
16
|
+
def self.parameters_for_operation(context)
|
17
|
+
Aws::SQS::EndpointParameters.create(context.config)
|
265
18
|
end
|
266
|
-
|
267
|
-
class SendMessageBatch
|
268
|
-
def self.build(context)
|
269
|
-
unless context.config.regional_endpoint
|
270
|
-
endpoint = context.config.endpoint.to_s
|
271
|
-
end
|
272
|
-
Aws::SQS::EndpointParameters.new(
|
273
|
-
region: context.config.region,
|
274
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
275
|
-
use_fips: context.config.use_fips_endpoint,
|
276
|
-
endpoint: endpoint,
|
277
|
-
)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
class SetQueueAttributes
|
282
|
-
def self.build(context)
|
283
|
-
unless context.config.regional_endpoint
|
284
|
-
endpoint = context.config.endpoint.to_s
|
285
|
-
end
|
286
|
-
Aws::SQS::EndpointParameters.new(
|
287
|
-
region: context.config.region,
|
288
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
289
|
-
use_fips: context.config.use_fips_endpoint,
|
290
|
-
endpoint: endpoint,
|
291
|
-
)
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
class StartMessageMoveTask
|
296
|
-
def self.build(context)
|
297
|
-
unless context.config.regional_endpoint
|
298
|
-
endpoint = context.config.endpoint.to_s
|
299
|
-
end
|
300
|
-
Aws::SQS::EndpointParameters.new(
|
301
|
-
region: context.config.region,
|
302
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
303
|
-
use_fips: context.config.use_fips_endpoint,
|
304
|
-
endpoint: endpoint,
|
305
|
-
)
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
class TagQueue
|
310
|
-
def self.build(context)
|
311
|
-
unless context.config.regional_endpoint
|
312
|
-
endpoint = context.config.endpoint.to_s
|
313
|
-
end
|
314
|
-
Aws::SQS::EndpointParameters.new(
|
315
|
-
region: context.config.region,
|
316
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
317
|
-
use_fips: context.config.use_fips_endpoint,
|
318
|
-
endpoint: endpoint,
|
319
|
-
)
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
class UntagQueue
|
324
|
-
def self.build(context)
|
325
|
-
unless context.config.regional_endpoint
|
326
|
-
endpoint = context.config.endpoint.to_s
|
327
|
-
end
|
328
|
-
Aws::SQS::EndpointParameters.new(
|
329
|
-
region: context.config.region,
|
330
|
-
use_dual_stack: context.config.use_dualstack_endpoint,
|
331
|
-
use_fips: context.config.use_fips_endpoint,
|
332
|
-
endpoint: endpoint,
|
333
|
-
)
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
19
|
end
|
338
20
|
end
|
data/lib/aws-sdk-sqs/message.rb
CHANGED
@@ -163,7 +163,7 @@ module Aws::SQS
|
|
163
163
|
queue_url: @queue_url,
|
164
164
|
receipt_handle: @receipt_handle
|
165
165
|
)
|
166
|
-
resp = Aws::Plugins::UserAgent.
|
166
|
+
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
167
167
|
@client.change_message_visibility(options)
|
168
168
|
end
|
169
169
|
resp.data
|
@@ -179,7 +179,7 @@ module Aws::SQS
|
|
179
179
|
queue_url: @queue_url,
|
180
180
|
receipt_handle: @receipt_handle
|
181
181
|
)
|
182
|
-
resp = Aws::Plugins::UserAgent.
|
182
|
+
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
183
183
|
@client.delete_message(options)
|
184
184
|
end
|
185
185
|
resp.data
|
@@ -246,7 +246,7 @@ module Aws::SQS
|
|
246
246
|
receipt_handle: item.receipt_handle
|
247
247
|
}
|
248
248
|
end
|
249
|
-
Aws::Plugins::UserAgent.
|
249
|
+
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
250
250
|
batch[0].client.delete_message_batch(params)
|
251
251
|
end
|
252
252
|
end
|
@@ -14,35 +14,49 @@ module Aws::SQS
|
|
14
14
|
option(
|
15
15
|
:endpoint_provider,
|
16
16
|
doc_type: 'Aws::SQS::EndpointProvider',
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
rbs_type: 'untyped',
|
18
|
+
docstring: <<~DOCS) do |_cfg|
|
19
|
+
The endpoint provider used to resolve endpoints. Any object that responds to
|
20
|
+
`#resolve_endpoint(parameters)` where `parameters` is a Struct similar to
|
21
|
+
`Aws::SQS::EndpointParameters`.
|
22
|
+
DOCS
|
22
23
|
Aws::SQS::EndpointProvider.new
|
23
24
|
end
|
24
25
|
|
25
26
|
# @api private
|
26
27
|
class Handler < Seahorse::Client::Handler
|
27
28
|
def call(context)
|
28
|
-
# If endpoint was discovered, do not resolve or apply the endpoint.
|
29
29
|
unless context[:discovered_endpoint]
|
30
|
-
params = parameters_for_operation(context)
|
30
|
+
params = Aws::SQS::Endpoints.parameters_for_operation(context)
|
31
31
|
endpoint = context.config.endpoint_provider.resolve_endpoint(params)
|
32
32
|
|
33
33
|
context.http_request.endpoint = endpoint.url
|
34
34
|
apply_endpoint_headers(context, endpoint.headers)
|
35
|
+
|
36
|
+
context[:endpoint_params] = params
|
37
|
+
context[:endpoint_properties] = endpoint.properties
|
35
38
|
end
|
36
39
|
|
37
|
-
context[:endpoint_params] = params
|
38
40
|
context[:auth_scheme] =
|
39
41
|
Aws::Endpoints.resolve_auth_scheme(context, endpoint)
|
40
42
|
|
41
|
-
@handler.call(context)
|
43
|
+
with_metrics(context) { @handler.call(context) }
|
42
44
|
end
|
43
45
|
|
44
46
|
private
|
45
47
|
|
48
|
+
def with_metrics(context, &block)
|
49
|
+
metrics = []
|
50
|
+
metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
|
51
|
+
if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
|
52
|
+
metrics << 'SIGV4A_SIGNING'
|
53
|
+
end
|
54
|
+
if context.config.credentials&.credentials&.account_id
|
55
|
+
metrics << 'RESOLVED_ACCOUNT_ID'
|
56
|
+
end
|
57
|
+
Aws::Plugins::UserAgent.metric(*metrics, &block)
|
58
|
+
end
|
59
|
+
|
46
60
|
def apply_endpoint_headers(context, headers)
|
47
61
|
headers.each do |key, values|
|
48
62
|
value = values
|
@@ -53,57 +67,6 @@ module Aws::SQS
|
|
53
67
|
context.http_request.headers[key] = value
|
54
68
|
end
|
55
69
|
end
|
56
|
-
|
57
|
-
def parameters_for_operation(context)
|
58
|
-
case context.operation_name
|
59
|
-
when :add_permission
|
60
|
-
Aws::SQS::Endpoints::AddPermission.build(context)
|
61
|
-
when :cancel_message_move_task
|
62
|
-
Aws::SQS::Endpoints::CancelMessageMoveTask.build(context)
|
63
|
-
when :change_message_visibility
|
64
|
-
Aws::SQS::Endpoints::ChangeMessageVisibility.build(context)
|
65
|
-
when :change_message_visibility_batch
|
66
|
-
Aws::SQS::Endpoints::ChangeMessageVisibilityBatch.build(context)
|
67
|
-
when :create_queue
|
68
|
-
Aws::SQS::Endpoints::CreateQueue.build(context)
|
69
|
-
when :delete_message
|
70
|
-
Aws::SQS::Endpoints::DeleteMessage.build(context)
|
71
|
-
when :delete_message_batch
|
72
|
-
Aws::SQS::Endpoints::DeleteMessageBatch.build(context)
|
73
|
-
when :delete_queue
|
74
|
-
Aws::SQS::Endpoints::DeleteQueue.build(context)
|
75
|
-
when :get_queue_attributes
|
76
|
-
Aws::SQS::Endpoints::GetQueueAttributes.build(context)
|
77
|
-
when :get_queue_url
|
78
|
-
Aws::SQS::Endpoints::GetQueueUrl.build(context)
|
79
|
-
when :list_dead_letter_source_queues
|
80
|
-
Aws::SQS::Endpoints::ListDeadLetterSourceQueues.build(context)
|
81
|
-
when :list_message_move_tasks
|
82
|
-
Aws::SQS::Endpoints::ListMessageMoveTasks.build(context)
|
83
|
-
when :list_queue_tags
|
84
|
-
Aws::SQS::Endpoints::ListQueueTags.build(context)
|
85
|
-
when :list_queues
|
86
|
-
Aws::SQS::Endpoints::ListQueues.build(context)
|
87
|
-
when :purge_queue
|
88
|
-
Aws::SQS::Endpoints::PurgeQueue.build(context)
|
89
|
-
when :receive_message
|
90
|
-
Aws::SQS::Endpoints::ReceiveMessage.build(context)
|
91
|
-
when :remove_permission
|
92
|
-
Aws::SQS::Endpoints::RemovePermission.build(context)
|
93
|
-
when :send_message
|
94
|
-
Aws::SQS::Endpoints::SendMessage.build(context)
|
95
|
-
when :send_message_batch
|
96
|
-
Aws::SQS::Endpoints::SendMessageBatch.build(context)
|
97
|
-
when :set_queue_attributes
|
98
|
-
Aws::SQS::Endpoints::SetQueueAttributes.build(context)
|
99
|
-
when :start_message_move_task
|
100
|
-
Aws::SQS::Endpoints::StartMessageMoveTask.build(context)
|
101
|
-
when :tag_queue
|
102
|
-
Aws::SQS::Endpoints::TagQueue.build(context)
|
103
|
-
when :untag_queue
|
104
|
-
Aws::SQS::Endpoints::UntagQueue.build(context)
|
105
|
-
end
|
106
|
-
end
|
107
70
|
end
|
108
71
|
|
109
72
|
def add_handlers(handlers, _config)
|
@@ -6,7 +6,6 @@ module Aws
|
|
6
6
|
module SQS
|
7
7
|
module Plugins
|
8
8
|
class Md5s < Seahorse::Client::Plugin
|
9
|
-
|
10
9
|
# @api private
|
11
10
|
class Handler < Seahorse::Client::Handler
|
12
11
|
def call(context)
|
@@ -26,16 +25,17 @@ module Aws
|
|
26
25
|
'String' => 1,
|
27
26
|
'Binary' => 2,
|
28
27
|
'Number' => 1
|
29
|
-
}
|
28
|
+
}.freeze
|
30
29
|
|
31
|
-
DATA_TYPE = /\A(String|Binary|Number)(\..+)?\z
|
30
|
+
DATA_TYPE = /\A(String|Binary|Number)(\..+)?\z/.freeze
|
32
31
|
|
33
32
|
NORMALIZED_ENCODING = Encoding::UTF_8
|
34
33
|
|
35
34
|
def validate_send_message(context, response)
|
36
35
|
body = context.params[:message_body]
|
37
36
|
attributes = context.params[:message_attributes]
|
38
|
-
|
37
|
+
system_attributes = context.params[:message_system_attributes]
|
38
|
+
validate_single_message(body, attributes, system_attributes, response)
|
39
39
|
end
|
40
40
|
|
41
41
|
def validate_send_message_batch(context, response)
|
@@ -43,63 +43,87 @@ module Aws
|
|
43
43
|
id = entry[:id]
|
44
44
|
body = entry[:message_body]
|
45
45
|
attributes = entry[:message_attributes]
|
46
|
+
system_attributes = entry[:message_system_attributes]
|
46
47
|
message_response = response.successful.select { |r| r.id == id }[0]
|
47
48
|
unless message_response.nil?
|
48
|
-
validate_single_message(body, attributes, message_response)
|
49
|
+
validate_single_message(body, attributes, system_attributes, message_response)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
def validate_single_message(body, attributes, response)
|
54
|
+
def validate_single_message(body, attributes, system_attributes, response)
|
54
55
|
validate_body(body, response)
|
55
56
|
unless attributes.nil? || attributes.empty?
|
56
57
|
validate_attributes(attributes, response)
|
57
58
|
end
|
59
|
+
unless system_attributes.nil? || system_attributes.empty?
|
60
|
+
validate_system_attributes(system_attributes, response)
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
def validate_body(body, response)
|
61
65
|
calculated_md5 = md5_of_message_body(body)
|
62
66
|
returned_md5 = response.md5_of_message_body
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
return unless calculated_md5 != returned_md5
|
68
|
+
|
69
|
+
error_message = mismatch_error_message(
|
70
|
+
'message body',
|
71
|
+
calculated_md5,
|
72
|
+
returned_md5,
|
73
|
+
response
|
74
|
+
)
|
75
|
+
raise Aws::Errors::ChecksumError, error_message
|
71
76
|
end
|
72
77
|
|
73
78
|
def validate_attributes(attributes, response)
|
74
79
|
calculated_md5 = md5_of_message_attributes(attributes)
|
75
80
|
returned_md5 = response.md5_of_message_attributes
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
return unless returned_md5 != calculated_md5
|
82
|
+
|
83
|
+
error_message = mismatch_error_message(
|
84
|
+
'message attributes',
|
85
|
+
calculated_md5,
|
86
|
+
returned_md5,
|
87
|
+
response
|
88
|
+
)
|
89
|
+
raise Aws::Errors::ChecksumError, error_message
|
90
|
+
end
|
91
|
+
|
92
|
+
def validate_system_attributes(system_attributes, response)
|
93
|
+
calculated_md5 = md5_of_message_system_attributes(system_attributes)
|
94
|
+
returned_md5 = response.md5_of_message_system_attributes
|
95
|
+
return unless returned_md5 != calculated_md5
|
96
|
+
|
97
|
+
error_message = mismatch_error_message(
|
98
|
+
'message system attributes',
|
99
|
+
calculated_md5,
|
100
|
+
returned_md5,
|
101
|
+
response
|
102
|
+
)
|
103
|
+
raise Aws::Errors::ChecksumError, error_message
|
84
104
|
end
|
85
105
|
|
86
106
|
def md5_of_message_body(message_body)
|
87
107
|
OpenSSL::Digest::MD5.hexdigest(message_body)
|
88
108
|
end
|
89
109
|
|
110
|
+
# MD5 of Message Attributes and System Attributes are effectively
|
111
|
+
# the same calculation. However, keeping these as two methods because
|
112
|
+
# they are modeled as two different shapes.
|
113
|
+
###
|
90
114
|
def md5_of_message_attributes(message_attributes)
|
91
|
-
encoded = {
|
115
|
+
encoded = {}
|
92
116
|
message_attributes.each do |name, attribute|
|
93
117
|
name = name.to_s
|
94
118
|
encoded[name] = String.new
|
95
119
|
data_type_without_label = DATA_TYPE.match(attribute[:data_type])[1]
|
96
120
|
encoded[name] << encode_length_and_bytes(name) <<
|
97
|
-
|
98
|
-
|
121
|
+
encode_length_and_bytes(attribute[:data_type]) <<
|
122
|
+
[TRANSPORT_TYPE_ENCODINGS[data_type_without_label]].pack('C')
|
99
123
|
|
100
|
-
if attribute[:string_value]
|
124
|
+
if !attribute[:string_value].nil?
|
101
125
|
encoded[name] << encode_length_and_string(attribute[:string_value])
|
102
|
-
elsif attribute[:binary_value]
|
126
|
+
elsif !attribute[:binary_value].nil?
|
103
127
|
encoded[name] << encode_length_and_bytes(attribute[:binary_value])
|
104
128
|
end
|
105
129
|
end
|
@@ -110,6 +134,30 @@ module Aws
|
|
110
134
|
OpenSSL::Digest::MD5.hexdigest(buffer)
|
111
135
|
end
|
112
136
|
|
137
|
+
def md5_of_message_system_attributes(message_system_attributes)
|
138
|
+
encoded = {}
|
139
|
+
message_system_attributes.each do |name, attribute|
|
140
|
+
name = name.to_s
|
141
|
+
encoded[name] = String.new
|
142
|
+
data_type_without_label = DATA_TYPE.match(attribute[:data_type])[1]
|
143
|
+
encoded[name] << encode_length_and_bytes(name) <<
|
144
|
+
encode_length_and_bytes(attribute[:data_type]) <<
|
145
|
+
[TRANSPORT_TYPE_ENCODINGS[data_type_without_label]].pack('C')
|
146
|
+
|
147
|
+
if !attribute[:string_value].nil?
|
148
|
+
encoded[name] << encode_length_and_string(attribute[:string_value])
|
149
|
+
elsif !attribute[:binary_value].nil?
|
150
|
+
encoded[name] << encode_length_and_bytes(attribute[:binary_value])
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
buffer = encoded.keys.sort.reduce(String.new) do |string, name|
|
155
|
+
string << encoded[name]
|
156
|
+
end
|
157
|
+
OpenSSL::Digest::MD5.hexdigest(buffer)
|
158
|
+
end
|
159
|
+
###
|
160
|
+
|
113
161
|
def encode_length_and_string(string)
|
114
162
|
string = String.new(string)
|
115
163
|
string.encode!(NORMALIZED_ENCODING)
|
@@ -117,7 +165,7 @@ module Aws
|
|
117
165
|
end
|
118
166
|
|
119
167
|
def encode_length_and_bytes(bytes)
|
120
|
-
[bytes.bytesize, bytes].pack('L>a*'
|
168
|
+
[bytes.bytesize, bytes].pack('L>a*')
|
121
169
|
end
|
122
170
|
|
123
171
|
def mismatch_error_message(section, local_md5, returned_md5, response)
|
@@ -154,13 +202,14 @@ not match.
|
|
154
202
|
end
|
155
203
|
|
156
204
|
def add_handlers(handlers, config)
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
205
|
+
return unless config.verify_checksums
|
206
|
+
|
207
|
+
handlers.add(
|
208
|
+
Handler,
|
209
|
+
priority: 10,
|
210
|
+
step: :validate,
|
211
|
+
operations: %i[send_message send_message_batch]
|
212
|
+
)
|
164
213
|
end
|
165
214
|
end
|
166
215
|
end
|