aws-sdk-sqs 1.9.0 → 1.70.0

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.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openssl'
2
4
 
3
5
  module Aws
@@ -50,7 +52,9 @@ module Aws
50
52
 
51
53
  def validate_single_message(body, attributes, response)
52
54
  validate_body(body, response)
53
- validate_attributes(attributes, response) unless attributes.nil?
55
+ unless attributes.nil? || attributes.empty?
56
+ validate_attributes(attributes, response)
57
+ end
54
58
  end
55
59
 
56
60
  def validate_body(body, response)
@@ -117,14 +121,12 @@ module Aws
117
121
  end
118
122
 
119
123
  def mismatch_error_message(section, local_md5, returned_md5, response)
120
- m = "MD5 returned by SQS does not match " <<
121
- "the calculation on the original request. ("
122
-
124
+ m = 'MD5 returned by SQS does not match '\
125
+ 'the calculation on the original request. ('
123
126
  if response.respond_to?(:id) && !response.id.nil?
124
- m << "Message ID: #{response.id}, "
127
+ m = "#{m}Message ID: #{response.id}, "
125
128
  end
126
-
127
- m << "MD5 calculated by the #{section}: " <<
129
+ "#{m}MD5 calculated by the #{section}: "\
128
130
  "'#{local_md5}', MD5 checksum returned: '#{returned_md5}')"
129
131
  end
130
132
  end
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module SQS
3
5
  module Plugins
4
6
  # @api private
5
7
  class QueueUrls < Seahorse::Client::Plugin
6
-
8
+ # Extract region from a provided queue_url
7
9
  class Handler < Seahorse::Client::Handler
8
-
9
10
  def call(context)
10
- if queue_url = context.params[:queue_url]
11
+ if (queue_url = context.params[:queue_url])
11
12
  update_endpoint(context, queue_url)
12
13
  update_region(context, queue_url)
13
14
  end
@@ -19,18 +20,31 @@ module Aws
19
20
  end
20
21
 
21
22
  # If the region in the queue url is not the configured
22
- # region, then we will modify the request to have
23
- # a sigv4 signer for the proper region.
23
+ # region, then we will modify signing to use it
24
24
  def update_region(context, queue_url)
25
- if queue_region = queue_url.to_s.split('.')[1]
26
- if queue_region != context.config.region
27
- config = context.config.dup
28
- config.region = queue_region
29
- config.sigv4_region = queue_region
30
- config.sigv4_signer = Aws::Plugins::SignatureV4.build_signer(config)
31
- context.config = config
25
+ if (queue_region = parse_region(queue_url)) &&
26
+ queue_region != context.config.region
27
+ context[:auth_scheme]['signingRegion'] = queue_region
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ # take the first component after the SQS service component
34
+ # Will return us-east-1 for:
35
+ # https://sqs.us-east-1.amazonaws.com/1234567890/demo
36
+ # https://vpce-x-y.sqs.us-east-1.vpce.amazonaws.com/1234567890/demo
37
+ # Will not return for:
38
+ # https://localstack-sqs.example.dev/queue/example
39
+ def parse_region(url)
40
+ parts = URI.parse(url).host.split('.')
41
+ parts.each_with_index do |part, index|
42
+ if part == 'sqs'
43
+ # assume region is the part right after the 'sqs' part
44
+ return parts[index + 1]
32
45
  end
33
46
  end
47
+ nil # no region found
34
48
  end
35
49
 
36
50
  end