aws-sdk 1.15.0 → 1.16.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.
- checksums.yaml +4 -4
- data/lib/aws/api_config/EC2-2013-02-01.yml +293 -31
- data/lib/aws/core.rb +5 -1
- data/lib/aws/core/configuration.rb +17 -4
- data/lib/aws/core/xml/sax_handlers/nokogiri.rb +1 -0
- data/lib/aws/dynamo_db.rb +8 -0
- data/lib/aws/dynamo_db/table.rb +8 -0
- data/lib/aws/s3/client.rb +84 -0
- data/lib/aws/s3/client/xml.rb +18 -0
- data/lib/aws/s3/object_metadata.rb +7 -0
- data/lib/aws/s3/s3_object.rb +2 -0
- data/lib/aws/simple_workflow/request.rb +5 -1
- data/lib/aws/sqs/config.rb +2 -0
- data/lib/aws/sqs/errors.rb +23 -0
- data/lib/aws/sqs/queue.rb +75 -3
- data/lib/aws/version.rb +1 -1
- metadata +2 -2
data/lib/aws/core.rb
CHANGED
@@ -466,7 +466,11 @@ module AWS
|
|
466
466
|
# that response bodies match the content-length specified in the
|
467
467
|
# response header, if present. Note that some HTTP handlers will
|
468
468
|
# always do this whether or not this value is true.
|
469
|
-
#
|
469
|
+
#
|
470
|
+
# @option options [Boolean] :sqs_verify_checksums (true)
|
471
|
+
# When `true` all SQS operations will check body content against
|
472
|
+
# MD5 checksums, raising an exception if there is a mismatch.
|
473
|
+
#
|
470
474
|
# @return [Core::Configuration] Returns the new configuration.
|
471
475
|
#
|
472
476
|
def config options = {}
|
@@ -182,6 +182,10 @@ module AWS
|
|
182
182
|
# if all SimpleDB read requests should be done consistently.
|
183
183
|
# Consistent reads are slower, but reflect all changes to SDB.
|
184
184
|
#
|
185
|
+
# @attr_reader [Boolean] sqs_verify_checksums (true)
|
186
|
+
# When `true` all SQS operations will check body content against
|
187
|
+
# MD5 checksums, raising an exception if there is a mismatch.
|
188
|
+
#
|
185
189
|
# @attr_reader [CredentialProvider::Provider] credential_provider
|
186
190
|
# Returns the object that is responsible for loading credentials.
|
187
191
|
#
|
@@ -317,6 +321,13 @@ module AWS
|
|
317
321
|
"<#{self.class.name}>"
|
318
322
|
end
|
319
323
|
|
324
|
+
# @api private
|
325
|
+
def endpoint_region(svc)
|
326
|
+
(supplied[svc.method_name] || {})[:region] or
|
327
|
+
supplied[:"#{svc.old_name}_region"] or
|
328
|
+
region
|
329
|
+
end
|
330
|
+
|
320
331
|
protected
|
321
332
|
|
322
333
|
def supplied
|
@@ -395,9 +406,9 @@ module AWS
|
|
395
406
|
elsif endpoint = config.send(svc_opt)[:endpoint]
|
396
407
|
endpoint
|
397
408
|
elsif endpoint_pattern
|
398
|
-
endpoint_pattern % config.
|
409
|
+
endpoint_pattern % config.endpoint_region(svc)
|
399
410
|
else
|
400
|
-
endpoint_builder.call(config.
|
411
|
+
endpoint_builder.call(config.endpoint_region(svc))
|
401
412
|
end
|
402
413
|
end
|
403
414
|
|
@@ -426,7 +437,7 @@ module AWS
|
|
426
437
|
else
|
427
438
|
'us-gov-west-1' # e.g. iam.us-gov.amazonaws.com
|
428
439
|
end
|
429
|
-
elsif matches = endpoint.match(
|
440
|
+
elsif matches = endpoint.match(/^.+?[.-](.+)\.amazonaws.com$/)
|
430
441
|
matches[1]
|
431
442
|
else
|
432
443
|
AWS.const_get(name).global_endpoint? ? 'us-east-1' : config.region
|
@@ -435,6 +446,7 @@ module AWS
|
|
435
446
|
end
|
436
447
|
|
437
448
|
needs = [
|
449
|
+
:"#{svc_opt}",
|
438
450
|
:"#{ruby_name}_endpoint",
|
439
451
|
:"#{ruby_name}_port",
|
440
452
|
:"#{ruby_name}_region",
|
@@ -457,7 +469,8 @@ module AWS
|
|
457
469
|
]
|
458
470
|
|
459
471
|
create_block = lambda do |config,client_options|
|
460
|
-
|
472
|
+
options = client_options[:"#{svc_opt}"]
|
473
|
+
AWS.const_get(name)::Client.new(options.merge(:config => config))
|
461
474
|
end
|
462
475
|
|
463
476
|
add_option_with_needs :"#{ruby_name}_client", needs, &create_block
|
data/lib/aws/dynamo_db.rb
CHANGED
@@ -125,6 +125,14 @@ module AWS
|
|
125
125
|
|
126
126
|
endpoint_prefix 'dynamodb'
|
127
127
|
|
128
|
+
|
129
|
+
def initialize options = {}
|
130
|
+
options = options.dup
|
131
|
+
options[:dynamo_db] ||= {}
|
132
|
+
options[:dynamo_db][:api_version] = '2011-12-05'
|
133
|
+
super(options)
|
134
|
+
end
|
135
|
+
|
128
136
|
# Returns a collection representing all the tables in your account.
|
129
137
|
#
|
130
138
|
# @return [TableCollection]
|
data/lib/aws/dynamo_db/table.rb
CHANGED
@@ -81,6 +81,10 @@ module AWS
|
|
81
81
|
#
|
82
82
|
# @attr [Time] throughput_last_decreased_at
|
83
83
|
#
|
84
|
+
# @attr [Integer] size_bytes
|
85
|
+
#
|
86
|
+
# @attr [Integer] item_count
|
87
|
+
#
|
84
88
|
# @attr [PrimaryKeyElement] hash_key Returns the hash key element
|
85
89
|
# for this table.
|
86
90
|
#
|
@@ -113,6 +117,10 @@ module AWS
|
|
113
117
|
|
114
118
|
attribute :write_capacity_units
|
115
119
|
|
120
|
+
attribute :item_count
|
121
|
+
|
122
|
+
attribute :size_bytes, :from => 'TableSizeBytes'
|
123
|
+
|
116
124
|
attribute :hash_key, :from => "HashKeyElement", :static => true do
|
117
125
|
translates_output {|v| PrimaryKeyElement.new(v) }
|
118
126
|
end
|
data/lib/aws/s3/client.rb
CHANGED
@@ -550,6 +550,90 @@ module AWS
|
|
550
550
|
|
551
551
|
end
|
552
552
|
|
553
|
+
# @overload put_bucket_logging(options = {})
|
554
|
+
# @param [Hash] options
|
555
|
+
# @option options [required,String] :bucket_name
|
556
|
+
# @option options [Boolean] :logging_enabled Set to true if turning on
|
557
|
+
# bucket logging. If not set or false, all of the following options
|
558
|
+
# will be ignored.
|
559
|
+
# @option options [String] :target_bucket The name of the bucket in
|
560
|
+
# which you want Amazon S3 to store server access logs. You can push
|
561
|
+
# logs to any bucket you own, including the bucket being logged.
|
562
|
+
# @option options [String] :target_prefix Allows you to specify a prefix
|
563
|
+
# for the keys that the log files will be stored under. Recommended
|
564
|
+
# if you will be writing logs from multiple buckets to the same target
|
565
|
+
# bucket.
|
566
|
+
# @option options [Array<Hash>] :grants An array of hashes specifying
|
567
|
+
# permission grantees. For each hash, specify ONLY ONE of :id, :uri,
|
568
|
+
# or :email_address.
|
569
|
+
# * `:email_address` - (String) E-mail address of the person being
|
570
|
+
# granted logging permissions.
|
571
|
+
# * `:id` - (String) The canonical user ID of the grantee.
|
572
|
+
# * `:uri` - (String) URI of the grantee group.
|
573
|
+
# * `:permission` - (String) Logging permissions given to the Grantee
|
574
|
+
# for the bucket. The bucket owner is automatically granted FULL_CONTROL
|
575
|
+
# to all logs delivered to the bucket. This optional element enables
|
576
|
+
# you grant access to others. Valid Values: FULL_CONTROL | READ | WRITE
|
577
|
+
# @return [Core::Response]
|
578
|
+
bucket_method(:put_bucket_logging, :put) do
|
579
|
+
configure_request do |req, options|
|
580
|
+
|
581
|
+
req.add_param('logging')
|
582
|
+
|
583
|
+
xml = Nokogiri::XML::Builder.new
|
584
|
+
xml.BucketLoggingStatus('xmlns' => XMLNS) do |xml|
|
585
|
+
if options[:logging_enabled] == true
|
586
|
+
xml.LoggingEnabled do
|
587
|
+
xml.TargetBucket(options[:target_bucket])
|
588
|
+
xml.TargetPrefix(options[:target_prefix])
|
589
|
+
unless options[:grants].nil?
|
590
|
+
|
591
|
+
xml.TargetGrants do
|
592
|
+
options[:grants].each do |grant|
|
593
|
+
xml.Grant do
|
594
|
+
if !grant[:email_address].nil?
|
595
|
+
xml.Grantee('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
596
|
+
'xsi:type' => 'AmazonCustomerByEmail') do
|
597
|
+
xml.EmailAddress(grant[:email_address])
|
598
|
+
end
|
599
|
+
elsif !grant[:uri].nil?
|
600
|
+
xml.Grantee('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
601
|
+
'xsi:type' => 'Group') do
|
602
|
+
xml.URI(grant[:uri])
|
603
|
+
end
|
604
|
+
elsif !grant[:id].nil?
|
605
|
+
xml.Grantee('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
606
|
+
'xsi:type' => 'CanonicalUser') do
|
607
|
+
xml.ID(grant[:id])
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
xml.Permission(grant[:permission])
|
612
|
+
end
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|
616
|
+
end
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
xml = xml.doc.root.to_xml
|
621
|
+
req.body = xml
|
622
|
+
req.headers['content-md5'] = md5(xml)
|
623
|
+
|
624
|
+
super(req, options)
|
625
|
+
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
# Gets the bucket's logging status.
|
630
|
+
# @overload get_bucket_logging(options = {})
|
631
|
+
# @param [Hash] options
|
632
|
+
# @option options [required,String] :bucket_name
|
633
|
+
# @return [Core::Response]
|
634
|
+
bucket_method(:get_bucket_logging, :get, 'logging',
|
635
|
+
XML::GetBucketLogging)
|
636
|
+
|
553
637
|
# @overload get_bucket_versioning(options = {})
|
554
638
|
# @param [Hash] options
|
555
639
|
# @option options [required,String] :bucket_name
|
data/lib/aws/s3/client/xml.rb
CHANGED
@@ -71,6 +71,24 @@ module AWS
|
|
71
71
|
|
72
72
|
end
|
73
73
|
|
74
|
+
GetBucketLogging = BaseGrammar.customize do
|
75
|
+
element("LoggingEnabled") do
|
76
|
+
element("TargetBucket") { }
|
77
|
+
element("TargetPrefix") { }
|
78
|
+
element("TargetGrants") do
|
79
|
+
list "Grant"
|
80
|
+
element("Grant") do
|
81
|
+
element("Grantee") do
|
82
|
+
element("EmailAddress") { }
|
83
|
+
element("ID") { }
|
84
|
+
element("URI") { }
|
85
|
+
end
|
86
|
+
element("Permission") { }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
74
92
|
GetBucketVersioning = BaseGrammar.customize do
|
75
93
|
default_value :status, :unversioned
|
76
94
|
element("Status") do
|
@@ -53,6 +53,13 @@ module AWS
|
|
53
53
|
# object.metadata['purpose'] = 'research'
|
54
54
|
# object.metadata['purpose'] # => 'research'
|
55
55
|
#
|
56
|
+
# @deprecated In order to safely update an S3 object's metadata, you
|
57
|
+
# should use {S3Object#copy_from}. This operation does not preserve
|
58
|
+
# the ACL, storage class (standard vs. reduced redundancy) or server
|
59
|
+
# side encryption settings. Using this method on anything other than
|
60
|
+
# vanilla S3 objects risks clobbering other metadata values set on the
|
61
|
+
# object.
|
62
|
+
#
|
56
63
|
# @note The name and value of each metadata field must conform
|
57
64
|
# to US-ASCII.
|
58
65
|
#
|
data/lib/aws/s3/s3_object.rb
CHANGED
@@ -803,6 +803,8 @@ module AWS
|
|
803
803
|
# @option options [Hash] :metadata A hash of metadata to save
|
804
804
|
# with the copied object. Each name, value pair must conform
|
805
805
|
# to US-ASCII. When blank, the sources metadata is copied.
|
806
|
+
# If you set this value, you must set ALL metadata values for
|
807
|
+
# the object as we do not preserve existing values.
|
806
808
|
#
|
807
809
|
# @option options [String] :content_type The content type of
|
808
810
|
# the copied object. Defaults to the source object's content
|
data/lib/aws/sqs/config.rb
CHANGED
data/lib/aws/sqs/errors.rb
CHANGED
@@ -96,6 +96,29 @@ module AWS
|
|
96
96
|
attr_reader :failures
|
97
97
|
|
98
98
|
end
|
99
|
+
|
100
|
+
class ChecksumError < StandardError
|
101
|
+
|
102
|
+
def initialize failures
|
103
|
+
# failures can also be a single failure, always generate an array
|
104
|
+
@failures = failures.is_a?(Array) ? failures : [failures]
|
105
|
+
super("#{@failures.size} messages failed checksum verification")
|
106
|
+
end
|
107
|
+
|
108
|
+
attr_reader :failures
|
109
|
+
end
|
110
|
+
|
111
|
+
class BatchSendMultiError < StandardError
|
112
|
+
def initialize *error_set
|
113
|
+
@errors = []
|
114
|
+
error_set.each do |error|
|
115
|
+
@errors << error
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
attr_reader :errors
|
120
|
+
end
|
121
|
+
|
99
122
|
end
|
100
123
|
end
|
101
124
|
end
|
data/lib/aws/sqs/queue.rb
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
+
require 'digest'
|
15
|
+
|
14
16
|
module AWS
|
15
17
|
class SQS
|
16
18
|
|
@@ -118,10 +120,13 @@ module AWS
|
|
118
120
|
client_opts[:message_body] = body
|
119
121
|
|
120
122
|
response = client.send_message(client_opts)
|
121
|
-
|
123
|
+
|
122
124
|
msg = SentMessage.new
|
123
125
|
msg.message_id = response[:message_id]
|
124
126
|
msg.md5 = response[:md5_of_message_body]
|
127
|
+
|
128
|
+
verify_send_message_checksum body, msg.md5
|
129
|
+
|
125
130
|
msg
|
126
131
|
|
127
132
|
end
|
@@ -187,6 +192,10 @@ module AWS
|
|
187
192
|
def receive_message(opts = {}, &block)
|
188
193
|
resp = client.receive_message(receive_opts(opts))
|
189
194
|
|
195
|
+
failed = verify_receive_message_checksum resp
|
196
|
+
|
197
|
+
raise Errors::ChecksumError.new(failed) unless failed.empty?
|
198
|
+
|
190
199
|
messages = resp[:messages].map do |m|
|
191
200
|
ReceivedMessage.new(self, m[:message_id], m[:receipt_handle],
|
192
201
|
:body => m[:body],
|
@@ -530,9 +539,11 @@ module AWS
|
|
530
539
|
client_opts[:entries] = entries
|
531
540
|
|
532
541
|
response = client.send_message_batch(client_opts)
|
533
|
-
|
542
|
+
|
534
543
|
failed = batch_failures(entries, response)
|
535
544
|
|
545
|
+
checksum_failed = verify_send_message_batch_checksum entries, response
|
546
|
+
|
536
547
|
sent = response[:successful].collect do |sent|
|
537
548
|
msg = SentMessage.new
|
538
549
|
msg.message_id = sent[:message_id]
|
@@ -540,7 +551,15 @@ module AWS
|
|
540
551
|
msg
|
541
552
|
end
|
542
553
|
|
543
|
-
|
554
|
+
if !failed.empty? && !checksum_failed.empty?
|
555
|
+
send_error = Errors::BatchSendError.new(sent, failed)
|
556
|
+
checksum_error = Errors::ChecksumError.new(checksum_failed)
|
557
|
+
raise Errors::BatchSendMultiError.new send_error, checksum_error
|
558
|
+
elsif !failed.empty?
|
559
|
+
raise Errors::BatchSendError.new(sent, failed) unless failed.empty?
|
560
|
+
elsif !checksum_failed.empty?
|
561
|
+
raise Errors::ChecksumError.new(checksum_failed)
|
562
|
+
end
|
544
563
|
|
545
564
|
sent
|
546
565
|
|
@@ -757,6 +776,59 @@ module AWS
|
|
757
776
|
})
|
758
777
|
end
|
759
778
|
|
779
|
+
# @api private
|
780
|
+
protected
|
781
|
+
def is_checksum_valid checksum, data
|
782
|
+
if config.sqs_verify_checksums?
|
783
|
+
calculate_checksum(data) == checksum
|
784
|
+
else
|
785
|
+
true
|
786
|
+
end
|
787
|
+
end
|
788
|
+
|
789
|
+
# @api private
|
790
|
+
protected
|
791
|
+
def calculate_checksum data
|
792
|
+
Digest::MD5.hexdigest data
|
793
|
+
end
|
794
|
+
|
795
|
+
# @api private
|
796
|
+
protected
|
797
|
+
def verify_send_message_checksum body, md5
|
798
|
+
unless is_checksum_valid md5, body
|
799
|
+
raise Errors::ChecksumError.new "Invalid MD5 #{md5} for message body #{body}"
|
800
|
+
end
|
801
|
+
end
|
802
|
+
|
803
|
+
# @api private
|
804
|
+
protected
|
805
|
+
def verify_send_message_batch_checksum entries, response
|
806
|
+
failed = []
|
807
|
+
|
808
|
+
response[:successful].each do |msg|
|
809
|
+
entry = entries.find{ |e| e[:id] == msg[:id] }
|
810
|
+
failed << msg unless is_checksum_valid msg[:md5_of_message_body], entry[:message_body]
|
811
|
+
end
|
812
|
+
|
813
|
+
failed
|
814
|
+
end
|
815
|
+
|
816
|
+
# @api private
|
817
|
+
protected
|
818
|
+
def verify_receive_message_checksum response
|
819
|
+
return [] if response[:messages].nil?
|
820
|
+
|
821
|
+
invalid_msgs = []
|
822
|
+
|
823
|
+
response[:messages].each do |msg|
|
824
|
+
md5 = msg[:md5_of_body]
|
825
|
+
body = msg[:body]
|
826
|
+
invalid_msgs << msg unless is_checksum_valid md5, body
|
827
|
+
end
|
828
|
+
|
829
|
+
invalid_msgs
|
830
|
+
end
|
831
|
+
|
760
832
|
end
|
761
833
|
|
762
834
|
end
|
data/lib/aws/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuidtools
|