aws-sdk 1.0.1 → 1.0.2
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.
- data/lib/aws/base_client.rb +11 -8
- data/lib/aws/cacheable.rb +2 -3
- data/lib/aws/common.rb +7 -1
- data/lib/aws/configuration.rb +8 -0
- data/lib/aws/default_signer.rb +17 -2
- data/lib/aws/ec2/client.rb +17 -15
- data/lib/aws/ec2/image.rb +27 -0
- data/lib/aws/ec2/resource.rb +5 -5
- data/lib/aws/http/curb_handler.rb +5 -1
- data/lib/aws/http/httparty_handler.rb +37 -3
- data/lib/aws/http/request.rb +4 -1
- data/lib/aws/http/request_param.rb +8 -1
- data/lib/aws/http/response.rb +3 -6
- data/lib/aws/naming.rb +0 -1
- data/lib/aws/policy.rb +1 -1
- data/lib/aws/rails.rb +24 -18
- data/lib/aws/record/base.rb +40 -0
- data/lib/aws/record/finder_methods.rb +17 -71
- data/lib/aws/record/optimistic_locking.rb +34 -0
- data/lib/aws/record/scope.rb +156 -16
- data/lib/aws/record/scopes.rb +55 -0
- data/lib/aws/s3/bucket_collection.rb +13 -0
- data/lib/aws/s3/client.rb +35 -0
- data/lib/aws/s3/data_options.rb +1 -1
- data/lib/aws/s3/policy.rb +1 -1
- data/lib/aws/s3/request.rb +9 -11
- data/lib/aws/s3/s3_object.rb +5 -4
- data/lib/aws/sns.rb +1 -4
- data/lib/aws/sns/policy.rb +1 -1
- data/lib/aws/sqs/policy.rb +1 -1
- metadata +13 -12
- data/lib/aws/http/builtin_handler.rb +0 -69
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright 2011 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
|
+
require 'aws/simple_db'
|
15
|
+
require 'aws/record/scope'
|
16
|
+
|
17
|
+
module AWS
|
18
|
+
module Record
|
19
|
+
|
20
|
+
module Scopes
|
21
|
+
|
22
|
+
# Adds a scoped finder method to this class. Given a call
|
23
|
+
# to scope like:
|
24
|
+
#
|
25
|
+
# scope :top_10, order(:popularity, :desc).limit(10)
|
26
|
+
#
|
27
|
+
# Then you can call the method +top_10+ on the class and it will
|
28
|
+
# return an enumerable scope object with the given find conditions.
|
29
|
+
#
|
30
|
+
# @param [Symbol] name The name of the scope. Scope names should be
|
31
|
+
# method-safe and should not conflict with any other class methods.
|
32
|
+
#
|
33
|
+
def scope name, scope = nil, &block
|
34
|
+
|
35
|
+
raise ArgumentError, "only a scope or block may be passed, not both" if
|
36
|
+
scope and block_given?
|
37
|
+
|
38
|
+
method_definition = scope ?
|
39
|
+
lambda{ scope } :
|
40
|
+
block
|
41
|
+
|
42
|
+
extend(Module.new { define_method(name, &method_definition) })
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Scope] Returns a new scope object for this class.
|
47
|
+
# @private
|
48
|
+
private
|
49
|
+
def _new_scope
|
50
|
+
Scope.new(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -41,6 +41,19 @@ module AWS
|
|
41
41
|
|
42
42
|
# Creates and returns a new Bucket. For example:
|
43
43
|
#
|
44
|
+
# @note If your bucket name contains one or more periods and it
|
45
|
+
# is hosted in a non-US region, you should make requests
|
46
|
+
# against the bucket using the S3 endpoint specific to the
|
47
|
+
# region in which your bucket resides. For example:
|
48
|
+
#
|
49
|
+
# s3 = AWS::S3.new(:s3_endpoint => "s3-eu-west-1.amazonaws.com")
|
50
|
+
# bucket = s3.buckets.create("my.eu.bucket")
|
51
|
+
#
|
52
|
+
# For a full list of endpoints and regions, see
|
53
|
+
# {http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html
|
54
|
+
# Regions and Endpoints} in the Amazon Web Services General
|
55
|
+
# Reference.
|
56
|
+
#
|
44
57
|
# @example
|
45
58
|
#
|
46
59
|
# bucket = s3.buckets.create('my-bucket')
|
data/lib/aws/s3/client.rb
CHANGED
@@ -827,6 +827,20 @@ module AWS
|
|
827
827
|
validate_bucket_name!(bucket_name) rescue false
|
828
828
|
end
|
829
829
|
|
830
|
+
# Returns true if the given +bucket_name+ is DNS compatible.
|
831
|
+
#
|
832
|
+
# DNS compatible bucket names may be accessed like:
|
833
|
+
#
|
834
|
+
# http://dns.compat.bucket.name.s3.amazonaws.com/
|
835
|
+
#
|
836
|
+
# Whereas non-dns compatible bucket names must place the bucket
|
837
|
+
# name in the url path, like:
|
838
|
+
#
|
839
|
+
# http://s3.amazonaws.com/dns_incompat_bucket_name/
|
840
|
+
#
|
841
|
+
# @return [Boolean] Returns true if the given bucket name may be
|
842
|
+
# is dns compatible.
|
843
|
+
# this bucket n
|
830
844
|
def dns_compatible_bucket_name?(bucket_name)
|
831
845
|
return false if
|
832
846
|
!valid_bucket_name?(bucket_name) or
|
@@ -850,6 +864,27 @@ module AWS
|
|
850
864
|
true
|
851
865
|
end
|
852
866
|
|
867
|
+
# Returns true if the bucket name must be used in the request
|
868
|
+
# path instead of as a sub-domain when making requests against
|
869
|
+
# S3.
|
870
|
+
#
|
871
|
+
# This can be an issue if the bucket name is DNS compatible but
|
872
|
+
# contains '.' (periods). These cause the SSL certificate to
|
873
|
+
# become invalid when making authenticated requets over SSL to the
|
874
|
+
# bucket name. The solution is to send this as a path argument
|
875
|
+
# instead.
|
876
|
+
#
|
877
|
+
# @return [Boolean] Returns true if the bucket name should be used
|
878
|
+
# as a path segement instead of dns prefix when making requests
|
879
|
+
# against s3.
|
880
|
+
def path_style_bucket_name? bucket_name
|
881
|
+
if dns_compatible_bucket_name?(bucket_name)
|
882
|
+
bucket_name =~ /\./ ? true : false
|
883
|
+
else
|
884
|
+
true
|
885
|
+
end
|
886
|
+
end
|
887
|
+
|
853
888
|
protected
|
854
889
|
def validate! name, value, &block
|
855
890
|
if error_msg = yield
|
data/lib/aws/s3/data_options.rb
CHANGED
data/lib/aws/s3/policy.rb
CHANGED
data/lib/aws/s3/request.rb
CHANGED
@@ -53,16 +53,12 @@ module AWS
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def host
|
56
|
-
Client.
|
57
|
-
"#{bucket}.#{@host}" :
|
58
|
-
@host
|
56
|
+
Client.path_style_bucket_name?(bucket) ? @host : "#{bucket}.#{@host}"
|
59
57
|
end
|
60
58
|
|
61
59
|
def path
|
62
60
|
parts = []
|
63
|
-
|
64
|
-
parts << bucket
|
65
|
-
end
|
61
|
+
parts << bucket if bucket and Client.path_style_bucket_name?(bucket)
|
66
62
|
parts << key if key
|
67
63
|
"/#{parts.join('/')}"
|
68
64
|
end
|
@@ -131,23 +127,25 @@ module AWS
|
|
131
127
|
|
132
128
|
# virtual hosted-style requests require the hostname to appear
|
133
129
|
# in the canonicalized resource prefixed by a forward slash.
|
134
|
-
if
|
130
|
+
if
|
131
|
+
Client.dns_compatible_bucket_name?(bucket) and
|
132
|
+
!Client.path_style_bucket_name?(bucket)
|
133
|
+
then
|
135
134
|
parts << "/#{bucket}"
|
136
135
|
end
|
137
|
-
|
136
|
+
|
138
137
|
# all requests require the portion of the un-decoded uri up to
|
139
138
|
# but not including the query string
|
140
139
|
parts << path
|
141
140
|
|
142
141
|
# lastly any sub resource querystring params need to be appened
|
143
142
|
# in lexigraphical ordered joined by '&' and prefixed by '?'
|
144
|
-
params = (sub_resource_params +
|
145
|
-
query_parameters_for_signature)
|
143
|
+
params = (sub_resource_params + query_parameters_for_signature)
|
146
144
|
unless params.empty?
|
147
145
|
parts << '?'
|
148
146
|
parts << params.sort.collect{|p| p.to_s }.join('&')
|
149
147
|
end
|
150
|
-
|
148
|
+
|
151
149
|
parts.join
|
152
150
|
end
|
153
151
|
|
data/lib/aws/s3/s3_object.rb
CHANGED
@@ -85,7 +85,7 @@ module AWS
|
|
85
85
|
# @param [Hash] options
|
86
86
|
# @option options [String] :version_id Which version of this object
|
87
87
|
# to make a HEAD request against.
|
88
|
-
# @return
|
88
|
+
# @return A head object response with metatadata,
|
89
89
|
# content_length, content_type and etag.
|
90
90
|
def head options = {}
|
91
91
|
client.head_object(options.merge(
|
@@ -122,11 +122,12 @@ module AWS
|
|
122
122
|
# @option [String] :version_id (nil) If present the specified version
|
123
123
|
# of this object will be deleted. Only works for buckets that have
|
124
124
|
# had versioning enabled.
|
125
|
-
# @return [
|
125
|
+
# @return [nil]
|
126
126
|
def delete options = {}
|
127
127
|
options[:bucket_name] = bucket.name
|
128
128
|
options[:key] = key
|
129
129
|
client.delete_object(options)
|
130
|
+
nil
|
130
131
|
end
|
131
132
|
|
132
133
|
# @option [String] :version_id (nil) If present the metadata object
|
@@ -552,13 +553,13 @@ module AWS
|
|
552
553
|
# AccessControlList#initialize.
|
553
554
|
#
|
554
555
|
# @param (see Bucket#acl=)
|
555
|
-
# @return [
|
556
|
-
#
|
556
|
+
# @return [nil]
|
557
557
|
def acl=(acl)
|
558
558
|
client.set_object_acl(
|
559
559
|
:bucket_name => bucket.name,
|
560
560
|
:key => key,
|
561
561
|
:acl => acl)
|
562
|
+
nil
|
562
563
|
end
|
563
564
|
|
564
565
|
# @private
|
data/lib/aws/sns.rb
CHANGED
@@ -28,7 +28,7 @@ module AWS
|
|
28
28
|
#
|
29
29
|
# For more information about Amazon SNS:
|
30
30
|
#
|
31
|
-
# * {Amazon SNS}[http://aws.amazon.com/
|
31
|
+
# * {Amazon SNS}[http://aws.amazon.com/sns/]
|
32
32
|
# * {Amazon SNS Documentation}[http://aws.amazon.com/documentation/sns/]
|
33
33
|
#
|
34
34
|
# = Credentials
|
@@ -46,9 +46,6 @@ module AWS
|
|
46
46
|
# :access_key_id => 'YOUR_ACCESS_KEY_ID',
|
47
47
|
# :secret_access_key => 'YOUR_SECRET_ACCESS_KEY')
|
48
48
|
#
|
49
|
-
# = Understanding the SNS Interface
|
50
|
-
#
|
51
|
-
# ...
|
52
49
|
class SNS
|
53
50
|
|
54
51
|
include ServiceInterface
|
data/lib/aws/sns/policy.rb
CHANGED
data/lib/aws/sqs/policy.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-07-
|
12
|
+
date: 2011-07-21 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: uuidtools
|
17
|
-
requirement: &
|
17
|
+
requirement: &2155405840 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '2.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2155405840
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: httparty
|
28
|
-
requirement: &
|
28
|
+
requirement: &2155405080 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0.7'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2155405080
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: nokogiri
|
39
|
-
requirement: &
|
39
|
+
requirement: &2155394520 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.4.4
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2155394520
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: json
|
50
|
-
requirement: &
|
50
|
+
requirement: &2155393900 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: '1.4'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2155393900
|
59
59
|
description: AWS SDK for Ruby
|
60
60
|
email:
|
61
61
|
executables: []
|
@@ -123,7 +123,6 @@ files:
|
|
123
123
|
- lib/aws/ec2/volume_collection.rb
|
124
124
|
- lib/aws/ec2.rb
|
125
125
|
- lib/aws/errors.rb
|
126
|
-
- lib/aws/http/builtin_handler.rb
|
127
126
|
- lib/aws/http/curb_handler.rb
|
128
127
|
- lib/aws/http/handler.rb
|
129
128
|
- lib/aws/http/httparty_handler.rb
|
@@ -156,7 +155,9 @@ files:
|
|
156
155
|
- lib/aws/record/exceptions.rb
|
157
156
|
- lib/aws/record/finder_methods.rb
|
158
157
|
- lib/aws/record/naming.rb
|
158
|
+
- lib/aws/record/optimistic_locking.rb
|
159
159
|
- lib/aws/record/scope.rb
|
160
|
+
- lib/aws/record/scopes.rb
|
160
161
|
- lib/aws/record/validations.rb
|
161
162
|
- lib/aws/record/validator.rb
|
162
163
|
- lib/aws/record/validators/acceptance.rb
|
@@ -283,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
283
284
|
version: '0'
|
284
285
|
segments:
|
285
286
|
- 0
|
286
|
-
hash:
|
287
|
+
hash: 437793363847079671
|
287
288
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
288
289
|
none: false
|
289
290
|
requirements:
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# Copyright 2011 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
|
-
require 'net/http'
|
15
|
-
require 'net/https'
|
16
|
-
|
17
|
-
module AWS
|
18
|
-
module Http
|
19
|
-
|
20
|
-
# @private
|
21
|
-
class BuiltinHandler
|
22
|
-
|
23
|
-
def handle(request, response)
|
24
|
-
|
25
|
-
http = Net::HTTP.new(request.host, request.use_ssl? ? 443 : 80)
|
26
|
-
|
27
|
-
# http://www.ruby-lang.org/en/news/2007/10/04/net-https-vulnerability/
|
28
|
-
if request.use_ssl?
|
29
|
-
http.use_ssl = true
|
30
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
31
|
-
store = OpenSSL::X509::Store.new
|
32
|
-
store.set_default_paths
|
33
|
-
http.cert_store = store
|
34
|
-
end
|
35
|
-
|
36
|
-
http.start do
|
37
|
-
|
38
|
-
# Net::HTTP adds this header for us when the body is
|
39
|
-
# provided, but it messes up signing
|
40
|
-
headers = { 'content-type' => '' }
|
41
|
-
|
42
|
-
# Net::HTTP calls strip on each header value, this causes errors
|
43
|
-
# when the values are numbers (like Content-Length)
|
44
|
-
request.headers.each_pair do |key,value|
|
45
|
-
headers[key] = value.to_s
|
46
|
-
end
|
47
|
-
|
48
|
-
http_request_class = case request.http_method
|
49
|
-
when 'HEAD' then Net::HTTP::Head
|
50
|
-
when 'GET' then Net::HTTP::Get
|
51
|
-
when 'PUT' then Net::HTTP::Put
|
52
|
-
when 'POST' then Net::HTTP::Post
|
53
|
-
when 'DELETE' then Net::HTTP::Delete
|
54
|
-
else raise "unsupported http request method: #{request.http_method}"
|
55
|
-
end
|
56
|
-
|
57
|
-
http_request = http_request_class.new(request.uri, headers)
|
58
|
-
http.request(http_request, request.body) do |http_response|
|
59
|
-
response.body = http_response.body
|
60
|
-
response.status = http_response.code.to_i
|
61
|
-
response.headers = http_response.to_hash
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|