aws-sdk 1.6.5 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aws/api_config/CloudFormation-2010-05-15.yml +1 -1
- data/lib/aws/api_config/EC2-2012-07-20.yml +283 -9
- data/lib/aws/cloud_formation/client.rb +2 -2
- data/lib/aws/core.rb +1 -1
- data/lib/aws/core/credential_providers.rb +6 -0
- data/lib/aws/core/http/net_http_handler.rb +1 -0
- data/lib/aws/core/inflection.rb +1 -0
- data/lib/aws/core/json_client.rb +1 -1
- data/lib/aws/core/options/xml_serializer.rb +1 -1
- data/lib/aws/core/rest_request_builder.rb +0 -2
- data/lib/aws/dynamo_db/types.rb +1 -1
- data/lib/aws/ec2/client.rb +161 -6
- data/lib/aws/s3.rb +3 -0
- data/lib/aws/s3/bucket.rb +63 -9
- data/lib/aws/s3/bucket_lifecycle_configuration.rb +1 -1
- data/lib/aws/s3/bucket_tag_collection.rb +109 -0
- data/lib/aws/s3/client.rb +167 -6
- data/lib/aws/s3/client/xml.rb +37 -1
- data/lib/aws/s3/config.rb +2 -0
- data/lib/aws/s3/cors_rule.rb +106 -0
- data/lib/aws/s3/cors_rule_collection.rb +192 -0
- data/lib/aws/s3/request.rb +1 -1
- data/lib/aws/s3/s3_object.rb +3 -1
- metadata +84 -70
- data/lib/user.rb +0 -49
@@ -0,0 +1,192 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class S3
|
16
|
+
|
17
|
+
# Manages the CORS rules for a single bucket.
|
18
|
+
#
|
19
|
+
# == Getting Rules
|
20
|
+
#
|
21
|
+
# To get the CORS rules for a bucket, use the {Bucket#cors} method. This
|
22
|
+
# returns a CORSRuleCollection for the bucket. The collection is
|
23
|
+
# enumerable.
|
24
|
+
#
|
25
|
+
# # enumerating all rules for a buck
|
26
|
+
# bucket.cors.each do |rule|
|
27
|
+
# # rule is a CORSRule object
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# == Setting Rules
|
31
|
+
#
|
32
|
+
# You can set the rules for a bucket (replacing all existing rules) using
|
33
|
+
# the {#set} method.
|
34
|
+
#
|
35
|
+
# # accepts a list of one or more rules
|
36
|
+
# bucket.rules.set(rule1, rule2)
|
37
|
+
#
|
38
|
+
# # rules can be an array of rules
|
39
|
+
# bucket.rules.set(rules)
|
40
|
+
#
|
41
|
+
# # passing an empty list or array removes all rules
|
42
|
+
# bucket.rules.set([])
|
43
|
+
# bucket.rules.clear # does the same thing
|
44
|
+
#
|
45
|
+
# Each rule can be a Hash, a {CORSRule} or another {CORSRuleCollection}.
|
46
|
+
# See {Client#put_bucket_cors} for a list of keys for a rule hash.
|
47
|
+
#
|
48
|
+
# == Adding Rules
|
49
|
+
#
|
50
|
+
# Adding rules is the same as setting rules. Rules you add will be
|
51
|
+
# appended to the end of the existing list of rules.
|
52
|
+
#
|
53
|
+
# # add one or more rules
|
54
|
+
# bucket.rules.add(rules)
|
55
|
+
#
|
56
|
+
# == Deleting Rules
|
57
|
+
#
|
58
|
+
# To remove a rule, use the {#delete_if} method.
|
59
|
+
#
|
60
|
+
# # delete rules that allow access from any domain
|
61
|
+
# bucket.cors.delete_if{|rule| rule.allowed_origins.include?('*')
|
62
|
+
#
|
63
|
+
class CORSRuleCollection
|
64
|
+
|
65
|
+
include Core::Collection::Simple
|
66
|
+
|
67
|
+
# @param [Bucket] bucket
|
68
|
+
# @param [Hash] options
|
69
|
+
def initialize bucket, options = {}
|
70
|
+
@bucket = bucket
|
71
|
+
super
|
72
|
+
end
|
73
|
+
|
74
|
+
# @return [Bucket]
|
75
|
+
attr_reader :bucket
|
76
|
+
|
77
|
+
# Replaces the CORS rules attached to this bucket. You can pass
|
78
|
+
# one or more rules as an array or a list.
|
79
|
+
#
|
80
|
+
# # replace all exisitng rules with a single rule
|
81
|
+
# bucket.cors.set(
|
82
|
+
# :allowed_methods => %w(GET),
|
83
|
+
# :allowed_origins => %w(http://*.mydomain.com),
|
84
|
+
# :max_age_seconds => 3600)
|
85
|
+
#
|
86
|
+
# If you pass an empty array, all of the rules will be removed from
|
87
|
+
# the bucket.
|
88
|
+
#
|
89
|
+
# # these two lines are equivilent
|
90
|
+
# bucket.cors.clear
|
91
|
+
# bucket.cors.set([])
|
92
|
+
#
|
93
|
+
# @param [Hash,CORSRule,CORSRuleCollection] rule A list or array
|
94
|
+
# of one or more rules to set. Each rule may be a Hash, a CORSRule
|
95
|
+
# or a CORSRuleCollection.
|
96
|
+
#
|
97
|
+
# @return [nil]
|
98
|
+
#
|
99
|
+
def set *rules
|
100
|
+
|
101
|
+
raise ArgumentError, 'expected one or more rules' if rules.empty?
|
102
|
+
|
103
|
+
if rules == [[]]
|
104
|
+
self.clear
|
105
|
+
else
|
106
|
+
rules = rule_hashes(rules)
|
107
|
+
client.put_bucket_cors(:bucket_name => bucket.name, :rules => rules)
|
108
|
+
end
|
109
|
+
|
110
|
+
nil
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
# Add one or more CORS rules to this bucket.
|
115
|
+
#
|
116
|
+
# # adding a single rule as a hash
|
117
|
+
# bucket.cors.add(
|
118
|
+
# :allowed_methods => %w(GET HEAD),
|
119
|
+
# :allowed_origins => %w(*),
|
120
|
+
# :max_age_seconds => 3600)
|
121
|
+
#
|
122
|
+
# You can add multiple rules in a single call:
|
123
|
+
#
|
124
|
+
# # each rule may be a hash, CORSRule or a CORSRuleCollection,
|
125
|
+
# bucket.cors.add(rules)
|
126
|
+
#
|
127
|
+
# # alternatively you can pass a list of rules
|
128
|
+
# bucket.cors.add(rule1, rule2, ...)
|
129
|
+
#
|
130
|
+
# @param (see #set)
|
131
|
+
# @return (see #set)
|
132
|
+
def add *rules
|
133
|
+
self.set(self, *rules)
|
134
|
+
end
|
135
|
+
alias_method :create, :add
|
136
|
+
|
137
|
+
# Deletes every rule for which the block evaluates to +true+.
|
138
|
+
#
|
139
|
+
# # remove all rules that are open to the 'world'
|
140
|
+
# bucket.cors.delete_if{|rule| rule.allowed_origins.include?('*') }
|
141
|
+
#
|
142
|
+
# @yield [rule]
|
143
|
+
# @yieldparam [CORSRule] rule
|
144
|
+
# @yieldreturn [Boolean] Return +true+ for each rule you want to delete.
|
145
|
+
# @return (see #set)
|
146
|
+
def delete_if &block
|
147
|
+
rules = []
|
148
|
+
self.each do |rule|
|
149
|
+
rules << rule unless yield(rule)
|
150
|
+
end
|
151
|
+
self.set(*rules)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Removes all CORS rules attached to this bucket.
|
155
|
+
#
|
156
|
+
# bucket.cors.count #=> 3
|
157
|
+
# bucket.cors.clear
|
158
|
+
# bucket.cors.count #=> 0
|
159
|
+
#
|
160
|
+
# @return [nil]
|
161
|
+
def clear
|
162
|
+
client.delete_bucket_cors(:bucket_name => bucket.name)
|
163
|
+
nil
|
164
|
+
end
|
165
|
+
|
166
|
+
protected
|
167
|
+
|
168
|
+
def _each_item options
|
169
|
+
resp = client.get_bucket_cors(options.merge(:bucket_name => bucket.name))
|
170
|
+
resp.data[:rules].each do |rule|
|
171
|
+
yield(CORSRule.new(rule))
|
172
|
+
end
|
173
|
+
rescue AWS::S3::Errors::NoSuchCORSConfiguration
|
174
|
+
# no cors rules exist for this bucket, nothing to yield
|
175
|
+
end
|
176
|
+
|
177
|
+
def rule_hashes rule
|
178
|
+
case rule
|
179
|
+
when Hash then rule
|
180
|
+
when CORSRule then rule.to_h
|
181
|
+
when CORSRuleCollection then rule.map(&:to_h)
|
182
|
+
when Array then rule.map{|r| rule_hashes(r) }.flatten
|
183
|
+
else
|
184
|
+
msg = "Expected one or more CORSRule, CORSRuleCollection or hash"
|
185
|
+
msg << ", got #{rule.class.name}"
|
186
|
+
raise ArgumentError, msg
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
data/lib/aws/s3/request.rb
CHANGED
@@ -180,7 +180,7 @@ module AWS
|
|
180
180
|
def sub_resources
|
181
181
|
%w(acl location logging notification partNumber policy
|
182
182
|
requestPayment torrent uploadId uploads versionId
|
183
|
-
versioning versions delete lifecycle)
|
183
|
+
versioning versions delete lifecycle tagging cors)
|
184
184
|
end
|
185
185
|
|
186
186
|
def query_parameters
|
data/lib/aws/s3/s3_object.rb
CHANGED
@@ -1384,9 +1384,11 @@ module AWS
|
|
1384
1384
|
# Ensure metadata exists
|
1385
1385
|
options[:metadata] = {} unless options[:metadata]
|
1386
1386
|
|
1387
|
+
matdesc = options[:encryption_matdesc] || config.s3_encryption_matdesc
|
1388
|
+
|
1387
1389
|
encryption_materials = {'x-amz-key' => enc_envelope_key,
|
1388
1390
|
'x-amz-iv' => enc_envelope_iv,
|
1389
|
-
'x-amz-matdesc' =>
|
1391
|
+
'x-amz-matdesc' => matdesc}
|
1390
1392
|
orig_headers = {}
|
1391
1393
|
|
1392
1394
|
# Save the unencrypted content length
|
metadata
CHANGED
@@ -1,86 +1,92 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 6
|
9
|
+
- 6
|
10
|
+
version: 1.6.6
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Amazon Web Services
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
|
18
|
+
date: 2012-09-19 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
22
|
none: false
|
18
|
-
requirements:
|
23
|
+
requirements:
|
19
24
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 1
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 1
|
30
|
+
version: "2.1"
|
31
|
+
name: uuidtools
|
22
32
|
type: :runtime
|
23
33
|
prerelease: false
|
24
|
-
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
25
37
|
none: false
|
26
|
-
requirements:
|
38
|
+
requirements:
|
27
39
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 5
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 7
|
45
|
+
version: "0.7"
|
31
46
|
name: httparty
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0.7'
|
38
47
|
type: :runtime
|
39
48
|
prerelease: false
|
40
|
-
|
49
|
+
requirement: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
41
52
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 15
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 4
|
60
|
+
- 4
|
53
61
|
version: 1.4.4
|
62
|
+
name: nokogiri
|
54
63
|
type: :runtime
|
55
64
|
prerelease: false
|
56
|
-
|
65
|
+
requirement: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
57
68
|
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.4.4
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: json
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
69
|
+
requirements:
|
67
70
|
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 7
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 4
|
76
|
+
version: "1.4"
|
77
|
+
name: json
|
70
78
|
type: :runtime
|
71
79
|
prerelease: false
|
72
|
-
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '1.4'
|
80
|
+
requirement: *id004
|
78
81
|
description: AWS SDK for Ruby
|
79
82
|
email:
|
80
83
|
executables: []
|
84
|
+
|
81
85
|
extensions: []
|
86
|
+
|
82
87
|
extra_rdoc_files: []
|
83
|
-
|
88
|
+
|
89
|
+
files:
|
84
90
|
- ca-bundle.crt
|
85
91
|
- rails/init.rb
|
86
92
|
- lib/aws/auto_scaling/activity.rb
|
@@ -386,11 +392,14 @@ files:
|
|
386
392
|
- lib/aws/s3/bucket.rb
|
387
393
|
- lib/aws/s3/bucket_collection.rb
|
388
394
|
- lib/aws/s3/bucket_lifecycle_configuration.rb
|
395
|
+
- lib/aws/s3/bucket_tag_collection.rb
|
389
396
|
- lib/aws/s3/bucket_version_collection.rb
|
390
397
|
- lib/aws/s3/cipher_io.rb
|
391
398
|
- lib/aws/s3/client/xml.rb
|
392
399
|
- lib/aws/s3/client.rb
|
393
400
|
- lib/aws/s3/config.rb
|
401
|
+
- lib/aws/s3/cors_rule.rb
|
402
|
+
- lib/aws/s3/cors_rule_collection.rb
|
394
403
|
- lib/aws/s3/data_options.rb
|
395
404
|
- lib/aws/s3/encryption_utils.rb
|
396
405
|
- lib/aws/s3/errors.rb
|
@@ -502,7 +511,6 @@ files:
|
|
502
511
|
- lib/net/http/connection_pool/connection.rb
|
503
512
|
- lib/net/http/connection_pool/session.rb
|
504
513
|
- lib/net/http/connection_pool.rb
|
505
|
-
- lib/user.rb
|
506
514
|
- lib/aws/api_config/AutoScaling-2011-01-01.yml
|
507
515
|
- lib/aws/api_config/CloudFormation-2010-05-15.yml
|
508
516
|
- lib/aws/api_config/CloudFront-2012-05-05.yml
|
@@ -524,31 +532,37 @@ files:
|
|
524
532
|
- NOTICE.txt
|
525
533
|
- LICENSE.txt
|
526
534
|
homepage: http://aws.amazon.com/sdkforruby
|
527
|
-
licenses:
|
535
|
+
licenses:
|
528
536
|
- Apache 2.0
|
529
537
|
post_install_message:
|
530
538
|
rdoc_options: []
|
531
|
-
|
539
|
+
|
540
|
+
require_paths:
|
532
541
|
- lib
|
533
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
542
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
534
543
|
none: false
|
535
|
-
requirements:
|
536
|
-
- -
|
537
|
-
- !ruby/object:Gem::Version
|
538
|
-
|
539
|
-
segments:
|
544
|
+
requirements:
|
545
|
+
- - ">="
|
546
|
+
- !ruby/object:Gem::Version
|
547
|
+
hash: 3
|
548
|
+
segments:
|
540
549
|
- 0
|
541
|
-
|
542
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
550
|
+
version: "0"
|
551
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
543
552
|
none: false
|
544
|
-
requirements:
|
545
|
-
- -
|
546
|
-
- !ruby/object:Gem::Version
|
547
|
-
|
553
|
+
requirements:
|
554
|
+
- - ">="
|
555
|
+
- !ruby/object:Gem::Version
|
556
|
+
hash: 3
|
557
|
+
segments:
|
558
|
+
- 0
|
559
|
+
version: "0"
|
548
560
|
requirements: []
|
561
|
+
|
549
562
|
rubyforge_project:
|
550
|
-
rubygems_version: 1.8.
|
563
|
+
rubygems_version: 1.8.21
|
551
564
|
signing_key:
|
552
565
|
specification_version: 3
|
553
566
|
summary: AWS SDK for Ruby
|
554
567
|
test_files: []
|
568
|
+
|
data/lib/user.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
class User < AWS::Record::HashModel
|
15
|
-
|
16
|
-
set_shard_name 'ruby-users'
|
17
|
-
|
18
|
-
optimistic_locking
|
19
|
-
|
20
|
-
## attributes
|
21
|
-
|
22
|
-
string_attr :username
|
23
|
-
string_attr :role
|
24
|
-
string_attr :tags, :set => true
|
25
|
-
|
26
|
-
boolean_attr :verified, :default => false
|
27
|
-
|
28
|
-
timestamps
|
29
|
-
|
30
|
-
## validations
|
31
|
-
|
32
|
-
validates_presence_of :username, :role
|
33
|
-
|
34
|
-
validates_inclusion_of :role,
|
35
|
-
:in => %w(root admin member),
|
36
|
-
:allow_nil => true
|
37
|
-
|
38
|
-
validates_length_of :username,
|
39
|
-
:within => 3..20,
|
40
|
-
:allow_nil => true
|
41
|
-
|
42
|
-
validates_format_of :username, :tags,
|
43
|
-
:with => /^[a-z0-9]+$/i,
|
44
|
-
:allow_nil => true,
|
45
|
-
:message => 'may only be letters and numbers'
|
46
|
-
|
47
|
-
validates_count_of :tags, :maximum => 3
|
48
|
-
|
49
|
-
end
|