aws-sdk 1.4.1 → 1.5.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.
- data/.yardopts +0 -1
- data/lib/aws/api_config/AutoScaling-2011-01-01.yml +772 -544
- data/lib/aws/api_config/CloudFormation-2010-05-15.yml +284 -185
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +458 -738
- data/lib/aws/api_config/EC2-2011-12-15.yml +3502 -2653
- data/lib/aws/api_config/ELB-2011-08-15.yml +484 -352
- data/lib/aws/api_config/IAM-2010-05-08.yml +899 -711
- data/lib/aws/api_config/SNS-2010-03-31.yml +235 -167
- data/lib/aws/api_config/SQS-2011-10-01.yml +290 -251
- data/lib/aws/api_config/STS-2011-06-15.yml +35 -41
- data/lib/aws/api_config/SimpleDB-2009-04-15.yml +290 -263
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +144 -130
- data/lib/aws/api_config/SimpleWorkflow-2012-01-25.yml +697 -1139
- data/lib/aws/auto_scaling/activity_collection.rb +1 -1
- data/lib/aws/auto_scaling/client.rb +724 -9
- data/lib/aws/auto_scaling/errors.rb +1 -5
- data/lib/aws/auto_scaling/group.rb +1 -1
- data/lib/aws/auto_scaling/group_collection.rb +1 -1
- data/lib/aws/auto_scaling/instance_collection.rb +1 -1
- data/lib/aws/auto_scaling/launch_configuration.rb +1 -1
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/request.rb +1 -2
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +1 -1
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +3 -3
- data/lib/aws/auto_scaling/tag_collection.rb +1 -1
- data/lib/aws/cloud_formation.rb +1 -18
- data/lib/aws/cloud_formation/client.rb +314 -8
- data/lib/aws/cloud_formation/errors.rb +1 -5
- data/lib/aws/cloud_formation/request.rb +1 -2
- data/lib/aws/cloud_formation/stack.rb +4 -3
- data/lib/aws/cloud_formation/stack_collection.rb +2 -2
- data/lib/aws/cloud_formation/stack_resource_collection.rb +1 -1
- data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +2 -2
- data/lib/aws/cloud_formation/stack_summary_collection.rb +1 -1
- data/lib/aws/core.rb +29 -14
- data/lib/aws/core/async_handle.rb +11 -12
- data/lib/aws/core/client.rb +112 -102
- data/lib/aws/core/client/query_json.rb +110 -0
- data/lib/aws/core/client/query_xml.rb +122 -0
- data/lib/aws/core/data.rb +242 -0
- data/lib/aws/core/http/request.rb +7 -4
- data/lib/aws/core/lazy_error_classes.rb +60 -38
- data/lib/aws/core/option_grammar.rb +1 -0
- data/lib/aws/core/policy.rb +2 -1
- data/lib/aws/core/resource.rb +38 -33
- data/lib/aws/core/response.rb +109 -44
- data/lib/aws/core/signature/version_2.rb +42 -0
- data/lib/aws/core/signature/version_3.rb +73 -0
- data/lib/aws/core/signature/version_3_http.rb +72 -0
- data/lib/aws/core/signature/version_4.rb +138 -0
- data/lib/aws/core/uri_escape.rb +6 -9
- data/lib/aws/core/xml/frame.rb +242 -0
- data/lib/aws/core/xml/frame_stack.rb +85 -0
- data/lib/aws/core/xml/grammar.rb +299 -0
- data/lib/aws/core/xml/parser.rb +70 -0
- data/lib/aws/core/xml/root_frame.rb +65 -0
- data/lib/aws/core/{configured_xml_grammars.rb → xml/sax_handlers/libxml.rb} +22 -20
- data/lib/aws/core/xml/sax_handlers/nokogiri.rb +55 -0
- data/lib/aws/core/{authorize_with_session_token.rb → xml/sax_handlers/ox.rb} +19 -7
- data/lib/aws/core/{configured_option_grammars.rb → xml/sax_handlers/rexml.rb} +22 -23
- data/lib/aws/core/xml/stub.rb +123 -0
- data/lib/aws/dynamo_db/batch_get.rb +1 -1
- data/lib/aws/dynamo_db/client.rb +796 -14
- data/lib/aws/dynamo_db/errors.rb +1 -38
- data/lib/aws/dynamo_db/item_collection.rb +29 -28
- data/lib/aws/dynamo_db/request.rb +3 -53
- data/lib/aws/dynamo_db/table.rb +6 -2
- data/lib/aws/ec2/attachment.rb +1 -1
- data/lib/aws/ec2/client.rb +3954 -9
- data/lib/aws/ec2/dhcp_options.rb +3 -3
- data/lib/aws/ec2/errors.rb +10 -4
- data/lib/aws/ec2/instance.rb +7 -6
- data/lib/aws/ec2/instance_collection.rb +2 -2
- data/lib/aws/ec2/key_pair_collection.rb +3 -3
- data/lib/aws/ec2/network_acl.rb +4 -2
- data/lib/aws/ec2/network_acl/entry.rb +10 -10
- data/lib/aws/ec2/network_interface.rb +2 -3
- data/lib/aws/ec2/network_interface/attachment.rb +8 -8
- data/lib/aws/ec2/permission_collection.rb +3 -3
- data/lib/aws/ec2/request.rb +1 -3
- data/lib/aws/ec2/resource_tag_collection.rb +4 -8
- data/lib/aws/ec2/route_table.rb +3 -2
- data/lib/aws/ec2/route_table/route.rb +7 -7
- data/lib/aws/ec2/security_group.rb +2 -2
- data/lib/aws/ec2/security_group/egress_ip_permission_collection.rb +16 -5
- data/lib/aws/ec2/security_group/ingress_ip_permission_collection.rb +4 -3
- data/lib/aws/ec2/security_group/ip_permission.rb +1 -2
- data/lib/aws/ec2/snapshot_collection.rb +6 -3
- data/lib/aws/ec2/subnet.rb +1 -1
- data/lib/aws/ec2/volume.rb +1 -3
- data/lib/aws/ec2/volume_collection.rb +2 -0
- data/lib/aws/elb/availability_zone_collection.rb +2 -2
- data/lib/aws/elb/backend_server_policy_collection.rb +1 -1
- data/lib/aws/elb/client.rb +513 -9
- data/lib/aws/elb/errors.rb +2 -6
- data/lib/aws/elb/instance_collection.rb +2 -2
- data/lib/aws/elb/request.rb +1 -1
- data/lib/aws/errors.rb +61 -74
- data/lib/aws/iam.rb +2 -3
- data/lib/aws/iam/client.rb +1178 -10
- data/lib/aws/iam/collection.rb +2 -1
- data/lib/aws/iam/errors.rb +1 -6
- data/lib/aws/iam/group.rb +8 -9
- data/lib/aws/iam/request.rb +1 -1
- data/lib/aws/iam/server_certificate_collection.rb +8 -5
- data/lib/aws/iam/signing_certificate.rb +1 -1
- data/lib/aws/iam/user.rb +2 -2
- data/lib/aws/iam/user_policy.rb +3 -2
- data/lib/aws/rails.rb +1 -2
- data/lib/aws/record.rb +3 -3
- data/lib/aws/record/abstract_base.rb +0 -3
- data/lib/aws/record/attributes.rb +7 -7
- data/lib/aws/record/model.rb +19 -19
- data/lib/aws/record/model/finder_methods.rb +7 -7
- data/lib/aws/s3/bucket.rb +7 -2
- data/lib/aws/s3/client.rb +391 -398
- data/lib/aws/s3/client/xml.rb +44 -71
- data/lib/aws/s3/data_options.rb +3 -2
- data/lib/aws/s3/errors.rb +8 -11
- data/lib/aws/s3/multipart_upload_collection.rb +1 -3
- data/lib/aws/s3/object_collection.rb +2 -1
- data/lib/aws/s3/object_metadata.rb +2 -2
- data/lib/aws/s3/paginated_collection.rb +2 -2
- data/lib/aws/s3/prefix_and_delimiter_collection.rb +1 -1
- data/lib/aws/s3/presigned_post.rb +18 -17
- data/lib/aws/s3/request.rb +4 -3
- data/lib/aws/s3/s3_object.rb +8 -10
- data/lib/aws/simple_db/attribute.rb +2 -2
- data/lib/aws/simple_db/attribute_collection.rb +14 -4
- data/lib/aws/simple_db/client.rb +313 -14
- data/lib/aws/simple_db/domain.rb +1 -1
- data/lib/aws/simple_db/domain_collection.rb +4 -4
- data/lib/aws/simple_db/domain_metadata.rb +1 -1
- data/lib/aws/simple_db/errors.rb +14 -2
- data/lib/aws/simple_db/expect_condition_option.rb +1 -1
- data/lib/aws/simple_db/item.rb +1 -1
- data/lib/aws/simple_db/item_collection.rb +9 -9
- data/lib/aws/simple_db/item_data.rb +9 -6
- data/lib/aws/simple_db/request.rb +1 -1
- data/lib/aws/simple_email_service.rb +8 -7
- data/lib/aws/simple_email_service/client.rb +174 -9
- data/lib/aws/simple_email_service/email_address_collection.rb +0 -1
- data/lib/aws/simple_email_service/errors.rb +1 -5
- data/lib/aws/simple_email_service/quotas.rb +8 -6
- data/lib/aws/simple_email_service/request.rb +7 -1
- data/lib/aws/simple_workflow/client.rb +1383 -6
- data/lib/aws/simple_workflow/decision_task.rb +1 -3
- data/lib/aws/simple_workflow/errors.rb +1 -38
- data/lib/aws/simple_workflow/history_event_collection.rb +2 -2
- data/lib/aws/simple_workflow/request.rb +5 -49
- data/lib/aws/simple_workflow/type.rb +1 -1
- data/lib/aws/simple_workflow/type_collection.rb +4 -3
- data/lib/aws/simple_workflow/workflow_execution_collection.rb +2 -2
- data/lib/aws/sns/client.rb +345 -9
- data/lib/aws/sns/errors.rb +1 -5
- data/lib/aws/sns/request.rb +1 -2
- data/lib/aws/sns/subscription_collection.rb +2 -2
- data/lib/aws/sns/topic.rb +15 -14
- data/lib/aws/sns/topic_collection.rb +1 -1
- data/lib/aws/sqs/client.rb +334 -9
- data/lib/aws/sqs/errors.rb +1 -6
- data/lib/aws/sqs/queue.rb +20 -21
- data/lib/aws/sqs/queue_collection.rb +3 -3
- data/lib/aws/sqs/request.rb +2 -2
- data/lib/aws/sts.rb +8 -10
- data/lib/aws/sts/client.rb +67 -10
- data/lib/aws/sts/errors.rb +1 -5
- data/lib/aws/sts/request.rb +1 -1
- data/lib/user.rb +49 -0
- metadata +21 -28
- data/lib/aws/auto_scaling/client/xml.rb +0 -32
- data/lib/aws/cloud_formation/client/xml.rb +0 -32
- data/lib/aws/core/api_config.rb +0 -44
- data/lib/aws/core/authorize_v2.rb +0 -39
- data/lib/aws/core/authorize_v3.rb +0 -38
- data/lib/aws/core/authorize_v4.rb +0 -149
- data/lib/aws/core/configured_client_methods.rb +0 -76
- data/lib/aws/core/configured_grammars.rb +0 -63
- data/lib/aws/core/configured_json_client_methods.rb +0 -74
- data/lib/aws/core/ignore_result_element.rb +0 -34
- data/lib/aws/core/json_client.rb +0 -41
- data/lib/aws/core/xml_grammar.rb +0 -957
- data/lib/aws/ec2/client/xml.rb +0 -175
- data/lib/aws/elb/client/xml.rb +0 -33
- data/lib/aws/elb/listener_spec.rb +0 -14
- data/lib/aws/iam/client/xml.rb +0 -34
- data/lib/aws/simple_db/client/options.rb +0 -32
- data/lib/aws/simple_db/client/xml.rb +0 -63
- data/lib/aws/simple_email_service/client/xml.rb +0 -34
- data/lib/aws/sns/client/xml.rb +0 -34
- data/lib/aws/sqs/client/xml.rb +0 -33
- data/lib/aws/sts/client/xml.rb +0 -34
data/lib/aws/iam/collection.rb
CHANGED
data/lib/aws/iam/errors.rb
CHANGED
data/lib/aws/iam/group.rb
CHANGED
|
@@ -20,6 +20,12 @@ module AWS
|
|
|
20
20
|
# their jobs. For example, you could have a group called Admins
|
|
21
21
|
# and give that group the types of permissions admins typically
|
|
22
22
|
# need.
|
|
23
|
+
# @attr [String] name The group's name.
|
|
24
|
+
# @attr_reader [String] id The group's unique ID.
|
|
25
|
+
# @attr_reader [Time] create_date When the group was created.
|
|
26
|
+
# @attr_reader [String] arn The group's ARN (Amazon Resource Name).
|
|
27
|
+
# @attr [String] path The group's path. Paths are used to identify
|
|
28
|
+
# which division or part of an organization the group belongs to.
|
|
23
29
|
class Group < Resource
|
|
24
30
|
|
|
25
31
|
prefix_update_attributes
|
|
@@ -30,21 +36,14 @@ module AWS
|
|
|
30
36
|
super
|
|
31
37
|
end
|
|
32
38
|
|
|
33
|
-
# @attr [String] The group's name.
|
|
34
39
|
mutable_attribute :name, :static => true, :as => :group_name
|
|
35
40
|
|
|
36
|
-
# @attr_reader [String] The group's unique ID.
|
|
37
41
|
attribute :id, :static => true, :as => :group_id
|
|
38
42
|
|
|
39
|
-
# @attr_reader [Time] When the group was created.
|
|
40
43
|
attribute :create_date, :static => true
|
|
41
44
|
|
|
42
|
-
# @attr_reader [String] The group's ARN (Amazon Resource Name).
|
|
43
45
|
attribute :arn
|
|
44
46
|
|
|
45
|
-
# @attr [String] The group's path. Paths are used to identify
|
|
46
|
-
# which division or part of an organization the group belongs
|
|
47
|
-
# to.
|
|
48
47
|
mutable_attribute :path do
|
|
49
48
|
translates_input do |path|
|
|
50
49
|
path = "/#{path}" unless path[0] == ?/
|
|
@@ -54,11 +53,11 @@ module AWS
|
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
populates_from(:get_group, :create_group) do |resp|
|
|
57
|
-
resp
|
|
56
|
+
resp[:group] if resp[:group][:group_name] == name
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
populates_from(:list_groups, :list_groups_for_user) do |resp|
|
|
61
|
-
resp
|
|
60
|
+
resp[:groups].find {|g| g[:group_name] == name }
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
# (see Resource#exists?)
|
data/lib/aws/iam/request.rb
CHANGED
|
@@ -87,7 +87,8 @@ module AWS
|
|
|
87
87
|
#
|
|
88
88
|
# @return [ServerCertificate] The newly created server
|
|
89
89
|
# certificate.
|
|
90
|
-
def
|
|
90
|
+
def create options = {}
|
|
91
|
+
|
|
91
92
|
client_opts = options.dup
|
|
92
93
|
client_opts[:server_certificate_name] = client_opts.delete(:name)
|
|
93
94
|
|
|
@@ -98,11 +99,13 @@ module AWS
|
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
resp = client.upload_server_certificate(client_opts)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
|
|
103
|
+
ServerCertificate.new(
|
|
104
|
+
resp[:server_certificate_metadata][:server_certificate_name],
|
|
105
|
+
:config => config)
|
|
106
|
+
|
|
104
107
|
end
|
|
105
|
-
alias_method :
|
|
108
|
+
alias_method :upload, :create
|
|
106
109
|
|
|
107
110
|
# Returns a reference to the server certificate with the given
|
|
108
111
|
# name:
|
|
@@ -55,7 +55,7 @@ module AWS
|
|
|
55
55
|
|
|
56
56
|
# @param [String] certificate_id The id of the signing certificate.
|
|
57
57
|
# @param [Hash] options
|
|
58
|
-
# @
|
|
58
|
+
# @option options [User] :user
|
|
59
59
|
def initialize certificate_id, options = {}
|
|
60
60
|
@id = certificate_id
|
|
61
61
|
@user = options[:user]
|
data/lib/aws/iam/user.rb
CHANGED
|
@@ -97,11 +97,11 @@ module AWS
|
|
|
97
97
|
mutable_attribute :path
|
|
98
98
|
|
|
99
99
|
populates_from(:create_user, :get_user) do |resp|
|
|
100
|
-
resp
|
|
100
|
+
resp[:user] if resp[:user][:user_name] == name
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
populates_from(:list_users, :get_group) do |resp|
|
|
104
|
-
resp
|
|
104
|
+
resp[:users].find{|u| u[:user_name] == name }
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
# Deletes this user.
|
data/lib/aws/iam/user_policy.rb
CHANGED
|
@@ -18,8 +18,9 @@ module AWS
|
|
|
18
18
|
|
|
19
19
|
class UserPolicy < Resource
|
|
20
20
|
|
|
21
|
-
# @param [User] The user this user policy belongs to.
|
|
22
|
-
# @param [String] The name of this user policy.
|
|
21
|
+
# @param [User] user The user this user policy belongs to.
|
|
22
|
+
# @param [String] name The name of this user policy.
|
|
23
|
+
# @param [Hash] options
|
|
23
24
|
def initialize user, name, options = {}
|
|
24
25
|
@user = user
|
|
25
26
|
@name = name
|
data/lib/aws/rails.rb
CHANGED
|
@@ -136,8 +136,6 @@ module AWS
|
|
|
136
136
|
#
|
|
137
137
|
# AWS.add_action_mailer_delivery_method(:ses, custom_options)
|
|
138
138
|
#
|
|
139
|
-
# @param [Hash] options
|
|
140
|
-
#
|
|
141
139
|
# @param [Symbol] name (:amazon_ses) The name of the delivery
|
|
142
140
|
# method. The name used here should be the same as you set in
|
|
143
141
|
# your environment config. If you name the delivery method
|
|
@@ -150,6 +148,7 @@ module AWS
|
|
|
150
148
|
# {AWS::SimpleEmailService#new} before delivering email.
|
|
151
149
|
#
|
|
152
150
|
# @return [nil]
|
|
151
|
+
#
|
|
153
152
|
def self.add_action_mailer_delivery_method name = :amazon_ses, options = {}
|
|
154
153
|
|
|
155
154
|
if ::Rails.version.to_f >= 3
|
data/lib/aws/record.rb
CHANGED
|
@@ -40,8 +40,8 @@ module AWS
|
|
|
40
40
|
# p.shard #=> 'products'
|
|
41
41
|
# p.save # the product is persisted to the 'production-products' domain
|
|
42
42
|
#
|
|
43
|
-
# @param [String] A prefix to append to all domains. This is useful
|
|
44
|
-
# grouping domains used by one application with a single prefix.
|
|
43
|
+
# @param [String] prefix A prefix to append to all domains. This is useful
|
|
44
|
+
# for grouping domains used by one application with a single prefix.
|
|
45
45
|
#
|
|
46
46
|
def self.domain_prefix= prefix
|
|
47
47
|
@domain_prefix = prefix
|
|
@@ -66,7 +66,7 @@ module AWS
|
|
|
66
66
|
# p.shard #=> 'products'
|
|
67
67
|
# p.save # the product is persisted to the 'production-products' table
|
|
68
68
|
#
|
|
69
|
-
# @param [String] A prefix to append to all tables. This is
|
|
69
|
+
# @param [String] prefix A prefix to append to all tables. This is
|
|
70
70
|
# useful for grouping tables used by one application with a
|
|
71
71
|
# single prefix.
|
|
72
72
|
#
|
|
@@ -44,9 +44,6 @@ module AWS
|
|
|
44
44
|
|
|
45
45
|
# Constructs a new record.
|
|
46
46
|
#
|
|
47
|
-
# @param [Hash] attributes A set of attribute values to seed this record
|
|
48
|
-
# with. The attributes are bulk assigned.
|
|
49
|
-
#
|
|
50
47
|
# @param [Hash] attributes Attributes that should be bulk assigned
|
|
51
48
|
# to this record. You can also specify the shard (i.e. domain
|
|
52
49
|
# or table) this record should persist to via +:shard+).
|
|
@@ -20,7 +20,7 @@ module AWS
|
|
|
20
20
|
# Base class for all of the AWS::Record attributes.
|
|
21
21
|
class BaseAttr
|
|
22
22
|
|
|
23
|
-
# @param [Symbol] Name of this attribute. It should be a name that
|
|
23
|
+
# @param [Symbol] name Name of this attribute. It should be a name that
|
|
24
24
|
# is safe to use as a method.
|
|
25
25
|
# @param [Hash] options
|
|
26
26
|
# @option options [String] :persist_as Defaults to the name of the
|
|
@@ -59,20 +59,20 @@ module AWS
|
|
|
59
59
|
(options[:persist_as] || @name).to_s
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
# @param [Mixed] A single value to type cast.
|
|
62
|
+
# @param [Mixed] raw_value A single value to type cast.
|
|
63
63
|
# @return [Mixed] Returns the type casted value.
|
|
64
64
|
def type_cast raw_value
|
|
65
65
|
self.class.type_cast(raw_value, options)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
# @param [String] The serialized string value.
|
|
68
|
+
# @param [String] serialized_value The serialized string value.
|
|
69
69
|
# @return [Mixed] Returns a deserialized type-casted value.
|
|
70
70
|
def deserialize serialized_value
|
|
71
71
|
self.class.deserialize(serialized_value, options)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
# Takes the type casted value and serializes it
|
|
75
|
-
# @param [Mixed] A single value to serialize.
|
|
75
|
+
# @param [Mixed] type_casted_value A single value to serialize.
|
|
76
76
|
# @return [Mixed] Returns the serialized value.
|
|
77
77
|
def serialize type_casted_value
|
|
78
78
|
self.class.serialize(type_casted_value, options)
|
|
@@ -116,7 +116,7 @@ module AWS
|
|
|
116
116
|
# string_attr.type_cast('', :preserve_empty_strings => true)
|
|
117
117
|
# # => ''
|
|
118
118
|
#
|
|
119
|
-
# @param [Mixed]
|
|
119
|
+
# @param [Mixed] raw_value
|
|
120
120
|
# @param [Hash] options
|
|
121
121
|
# @option options [Boolean] :preserve_empty_strings (false) When true,
|
|
122
122
|
# empty strings are preserved and not cast to nil.
|
|
@@ -189,7 +189,7 @@ module AWS
|
|
|
189
189
|
# int_attribute.type_cast('')
|
|
190
190
|
# #=> nil
|
|
191
191
|
#
|
|
192
|
-
# @param [Mixed]
|
|
192
|
+
# @param [Mixed] raw_value The value to type cast to an integer.
|
|
193
193
|
# @return [Integer,nil] Returns the type casted integer or nil
|
|
194
194
|
def self.type_cast raw_value, options = {}
|
|
195
195
|
case raw_value
|
|
@@ -294,7 +294,7 @@ module AWS
|
|
|
294
294
|
# attribute.serialize(DateTime.parse('2001-01-01'))
|
|
295
295
|
# #=> '2001-01-01'
|
|
296
296
|
#
|
|
297
|
-
# @param [Date]
|
|
297
|
+
# @param [Date] date The date to serialize.
|
|
298
298
|
#
|
|
299
299
|
# @param [Hash] options
|
|
300
300
|
#
|
data/lib/aws/record/model.rb
CHANGED
|
@@ -280,33 +280,33 @@ module AWS
|
|
|
280
280
|
# class Product < AWS::Record::Model
|
|
281
281
|
# end
|
|
282
282
|
#
|
|
283
|
-
# Product.create_table #=>
|
|
284
|
-
#
|
|
285
|
-
# If you shard you data across multiple domains, you can specify the
|
|
286
|
-
# shard name:
|
|
287
|
-
#
|
|
288
|
-
# # create two domains, with the given names
|
|
289
|
-
# Product.create_domain :shard_name => 'products-1'
|
|
290
|
-
# Product.create_domain :shard_name => 'products-2'
|
|
283
|
+
# Product.create_table #=> 'Product'
|
|
291
284
|
#
|
|
292
285
|
# If you share a single AWS account with multiple applications, you
|
|
293
|
-
# can provide a domain prefix
|
|
294
|
-
# collisions:
|
|
286
|
+
# can provide a domain prefix for your model classes.
|
|
295
287
|
#
|
|
296
288
|
# AWS::Record.domain_prefix = 'myapp-'
|
|
297
289
|
#
|
|
298
|
-
#
|
|
299
|
-
# Product.create_domain
|
|
290
|
+
# Product.create_table #=> 'myapp-Product'
|
|
300
291
|
#
|
|
301
|
-
#
|
|
302
|
-
#
|
|
292
|
+
# If you have set a model shard name, this is used in place of the
|
|
293
|
+
# class name.
|
|
303
294
|
#
|
|
304
|
-
#
|
|
305
|
-
#
|
|
295
|
+
# AWS::Record.domain_prefix = 'prod-'
|
|
296
|
+
# class Product < AWS::Record::Model
|
|
297
|
+
# set_shard_name 'products'
|
|
298
|
+
# end
|
|
299
|
+
#
|
|
300
|
+
# Product.create_table #=> 'prod-products'
|
|
301
|
+
#
|
|
302
|
+
# If you shard you data across multiple domains, you can specify the
|
|
303
|
+
# shard name:
|
|
304
|
+
#
|
|
305
|
+
# # create two domains, with the given names
|
|
306
|
+
# Product.create_domain 'products-1'
|
|
307
|
+
# Product.create_domain 'products-2'
|
|
306
308
|
#
|
|
307
|
-
# @
|
|
308
|
-
# shard name will be prefixed with {AWS::Record.domain_prefix},
|
|
309
|
-
# and that becomes the domain name.
|
|
309
|
+
# @param [optional,String] shard_name Defaults to the class name.
|
|
310
310
|
#
|
|
311
311
|
# @return [SimpleDB::Domain]
|
|
312
312
|
#
|
|
@@ -93,7 +93,7 @@ module AWS
|
|
|
93
93
|
# # ...
|
|
94
94
|
# end
|
|
95
95
|
#
|
|
96
|
-
# @param [String]
|
|
96
|
+
# @param [String] shard_name
|
|
97
97
|
# @return [Scope] Returns a scope for restricting the domain of subsequent
|
|
98
98
|
def shard shard_name
|
|
99
99
|
new_scope.shard(shard_name)
|
|
@@ -186,11 +186,12 @@ module AWS
|
|
|
186
186
|
# Car.where(:color => 'red').order(:price, :desc).limit(10)
|
|
187
187
|
#
|
|
188
188
|
# @overload where(conditions_hash)
|
|
189
|
+
# @param [Hash] conditions_hash A hash of attributes to values. Each
|
|
190
|
+
# key/value pair from the hash becomes a find condition. All
|
|
191
|
+
# conditions are joined by AND.
|
|
192
|
+
#
|
|
189
193
|
# @overload where(sql_fragment[, quote_params, ...])
|
|
190
194
|
#
|
|
191
|
-
# @param [Hash] conditions_hash A hash of attributes to values. Each
|
|
192
|
-
# key/value pair from the hash becomes a find condition. All conditions
|
|
193
|
-
# are joined by AND.
|
|
194
195
|
def where *args
|
|
195
196
|
new_scope.where(*args)
|
|
196
197
|
end
|
|
@@ -206,9 +207,8 @@ module AWS
|
|
|
206
207
|
# Pepole.order(:age, :desc).limit(10).each {|person| ... }
|
|
207
208
|
#
|
|
208
209
|
# @overload order(attribute, direction = :asc)
|
|
209
|
-
#
|
|
210
|
-
#
|
|
211
|
-
# or descending order.
|
|
210
|
+
# @param [String,Symbol] attribute The attribute to sort by.
|
|
211
|
+
# @param [:asc,:desc] direction (:asc) The direction to sort.
|
|
212
212
|
def order *args
|
|
213
213
|
new_scope.order(*args)
|
|
214
214
|
end
|
data/lib/aws/s3/bucket.rb
CHANGED
|
@@ -202,10 +202,14 @@ module AWS
|
|
|
202
202
|
#
|
|
203
203
|
# @return [AccessControlList]
|
|
204
204
|
def acl
|
|
205
|
-
|
|
205
|
+
|
|
206
|
+
resp = client.get_bucket_acl(:bucket_name => name)
|
|
207
|
+
|
|
208
|
+
acl = AccessControlList.new(resp.data)
|
|
206
209
|
acl.extend ACLProxy
|
|
207
210
|
acl.bucket = self
|
|
208
211
|
acl
|
|
212
|
+
|
|
209
213
|
end
|
|
210
214
|
|
|
211
215
|
# Sets the bucket's access control list. +acl+ can be:
|
|
@@ -263,7 +267,8 @@ module AWS
|
|
|
263
267
|
# @return [Policy,nil] Returns the bucket policy (if it has one),
|
|
264
268
|
# or it returns +nil+ otherwise.
|
|
265
269
|
def policy
|
|
266
|
-
|
|
270
|
+
resp = client.get_bucket_policy(:bucket_name => name)
|
|
271
|
+
policy = Policy.from_json(resp.data[:policy])
|
|
267
272
|
policy.extend(PolicyProxy)
|
|
268
273
|
policy.bucket = self
|
|
269
274
|
policy
|
data/lib/aws/s3/client.rb
CHANGED
|
@@ -20,79 +20,39 @@ require 'digest/md5'
|
|
|
20
20
|
module AWS
|
|
21
21
|
class S3
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
# Provides a low-level client to Amazon S3:
|
|
25
|
-
#
|
|
26
|
-
# * Each method makes exactly one request to S3, and no two
|
|
27
|
-
# methods make the same type of request.
|
|
28
|
-
#
|
|
29
|
-
# * These methods hide the details of how request parameters are
|
|
30
|
-
# sent to S3; for example:
|
|
31
|
-
#
|
|
32
|
-
# client.set_bucket_acl(# controls which host to connect to
|
|
33
|
-
# :bucket_name => "mybucket",
|
|
34
|
-
# # the request payload
|
|
35
|
-
# :acl => [{ :grantee => "..." }])
|
|
36
|
-
#
|
|
37
|
-
# * These methods return subclasses of Response, so that you can
|
|
38
|
-
# always get access to the request that was made and the raw
|
|
39
|
-
# HTTP response. You can also access S3-specific response
|
|
40
|
-
# metadata. For example:
|
|
41
|
-
#
|
|
42
|
-
# response = client.list_buckets
|
|
43
|
-
# response.http_request.http_method # => "GET"
|
|
44
|
-
# response.http_response.body # => "<ListAllMyBucketsResult xmlns..."
|
|
45
|
-
# response.request_id # => "32FE2CEB32F5EE25"
|
|
46
|
-
# # (S3-specific metadata)
|
|
47
|
-
#
|
|
48
|
-
# * This client attempts to raise ArgumentError for any invalid
|
|
49
|
-
# requests it can detect before sending a request to the
|
|
50
|
-
# service. For example:
|
|
51
|
-
#
|
|
52
|
-
# begin
|
|
53
|
-
# client.create_bucket
|
|
54
|
-
# rescue ArgumentError => e
|
|
55
|
-
# puts e # prints "The bucket_name parameter is
|
|
56
|
-
# # required"
|
|
57
|
-
# end
|
|
58
|
-
#
|
|
59
|
-
# * Each method can take an +:async+ to turn it into an
|
|
60
|
-
# asynchronous operation. Instead of blocking on the response
|
|
61
|
-
# to the service call, the method will return a handle on the
|
|
62
|
-
# response. For example:
|
|
63
|
-
#
|
|
64
|
-
# response = client.list_buckets(:async => true)
|
|
65
|
-
# response.on_success { p response.buckets.map(&:name) }
|
|
66
|
-
#
|
|
67
|
-
# @private
|
|
23
|
+
# Client class for Amazon Simple Storage Service (S3).
|
|
68
24
|
class Client < Core::Client
|
|
69
25
|
|
|
70
|
-
AWS.register_autoloads(self) do
|
|
71
|
-
autoload :XML, 'xml'
|
|
72
|
-
end
|
|
73
|
-
|
|
74
26
|
API_VERSION = '2006-03-01'
|
|
75
27
|
|
|
76
28
|
XMLNS = "http://s3.amazonaws.com/doc/#{API_VERSION}/"
|
|
77
29
|
|
|
30
|
+
AWS.register_autoloads(self) do
|
|
31
|
+
autoload :XML, 'xml'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @private
|
|
78
35
|
EMPTY_BODY_ERRORS = {
|
|
79
36
|
304 => Errors::NotModified,
|
|
80
37
|
404 => Errors::NoSuchKey
|
|
81
38
|
}
|
|
82
39
|
|
|
40
|
+
# @private
|
|
41
|
+
CACHEABLE_REQUESTS = Set[]
|
|
42
|
+
|
|
83
43
|
include DataOptions
|
|
84
44
|
include Core::UriEscape
|
|
85
45
|
|
|
86
|
-
configure_client
|
|
87
|
-
|
|
88
46
|
protected
|
|
47
|
+
|
|
89
48
|
def self.bucket_method(method_name, verb, *args, &block)
|
|
49
|
+
|
|
90
50
|
method_options = (args.pop if args.last.kind_of?(Hash)) || {}
|
|
91
|
-
xml_grammar = (args.pop if args.last.respond_to?(:
|
|
51
|
+
xml_grammar = (args.pop if args.last.respond_to?(:rules))
|
|
92
52
|
verb = verb.to_s.upcase
|
|
93
53
|
subresource = args.first
|
|
94
54
|
|
|
95
|
-
add_client_request_method(method_name
|
|
55
|
+
add_client_request_method(method_name) do
|
|
96
56
|
|
|
97
57
|
configure_request do |req, options|
|
|
98
58
|
require_bucket_name!(options[:bucket_name])
|
|
@@ -110,10 +70,26 @@ module AWS
|
|
|
110
70
|
end
|
|
111
71
|
|
|
112
72
|
instance_eval(&block) if block
|
|
73
|
+
|
|
74
|
+
if xml_grammar
|
|
75
|
+
|
|
76
|
+
parser = Core::XML::Parser.new(xml_grammar.rules)
|
|
77
|
+
|
|
78
|
+
process_response do |resp|
|
|
79
|
+
resp.data = parser.parse(resp.http_response.body)
|
|
80
|
+
super(resp)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
simulate_response do |resp|
|
|
84
|
+
resp.data = parser.simulate
|
|
85
|
+
super(resp)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
113
90
|
end
|
|
114
91
|
end
|
|
115
92
|
|
|
116
|
-
protected
|
|
117
93
|
def self.object_method(method_name, verb, *args, &block)
|
|
118
94
|
bucket_method(method_name, verb, *args) do
|
|
119
95
|
configure_request do |req, options|
|
|
@@ -128,6 +104,11 @@ module AWS
|
|
|
128
104
|
|
|
129
105
|
public
|
|
130
106
|
|
|
107
|
+
# Creates a bucket.
|
|
108
|
+
# @overload create_bucket(options = {})
|
|
109
|
+
# @param [Hash] options
|
|
110
|
+
# @option options [required,String] :bucket_name
|
|
111
|
+
# @return [Core::Response]
|
|
131
112
|
bucket_method(:create_bucket, :put) do
|
|
132
113
|
configure_request do |req, options|
|
|
133
114
|
validate_bucket_name!(options[:bucket_name])
|
|
@@ -144,14 +125,18 @@ module AWS
|
|
|
144
125
|
end
|
|
145
126
|
end
|
|
146
127
|
|
|
147
|
-
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
#
|
|
152
|
-
# * +:bucket_name+ -- The name of the bucket.
|
|
128
|
+
# Deletes an empty bucket.
|
|
129
|
+
# @overload delete_bucket(options = {})
|
|
130
|
+
# @param [Hash] options
|
|
131
|
+
# @option options [required,String] :bucket_name
|
|
132
|
+
# @return [Core::Response]
|
|
153
133
|
bucket_method(:delete_bucket, :delete)
|
|
154
134
|
|
|
135
|
+
# @overload set_bucket_lifecycle_configuration(options = {})
|
|
136
|
+
# @param [Hash] options
|
|
137
|
+
# @option options [required,String] :bucket_name
|
|
138
|
+
# @option options [required,String] :lifecycle_configuration
|
|
139
|
+
# @return [Core::Response]
|
|
155
140
|
bucket_method(:set_bucket_lifecycle_configuration, :put) do
|
|
156
141
|
|
|
157
142
|
configure_request do |req, options|
|
|
@@ -165,6 +150,10 @@ module AWS
|
|
|
165
150
|
|
|
166
151
|
end
|
|
167
152
|
|
|
153
|
+
# @overload get_bucket_lifecycle_configuration(options = {})
|
|
154
|
+
# @param [Hash] options
|
|
155
|
+
# @option options [required,String] :bucket_name
|
|
156
|
+
# @return [Core::Response]
|
|
168
157
|
bucket_method(:get_bucket_lifecycle_configuration, :get) do
|
|
169
158
|
|
|
170
159
|
configure_request do |req, options|
|
|
@@ -174,12 +163,15 @@ module AWS
|
|
|
174
163
|
|
|
175
164
|
process_response do |resp|
|
|
176
165
|
xml = resp.http_response.body
|
|
177
|
-
data = XML::GetBucketLifecycleConfiguration.parse(xml)
|
|
178
|
-
Core::MetaUtils.extend_method(resp, :data) { ResponseData.new(data) }
|
|
166
|
+
resp.data = XML::GetBucketLifecycleConfiguration.parse(xml)
|
|
179
167
|
end
|
|
180
168
|
|
|
181
169
|
end
|
|
182
170
|
|
|
171
|
+
# @overload delete_bucket_lifecycle_configuration(options = {})
|
|
172
|
+
# @param [Hash] options
|
|
173
|
+
# @option options [required,String] :bucket_name
|
|
174
|
+
# @return [Core::Response]
|
|
183
175
|
bucket_method(:delete_bucket_lifecycle_configuration, :delete) do
|
|
184
176
|
|
|
185
177
|
configure_request do |req, options|
|
|
@@ -189,38 +181,36 @@ module AWS
|
|
|
189
181
|
|
|
190
182
|
end
|
|
191
183
|
|
|
192
|
-
#
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
# Lists the buckets in the account.
|
|
184
|
+
# @overload list_buckets(options = {})
|
|
185
|
+
# @param [Hash] options
|
|
186
|
+
# @return [Core::Response]
|
|
196
187
|
add_client_request_method(:list_buckets) do
|
|
188
|
+
|
|
197
189
|
configure_request do |req, options|
|
|
198
190
|
req.http_method = "GET"
|
|
199
191
|
end
|
|
200
192
|
|
|
201
193
|
process_response do |resp|
|
|
202
|
-
XML::ListBuckets.parse(resp.http_response.body
|
|
194
|
+
resp.data = XML::ListBuckets.parse(resp.http_response.body)
|
|
203
195
|
end
|
|
196
|
+
|
|
197
|
+
simulate_response do |resp|
|
|
198
|
+
resp.data = Core::XML::Parser.new(XML::ListBuckets.rules).simulate
|
|
199
|
+
end
|
|
200
|
+
|
|
204
201
|
end
|
|
205
202
|
|
|
206
|
-
##
|
|
207
203
|
# Sets the access policy for a bucket.
|
|
208
|
-
#
|
|
209
|
-
#
|
|
210
|
-
#
|
|
211
|
-
#
|
|
212
|
-
#
|
|
213
|
-
#
|
|
214
|
-
# is assumed to contain a valid policy expressed in JSON), a
|
|
215
|
-
# Policy or any object that responds to +to_json+.
|
|
216
|
-
#
|
|
217
|
-
# == Response
|
|
218
|
-
#
|
|
219
|
-
# The response contains only the standard fields.
|
|
204
|
+
# @overload set_bucket_policy(options = {})
|
|
205
|
+
# @param [Hash] options
|
|
206
|
+
# @option options [required,String] :bucket_name
|
|
207
|
+
# @option options [required,String] :policy This can be a String
|
|
208
|
+
# or any object that responds to +#to_json+.
|
|
209
|
+
# @return [Core::Response]
|
|
220
210
|
bucket_method(:set_bucket_policy, :put, 'policy') do
|
|
221
211
|
|
|
222
212
|
configure_request do |req, options|
|
|
223
|
-
|
|
213
|
+
require_policy!(options[:policy])
|
|
224
214
|
super(req, options)
|
|
225
215
|
policy = options[:policy]
|
|
226
216
|
policy = policy.to_json unless policy.respond_to?(:to_str)
|
|
@@ -229,37 +219,33 @@ module AWS
|
|
|
229
219
|
|
|
230
220
|
end
|
|
231
221
|
|
|
232
|
-
##
|
|
233
222
|
# Gets the access policy for a bucket.
|
|
234
|
-
#
|
|
235
|
-
#
|
|
236
|
-
#
|
|
237
|
-
#
|
|
238
|
-
#
|
|
239
|
-
# == Response
|
|
240
|
-
#
|
|
241
|
-
# A successful response will have a +policy+ method that
|
|
242
|
-
# returns an instance of Policy.
|
|
243
|
-
#
|
|
223
|
+
# @overload get_bucket_policy(options = {})
|
|
224
|
+
# @param [Hash] options
|
|
225
|
+
# @option options [required,String] :bucket_name
|
|
226
|
+
# @return [Core::Response]
|
|
244
227
|
bucket_method(:get_bucket_policy, :get, 'policy') do
|
|
228
|
+
|
|
245
229
|
process_response do |resp|
|
|
246
|
-
|
|
247
|
-
# we should be doing in case of invalid JSON from the service?
|
|
248
|
-
policy = Policy.from_json(resp.http_response.body) rescue nil
|
|
249
|
-
Core::MetaUtils.extend_method(resp, :policy) { policy }
|
|
230
|
+
resp.data[:policy] = resp.http_response.body
|
|
250
231
|
end
|
|
232
|
+
|
|
251
233
|
end
|
|
252
234
|
|
|
253
|
-
##
|
|
254
235
|
# Deletes the access policy for a bucket.
|
|
255
|
-
#
|
|
256
|
-
#
|
|
257
|
-
#
|
|
258
|
-
#
|
|
259
|
-
#
|
|
236
|
+
# @overload delete_bucket_policy(options = {})
|
|
237
|
+
# @param [Hash] options
|
|
238
|
+
# @option options [required,String] :bucket_name
|
|
239
|
+
# @return [Core::Response]
|
|
260
240
|
bucket_method(:delete_bucket_policy, :delete, 'policy')
|
|
261
241
|
|
|
242
|
+
# @overload set_bucket_versioning(options = {})
|
|
243
|
+
# @param [Hash] options
|
|
244
|
+
# @option options [required,String] :bucket_name
|
|
245
|
+
# @option options [required,String] :state
|
|
246
|
+
# @return [Core::Response]
|
|
262
247
|
bucket_method(:set_bucket_versioning, :put, 'versioning') do
|
|
248
|
+
|
|
263
249
|
configure_request do |req, options|
|
|
264
250
|
state = options[:state].to_s.downcase.capitalize
|
|
265
251
|
unless state =~ /^(Enabled|Suspended)$/
|
|
@@ -272,24 +258,40 @@ module AWS
|
|
|
272
258
|
</VersioningConfiguration>
|
|
273
259
|
XML
|
|
274
260
|
end
|
|
261
|
+
|
|
275
262
|
end
|
|
276
263
|
|
|
277
|
-
##
|
|
278
264
|
# Gets the bucket's location constraint.
|
|
279
|
-
# @
|
|
280
|
-
#
|
|
265
|
+
# @overload get_bucket_location(options = {})
|
|
266
|
+
# @param [Hash] options
|
|
267
|
+
# @option options [required,String] :bucket_name
|
|
268
|
+
# @return [Core::Response]
|
|
281
269
|
bucket_method(:get_bucket_location, :get, 'location') do
|
|
270
|
+
|
|
282
271
|
process_response do |response|
|
|
283
272
|
regex = />(.*)<\/LocationConstraint>/
|
|
284
273
|
matches = response.http_response.body.match(regex)
|
|
285
|
-
|
|
286
|
-
Core::MetaUtils.extend_method(response, :location_constraint) { location }
|
|
274
|
+
response.data[:location_constraint] = matches ? matches[1] : nil
|
|
287
275
|
end
|
|
276
|
+
|
|
288
277
|
end
|
|
289
278
|
|
|
279
|
+
# @overload get_bucket_versioning(options = {})
|
|
280
|
+
# @param [Hash] options
|
|
281
|
+
# @option options [required,String] :bucket_name
|
|
282
|
+
# @return [Core::Response]
|
|
290
283
|
bucket_method(:get_bucket_versioning, :get, 'versioning',
|
|
291
284
|
XML::GetBucketVersioning)
|
|
292
285
|
|
|
286
|
+
# @overload list_object_versions(options = {})
|
|
287
|
+
# @param [Hash] options
|
|
288
|
+
# @option options [required,String] :bucket_name
|
|
289
|
+
# @option options [String] :prefix
|
|
290
|
+
# @option options [String] :delimiter
|
|
291
|
+
# @option options [String] :max_keys
|
|
292
|
+
# @option options [String] :key_marker
|
|
293
|
+
# @option options [String] :version_id_marker
|
|
294
|
+
# @return [Core::Response]
|
|
293
295
|
bucket_method(:list_object_versions, :get, 'versions',
|
|
294
296
|
XML::ListObjectVersions) do
|
|
295
297
|
|
|
@@ -305,24 +307,19 @@ module AWS
|
|
|
305
307
|
|
|
306
308
|
end
|
|
307
309
|
|
|
308
|
-
##
|
|
309
310
|
# Sets the access control list for a bucket.
|
|
310
|
-
#
|
|
311
|
-
#
|
|
312
|
-
#
|
|
313
|
-
#
|
|
314
|
-
#
|
|
315
|
-
#
|
|
316
|
-
#
|
|
317
|
-
#
|
|
318
|
-
#
|
|
319
|
-
#
|
|
320
|
-
# AccessControlList#initialize.
|
|
321
|
-
#
|
|
322
|
-
# == Response
|
|
323
|
-
#
|
|
324
|
-
# The response contains only the standard fields.
|
|
311
|
+
# @overload set_bucket_acl(options = {})
|
|
312
|
+
# @param [Hash] options
|
|
313
|
+
# @option options [required,String] :bucket_name
|
|
314
|
+
# @option options [required,String,AccessControlList,Hash] :acl
|
|
315
|
+
# This may be any of the following:
|
|
316
|
+
# * An XML policy as a string (which is passed to S3 uninterpreted)
|
|
317
|
+
# * An {AccessControlList} object
|
|
318
|
+
# * Any object that responds to +#to_xml+
|
|
319
|
+
# * A hash that is compatible with {AccessControlList} #new.
|
|
320
|
+
# @return [Core::Response]
|
|
325
321
|
bucket_method(:set_bucket_acl, :put, 'acl') do
|
|
322
|
+
|
|
326
323
|
configure_request do |req, options|
|
|
327
324
|
require_acl!(options[:acl])
|
|
328
325
|
super(req, options)
|
|
@@ -334,40 +331,28 @@ module AWS
|
|
|
334
331
|
req.body = options[:acl].to_xml
|
|
335
332
|
end
|
|
336
333
|
end
|
|
334
|
+
|
|
337
335
|
end
|
|
338
336
|
|
|
339
|
-
##
|
|
340
337
|
# Gets the access control list for a bucket.
|
|
341
|
-
#
|
|
342
|
-
#
|
|
343
|
-
#
|
|
344
|
-
#
|
|
345
|
-
|
|
346
|
-
# == Response
|
|
347
|
-
#
|
|
348
|
-
# A successful response will have an +acl+ method that
|
|
349
|
-
# returns an instance of AccessControlList.
|
|
350
|
-
#
|
|
351
|
-
bucket_method(:get_bucket_acl, :get, 'acl',
|
|
352
|
-
XML::GetBucketAcl)
|
|
338
|
+
# @overload get_bucket_acl(options = {})
|
|
339
|
+
# @param [Hash] options
|
|
340
|
+
# @option options [required,String] :bucket_name
|
|
341
|
+
# @return [Core::Response]
|
|
342
|
+
bucket_method(:get_bucket_acl, :get, 'acl', XML::GetBucketAcl)
|
|
353
343
|
|
|
354
|
-
##
|
|
355
344
|
# Sets the access control list for an object.
|
|
356
|
-
#
|
|
357
|
-
#
|
|
358
|
-
#
|
|
359
|
-
#
|
|
360
|
-
#
|
|
361
|
-
#
|
|
362
|
-
#
|
|
363
|
-
#
|
|
364
|
-
#
|
|
365
|
-
#
|
|
366
|
-
#
|
|
367
|
-
#
|
|
368
|
-
# == Response
|
|
369
|
-
#
|
|
370
|
-
# The response contains only the standard fields.
|
|
345
|
+
# @overload set_object_acl(options = {})
|
|
346
|
+
# @param [Hash] options
|
|
347
|
+
# @option options [required,String] :bucket_name
|
|
348
|
+
# @option options [required,String] :key
|
|
349
|
+
# @option options [required,String,AccessControlList,Hash] :acl
|
|
350
|
+
# This may be any of the following:
|
|
351
|
+
# * An XML policy as a string (which is passed to S3 uninterpreted)
|
|
352
|
+
# * An {AccessControlList} object
|
|
353
|
+
# * Any object that responds to +#to_xml+
|
|
354
|
+
# * A hash that is compatible with {AccessControlList} #new.
|
|
355
|
+
# @return [Core::Response]
|
|
371
356
|
object_method(:set_object_acl, :put, 'acl') do
|
|
372
357
|
configure_request do |req, options|
|
|
373
358
|
require_acl!(options[:acl]) unless options[:acl].kind_of?(Symbol)
|
|
@@ -384,79 +369,21 @@ module AWS
|
|
|
384
369
|
end
|
|
385
370
|
end
|
|
386
371
|
|
|
387
|
-
##
|
|
388
372
|
# Gets the access control list for an object.
|
|
389
|
-
#
|
|
390
|
-
#
|
|
391
|
-
#
|
|
392
|
-
#
|
|
393
|
-
#
|
|
394
|
-
|
|
395
|
-
#
|
|
396
|
-
# == Response
|
|
397
|
-
#
|
|
398
|
-
# A successful response will have an +acl+ method that
|
|
399
|
-
# returns an instance of AccessControlList.
|
|
400
|
-
object_method(:get_object_acl, :get, 'acl',
|
|
401
|
-
XML::GetBucketAcl)
|
|
373
|
+
# @overload get_object_acl(options = {})
|
|
374
|
+
# @param [Hash] options
|
|
375
|
+
# @option options [required,String] :bucket_name
|
|
376
|
+
# @option options [required,String] :key
|
|
377
|
+
# @return [Core::Response]
|
|
378
|
+
object_method(:get_object_acl, :get, 'acl', XML::GetBucketAcl)
|
|
402
379
|
|
|
403
|
-
##
|
|
404
380
|
# Puts data into an object, replacing the current contents.
|
|
405
381
|
#
|
|
406
|
-
#
|
|
407
|
-
#
|
|
408
|
-
#
|
|
409
|
-
#
|
|
410
|
-
#
|
|
411
|
-
#
|
|
412
|
-
# * +:data+ -- The data to upload. This can be provided as an option
|
|
413
|
-
# or when using block form (see below). Valid values include:
|
|
414
|
-
#
|
|
415
|
-
# * A string
|
|
416
|
-
#
|
|
417
|
-
# * A Pathname object.
|
|
418
|
-
#
|
|
419
|
-
# * Any object with +read+ and +eof?+ methods that behave
|
|
420
|
-
# like Ruby's IO class (e.g. IO, File, Tempfile, StringIO, etc).
|
|
421
|
-
# The object must support the following access methods:
|
|
422
|
-
#
|
|
423
|
-
# read # all at once
|
|
424
|
-
# read(length) until eof? # in chunks
|
|
425
|
-
#
|
|
426
|
-
# == Optional
|
|
427
|
-
#
|
|
428
|
-
# * +:content_length+ -- Required if you are using block form to
|
|
429
|
-
# write data or if it is not possible to determine the size of
|
|
430
|
-
# +:data+. Best effort is made to determine the content length of
|
|
431
|
-
# strings, files, tempfiles, io objects, and any object that responds
|
|
432
|
-
# to #length or #size.
|
|
433
|
-
#
|
|
434
|
-
# * +:metadata+ -- A hash of metadata to be included with the
|
|
435
|
-
# object. These will be sent to S3 as headers prefixed with
|
|
436
|
-
# +x-amz-meta+.
|
|
437
|
-
#
|
|
438
|
-
# * +:acl+ -- A canned access control policy, valid values are:
|
|
439
|
-
# * +:private+
|
|
440
|
-
# * +:public_read+
|
|
441
|
-
# * ...
|
|
442
|
-
# Defaults to +:private+
|
|
443
|
-
#
|
|
444
|
-
# * +:storage_class+ -- Controls whether Reduced Redundancy
|
|
445
|
-
# Storage is enabled for the object. Valid values are
|
|
446
|
-
# +:standard+ (the default) or +:reduced_redundancy+
|
|
447
|
-
#
|
|
448
|
-
# * +:cache_control+ -- Can be used to specify caching
|
|
449
|
-
# behavior [...]
|
|
450
|
-
#
|
|
451
|
-
# * +:content_disposition+ -- Specifies presentational
|
|
452
|
-
# information [...]
|
|
453
|
-
#
|
|
454
|
-
# * +:content_encoding+ -- Specifies what content encodings
|
|
455
|
-
# have been [...]
|
|
456
|
-
#
|
|
457
|
-
# * +:content_md5+ -- The base64 encoded 128-bit [...]
|
|
458
|
-
#
|
|
459
|
-
# * +:content_type+ -- A standard MIME type describing [...]
|
|
382
|
+
# s3_client.put_object({
|
|
383
|
+
# :bucket_name => 'bucket-name',
|
|
384
|
+
# :key => 'readme.txt',
|
|
385
|
+
# :data => 'This is the readme for ...',
|
|
386
|
+
# })
|
|
460
387
|
#
|
|
461
388
|
# == Block Form
|
|
462
389
|
#
|
|
@@ -485,11 +412,45 @@ module AWS
|
|
|
485
412
|
# sure the HTTP handler you configure for the client meets
|
|
486
413
|
# your needs.
|
|
487
414
|
#
|
|
488
|
-
#
|
|
489
|
-
#
|
|
490
|
-
#
|
|
491
|
-
#
|
|
492
|
-
#
|
|
415
|
+
# @overload put_object(options = {})
|
|
416
|
+
# @param [Hash] options
|
|
417
|
+
# @option options [required,String] :bucket_name
|
|
418
|
+
# @option options [required,String] :key
|
|
419
|
+
# @option options [required,String,Pathname,File,IO] :data
|
|
420
|
+
# The data to upload. This can be provided as a string,
|
|
421
|
+
# a Pathname object, or any object that responds to
|
|
422
|
+
# +#read+ and +#eof?+ (e.g. IO, File, Tempfile, StringIO, etc).
|
|
423
|
+
# @option options [Integer] :content_length
|
|
424
|
+
# Required if you are using block form to write data or if it is
|
|
425
|
+
# not possible to determine the size of +:data+. A best effort
|
|
426
|
+
# is made to determine the content length of strings, files,
|
|
427
|
+
# tempfiles, io objects, and any object that responds
|
|
428
|
+
# to +#length+ or +#size+.
|
|
429
|
+
# @option options [Hash] :metadata
|
|
430
|
+
# A hash of metadata to be included with the
|
|
431
|
+
# object. These will be sent to S3 as headers prefixed with
|
|
432
|
+
# +x-amz-meta+.
|
|
433
|
+
# @option options [Symbol] :acl (:private) A canned access
|
|
434
|
+
# control policy. Accepted values include:
|
|
435
|
+
# * +:private+
|
|
436
|
+
# * +:public_read+
|
|
437
|
+
# * ...
|
|
438
|
+
# @option options [Symbol] :storage_class+ (:standard)
|
|
439
|
+
# Controls whether Reduced Redundancy Storage is enabled for
|
|
440
|
+
# the object. Valid values are +:standard+ and
|
|
441
|
+
# +:reduced_redundancy+.
|
|
442
|
+
# @option options [String] :cache_control
|
|
443
|
+
# Can be used to specify caching behavior.
|
|
444
|
+
# @option opitons [String] :content_disposition
|
|
445
|
+
# Specifies presentational information.
|
|
446
|
+
# @option options [String] :content_encoding
|
|
447
|
+
# Specifies the content encoding.
|
|
448
|
+
# @option options [String] :content_md5
|
|
449
|
+
# The base64 encoded content md5 of the +:data+.
|
|
450
|
+
# @option options [String] :content_type
|
|
451
|
+
# Specifies the content type.
|
|
452
|
+
# @option options [String] :expires
|
|
453
|
+
# @return [Core::Response]
|
|
493
454
|
#
|
|
494
455
|
object_method(:put_object, :put,
|
|
495
456
|
:header_options => {
|
|
@@ -514,91 +475,54 @@ module AWS
|
|
|
514
475
|
end
|
|
515
476
|
|
|
516
477
|
process_response do |response|
|
|
517
|
-
|
|
478
|
+
|
|
479
|
+
response.data[:version_id] =
|
|
518
480
|
response.http_response.header('x-amz-version-id')
|
|
481
|
+
|
|
482
|
+
response.data[:etag] = response.http_response.header('ETag')
|
|
483
|
+
|
|
484
|
+
if time = response.http_response.header('Last-Modified')
|
|
485
|
+
response.data[:last_modified] = Time.parse(time)
|
|
519
486
|
end
|
|
520
|
-
|
|
521
|
-
response.http_response.header('ETag')
|
|
522
|
-
end
|
|
523
|
-
Core::MetaUtils.extend_method(response, :last_modified) do
|
|
524
|
-
Time.parse(response.http_response.header('Last-Modified'))
|
|
525
|
-
end
|
|
487
|
+
|
|
526
488
|
add_sse_to_response(response)
|
|
527
489
|
end
|
|
528
490
|
|
|
529
491
|
simulate_response do |response|
|
|
530
|
-
|
|
531
|
-
|
|
492
|
+
response.data[:etag] = 'abc123'
|
|
493
|
+
response.data[:version_id] = nil
|
|
532
494
|
end
|
|
495
|
+
|
|
533
496
|
end
|
|
534
497
|
|
|
535
|
-
##
|
|
536
498
|
# Gets the data for a key.
|
|
499
|
+
# @overload get_object(options = {})
|
|
500
|
+
# @param [Hash] options
|
|
501
|
+
# @option options [required,String] :bucket_name
|
|
502
|
+
# @option options [required,String] :key
|
|
503
|
+
# @option options [Time] :if_modified_since If specified, the
|
|
504
|
+
# response will contain an additional +:modified+ value that
|
|
505
|
+
# returns true if the object was modified after the given
|
|
506
|
+
# time. If +:modified+ is false, then the response
|
|
507
|
+
# +:data+ value will be +nil+.
|
|
508
|
+
# @option options [Time] :if_unmodified_since If specified, the
|
|
509
|
+
# response will contain an additional +:unmodified+ value
|
|
510
|
+
# that is true if the object was not modified after the
|
|
511
|
+
# given time. If +:unmodified+ returns false, the +:data+
|
|
512
|
+
# value will be +nil+.
|
|
513
|
+
# @option options [String] :if_match If specified, the response
|
|
514
|
+
# will contain an additional +:matches+ value that is true
|
|
515
|
+
# if the object ETag matches the value for this option. If
|
|
516
|
+
# +:matches+ is false, the +:data+ value of the
|
|
517
|
+
# response will be +nil+.
|
|
518
|
+
# @option options [String] :if_none_match If specified, the
|
|
519
|
+
# response will contain an additional +:matches+ value that
|
|
520
|
+
# is true if and only if the object ETag matches the value for
|
|
521
|
+
# this option. If +:matches+ is true, the +:data+ value
|
|
522
|
+
# of the response will be +nil+.
|
|
523
|
+
# @option options [Range<Integer>] :range A byte range of data to request.
|
|
524
|
+
# @return [Core::Response]
|
|
537
525
|
#
|
|
538
|
-
# == Required Options
|
|
539
|
-
#
|
|
540
|
-
# * +:bucket_name+ -- The name of the bucket that contains the data.
|
|
541
|
-
#
|
|
542
|
-
# * +:key+ -- The key under which the data exists.
|
|
543
|
-
#
|
|
544
|
-
# == Optional
|
|
545
|
-
#
|
|
546
|
-
# * +:if_modified_since+ -- A Time object; if specified, the
|
|
547
|
-
# response will contain an additional +modified?+ method that
|
|
548
|
-
# returns true if the object was modified after the given
|
|
549
|
-
# time. If +modified?+ returns false, the +data+ method of
|
|
550
|
-
# the response will return +nil+.
|
|
551
|
-
#
|
|
552
|
-
# * +:if_unmodified_since+ -- A Time object; if specified, the
|
|
553
|
-
# response will contain an additional +unmodified?+ method
|
|
554
|
-
# that returns true if the object was not modified after the
|
|
555
|
-
# given time. If +unmodified?+ returns false, the +data+
|
|
556
|
-
# method of the response will return +nil+.
|
|
557
|
-
#
|
|
558
|
-
# * +:if_match+ -- A string; if specified, the response will
|
|
559
|
-
# contain an additional +matches?+ method that returns true
|
|
560
|
-
# if the object ETag matches the value for this option. If
|
|
561
|
-
# +matches?+ returns false, the +data+ method of the
|
|
562
|
-
# response will return +nil+.
|
|
563
|
-
#
|
|
564
|
-
# * +:if_none_match+ -- A string; if specified, the response
|
|
565
|
-
# will contain an additional +matches?+ method that returns
|
|
566
|
-
# true if and only if the object ETag matches the value for
|
|
567
|
-
# this option. If +matches?+ returns true, the +data+
|
|
568
|
-
# method of the response will return +nil+.
|
|
569
|
-
#
|
|
570
|
-
# * +:to+ -- A destination for the data. Valid values:
|
|
571
|
-
#
|
|
572
|
-
# * The path to a file as a string
|
|
573
|
-
#
|
|
574
|
-
# * A Pathname object
|
|
575
|
-
#
|
|
576
|
-
# * Any object that supports <code>write(data)</code> and
|
|
577
|
-
# +close+ methods like Ruby's IO class
|
|
578
|
-
#
|
|
579
|
-
# * +:range+ -- TODO: figure out the format for this
|
|
580
|
-
# parameter.
|
|
581
|
-
#
|
|
582
|
-
# == Response
|
|
583
|
-
#
|
|
584
|
-
# A successful response will have some combination of the
|
|
585
|
-
# following methods:
|
|
586
|
-
#
|
|
587
|
-
# * +data+ -- The object data as a string. This will return
|
|
588
|
-
# +nil+ if one of the conditional options above is specified
|
|
589
|
-
# and the condition is not met. It will also return +nil+
|
|
590
|
-
# if +deleted?+ returns true. It will not be present if the
|
|
591
|
-
# +:to+ option is specified.
|
|
592
|
-
#
|
|
593
|
-
# * +modified?+, +unmodified?+, +matches?+ -- These will be
|
|
594
|
-
# present as documented in the conditional options above.
|
|
595
|
-
#
|
|
596
|
-
# * +version_id+ -- Returns the version ID of the object that
|
|
597
|
-
# was written (only for versioned buckets).
|
|
598
|
-
#
|
|
599
|
-
# * +deleted?+ -- This will return +true+ if the bucket has
|
|
600
|
-
# versioning enabled and the object retrieved was a delete
|
|
601
|
-
# marker.
|
|
602
526
|
object_method(:get_object, :get,
|
|
603
527
|
:header_options => {
|
|
604
528
|
:if_modified_since => "If-Modified-Since",
|
|
@@ -633,15 +557,20 @@ module AWS
|
|
|
633
557
|
end
|
|
634
558
|
|
|
635
559
|
process_response do |resp|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
http_response.header('x-amz-version-id')
|
|
639
|
-
end
|
|
560
|
+
resp.data[:data] = resp.http_response.body
|
|
561
|
+
resp.data[:version_id] = resp.http_response.header('x-amz-version-id')
|
|
640
562
|
add_sse_to_response(resp)
|
|
641
563
|
end
|
|
642
564
|
end
|
|
643
565
|
|
|
566
|
+
# @overload head_object(options = {})
|
|
567
|
+
# @param [Hash] options
|
|
568
|
+
# @option options [required,String] :bucket_name
|
|
569
|
+
# @option options [required,String] :key
|
|
570
|
+
# @option options [String] :version_id
|
|
571
|
+
# @return [Core::Response]
|
|
644
572
|
object_method(:head_object, :head) do
|
|
573
|
+
|
|
645
574
|
configure_request do |req, options|
|
|
646
575
|
super(req, options)
|
|
647
576
|
if options[:version_id]
|
|
@@ -652,51 +581,55 @@ module AWS
|
|
|
652
581
|
process_response do |resp|
|
|
653
582
|
|
|
654
583
|
# create a hash of user-supplied metadata
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
meta[$1] = [value].flatten.join
|
|
660
|
-
end
|
|
584
|
+
meta = {}
|
|
585
|
+
resp.http_response.headers.each_pair do |name,value|
|
|
586
|
+
if name =~ /^x-amz-meta-(.+)$/i
|
|
587
|
+
meta[$1] = [value].flatten.join
|
|
661
588
|
end
|
|
662
|
-
meta
|
|
663
589
|
end
|
|
590
|
+
meta
|
|
591
|
+
resp.data[:meta] = meta
|
|
664
592
|
|
|
665
593
|
if expiry = resp.http_response.headers['x-amz-expiration']
|
|
666
594
|
expiry.first =~ /^expiry-date="(.+)", rule-id="(.+)"$/
|
|
667
|
-
|
|
668
|
-
|
|
595
|
+
exp_date = DateTime.parse($1)
|
|
596
|
+
exp_rule_id = $2
|
|
669
597
|
else
|
|
670
|
-
|
|
671
|
-
|
|
598
|
+
exp_date = nil
|
|
599
|
+
exp_rule_id = nil
|
|
672
600
|
end
|
|
673
|
-
Core::MetaUtils.extend_method(resp, :expiration_date) { date }
|
|
674
|
-
Core::MetaUtils.extend_method(resp, :expiration_rule_id) { rule_id }
|
|
675
601
|
|
|
676
|
-
|
|
602
|
+
resp.data[:expiration_date] = exp_date
|
|
603
|
+
resp.data[:expiration_rule_id] = exp_rule_id
|
|
604
|
+
|
|
677
605
|
{
|
|
678
606
|
'x-amz-version-id' => :version_id,
|
|
679
607
|
'content-type' => :content_type,
|
|
680
608
|
'etag' => :etag,
|
|
681
609
|
}.each_pair do |header,method|
|
|
682
|
-
|
|
683
|
-
http_response.header(header)
|
|
684
|
-
end
|
|
610
|
+
resp.data[method] = resp.http_response.header(header)
|
|
685
611
|
end
|
|
686
612
|
|
|
687
|
-
|
|
688
|
-
Time.parse(
|
|
613
|
+
if time = resp.http_response.header('Last-Modified')
|
|
614
|
+
resp.data[:last_modified] = Time.parse(time)
|
|
689
615
|
end
|
|
690
616
|
|
|
691
|
-
|
|
692
|
-
http_response.header('content-length').to_i
|
|
693
|
-
end
|
|
617
|
+
resp.data[:content_length] =
|
|
618
|
+
resp.http_response.header('content-length').to_i
|
|
694
619
|
|
|
695
620
|
add_sse_to_response(resp)
|
|
621
|
+
|
|
696
622
|
end
|
|
697
623
|
end
|
|
698
624
|
|
|
625
|
+
# @overload delete_object(options = {})
|
|
626
|
+
# @param [Hash] options
|
|
627
|
+
# @option options [required,String] :bucket_name
|
|
628
|
+
# @option options [required,String] :key
|
|
629
|
+
# @option options [String] :version_id
|
|
630
|
+
# @return [Core::Response]
|
|
699
631
|
object_method(:delete_object, :delete) do
|
|
632
|
+
|
|
700
633
|
configure_request do |req, options|
|
|
701
634
|
super(req, options)
|
|
702
635
|
if options[:version_id]
|
|
@@ -705,13 +638,19 @@ module AWS
|
|
|
705
638
|
end
|
|
706
639
|
|
|
707
640
|
process_response do |resp|
|
|
708
|
-
|
|
709
|
-
http_response.header('x-amz-version-id')
|
|
710
|
-
end
|
|
641
|
+
resp.data[:version_id] = resp.http_response.header('x-amz-version-id')
|
|
711
642
|
end
|
|
712
643
|
|
|
713
644
|
end
|
|
714
645
|
|
|
646
|
+
# @overload list_objects(options = {})
|
|
647
|
+
# @param [Hash] options
|
|
648
|
+
# @option options [required,String] :bucket_name
|
|
649
|
+
# @option options [String] :delimiter
|
|
650
|
+
# @option options [String] :marker
|
|
651
|
+
# @option options [String] :max_keys
|
|
652
|
+
# @option options [String] :prefix
|
|
653
|
+
# @return [Core::Response]
|
|
715
654
|
bucket_method(:list_objects, :get, XML::ListObjects) do
|
|
716
655
|
configure_request do |req, options|
|
|
717
656
|
super(req, options)
|
|
@@ -724,6 +663,22 @@ module AWS
|
|
|
724
663
|
end
|
|
725
664
|
end
|
|
726
665
|
|
|
666
|
+
alias_method :get_bucket, :list_objects
|
|
667
|
+
|
|
668
|
+
# @overload initiate_multipart_upload(options = {})
|
|
669
|
+
# @param [Hash] options
|
|
670
|
+
# @option options [required,String] :bucket_name
|
|
671
|
+
# @option options [required,String] :key
|
|
672
|
+
# @option options [Hash] :metadata
|
|
673
|
+
# @option options [Symbol] :acl
|
|
674
|
+
# @option options [String] :cache_control
|
|
675
|
+
# @option options [String] :content_disposition
|
|
676
|
+
# @option options [String] :content_encoding
|
|
677
|
+
# @option options [String] :content_type
|
|
678
|
+
# @option options [String] :storage_class
|
|
679
|
+
# @option options [String] :server_side_encryption
|
|
680
|
+
# @option options [String] :expires
|
|
681
|
+
# @return [Core::Response]
|
|
727
682
|
object_method(:initiate_multipart_upload, :post, 'uploads',
|
|
728
683
|
XML::InitiateMultipartUpload,
|
|
729
684
|
:header_options => {
|
|
@@ -750,6 +705,16 @@ module AWS
|
|
|
750
705
|
end
|
|
751
706
|
end
|
|
752
707
|
|
|
708
|
+
# @overload list_multipart_uploads(options = {})
|
|
709
|
+
# @param [Hash] options
|
|
710
|
+
# @option options [required,String] :bucket_name
|
|
711
|
+
# @option options [String] :delimiter
|
|
712
|
+
# @option options [String] :key_marker
|
|
713
|
+
# @option options [String] :max_keys
|
|
714
|
+
# @option options [String] :upload_id_marker
|
|
715
|
+
# @option options [String] :max_uploads
|
|
716
|
+
# @option options [String] :prefix
|
|
717
|
+
# @return [Core::Response]
|
|
753
718
|
bucket_method(:list_multipart_uploads,
|
|
754
719
|
:get, 'uploads',
|
|
755
720
|
XML::ListMultipartUploads) do
|
|
@@ -765,6 +730,12 @@ module AWS
|
|
|
765
730
|
end
|
|
766
731
|
end
|
|
767
732
|
|
|
733
|
+
# @overload delete_objects(options = {})
|
|
734
|
+
# @param [Hash] options
|
|
735
|
+
# @option options [required,String] :bucket_name
|
|
736
|
+
# @option options [required,Array<String>] :keys
|
|
737
|
+
# @option options [Boolean] :quiet (true)
|
|
738
|
+
# @return [Core::Response]
|
|
768
739
|
bucket_method(:delete_objects, :post, 'delete', XML::DeleteObjects) do
|
|
769
740
|
configure_request do |req, options|
|
|
770
741
|
|
|
@@ -772,7 +743,10 @@ module AWS
|
|
|
772
743
|
|
|
773
744
|
quiet = options.key?(:quiet) ? options[:quiet] : true
|
|
774
745
|
|
|
775
|
-
|
|
746
|
+
# previously named this option :objects, since renamed
|
|
747
|
+
keys = options[:objects] || options[:keys]
|
|
748
|
+
|
|
749
|
+
objects = keys.inject('') do |xml,o|
|
|
776
750
|
xml << "<Object><Key>#{o[:key]}</Key>"
|
|
777
751
|
xml << "<VersionId>#{o[:version_id]}</VersionId>" if o[:version_id]
|
|
778
752
|
xml << "</Object>"
|
|
@@ -790,6 +764,17 @@ module AWS
|
|
|
790
764
|
end
|
|
791
765
|
end
|
|
792
766
|
|
|
767
|
+
# @overload upload_part(options = {})
|
|
768
|
+
# @param [Hash] options
|
|
769
|
+
# @option options [required,String] :bucket_name
|
|
770
|
+
# @option options [required,String] :key
|
|
771
|
+
# @option options [required,String,Pathname,File,IO] :data
|
|
772
|
+
# The data to upload. This can be provided as a string,
|
|
773
|
+
# a Pathname object, or any object that responds to
|
|
774
|
+
# +#read+ and +#eof?+ (e.g. IO, File, Tempfile, StringIO, etc).
|
|
775
|
+
# @option options [required,String] :upload_id
|
|
776
|
+
# @option options [required,Integer] :part_number
|
|
777
|
+
# @return [Core::Response]
|
|
793
778
|
object_method(:upload_part, :put,
|
|
794
779
|
:header_options => {
|
|
795
780
|
:content_md5 => 'Content-MD5'
|
|
@@ -806,20 +791,25 @@ module AWS
|
|
|
806
791
|
end
|
|
807
792
|
|
|
808
793
|
process_response do |response|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
Core::MetaUtils.extend_method(response, :last_modified) do
|
|
813
|
-
Time.parse(response.http_response.header('Last-Modified'))
|
|
794
|
+
response.data[:etag] = response.http_response.header('ETag')
|
|
795
|
+
if time = response.http_response.header('Last-Modified')
|
|
796
|
+
response.data[:last_modified] = Time.parse(time)
|
|
814
797
|
end
|
|
815
798
|
add_sse_to_response(response)
|
|
816
799
|
end
|
|
817
800
|
|
|
818
801
|
simulate_response do |response|
|
|
819
|
-
|
|
802
|
+
response.data[:etag] = 'abc123'
|
|
820
803
|
end
|
|
821
804
|
end
|
|
822
805
|
|
|
806
|
+
# @overload complete_multipart_upload(options = {})
|
|
807
|
+
# @param [Hash] options
|
|
808
|
+
# @option options [required,String] :bucket_name
|
|
809
|
+
# @option options [required,String] :key
|
|
810
|
+
# @option options [required,String] :upload_id
|
|
811
|
+
# @option options [required,Array<String>] :parts
|
|
812
|
+
# @return [Core::Response]
|
|
823
813
|
object_method(:complete_multipart_upload, :post,
|
|
824
814
|
XML::CompleteMultipartUpload) do
|
|
825
815
|
configure_request do |req, options|
|
|
@@ -838,17 +828,22 @@ module AWS
|
|
|
838
828
|
end
|
|
839
829
|
|
|
840
830
|
process_response do |response|
|
|
841
|
-
Core::MetaUtils.extend_method(response, :version_id) do
|
|
842
|
-
response.http_response.header('x-amz-version-id')
|
|
843
|
-
end
|
|
844
831
|
add_sse_to_response(response)
|
|
832
|
+
response.data[:version_id] =
|
|
833
|
+
response.http_response.header('x-amz-version-id')
|
|
845
834
|
end
|
|
846
835
|
|
|
847
836
|
simulate_response do |response|
|
|
848
|
-
|
|
837
|
+
response.data[:version_id] = nil
|
|
849
838
|
end
|
|
850
839
|
end
|
|
851
840
|
|
|
841
|
+
# @overload abort_multipart_upload(options = {})
|
|
842
|
+
# @param [Hash] options
|
|
843
|
+
# @option options [required,String] :bucket_name
|
|
844
|
+
# @option options [required,String] :key
|
|
845
|
+
# @option options [required,String] :upload_id
|
|
846
|
+
# @return [Core::Response]
|
|
852
847
|
object_method(:abort_multipart_upload, :delete) do
|
|
853
848
|
configure_request do |req, options|
|
|
854
849
|
require_upload_id!(options[:upload_id])
|
|
@@ -857,8 +852,16 @@ module AWS
|
|
|
857
852
|
end
|
|
858
853
|
end
|
|
859
854
|
|
|
860
|
-
|
|
861
|
-
|
|
855
|
+
# @overload list_parts(options = {})
|
|
856
|
+
# @param [Hash] options
|
|
857
|
+
# @option options [required,String] :bucket_name
|
|
858
|
+
# @option options [required,String] :key
|
|
859
|
+
# @option options [required,String] :upload_id
|
|
860
|
+
# @option options [Integer] :max_parts
|
|
861
|
+
# @option options [Integer] :part_number_marker
|
|
862
|
+
# @return [Core::Response]
|
|
863
|
+
object_method(:list_parts, :get, XML::ListParts) do
|
|
864
|
+
|
|
862
865
|
configure_request do |req, options|
|
|
863
866
|
require_upload_id!(options[:upload_id])
|
|
864
867
|
super(req, options)
|
|
@@ -866,21 +869,22 @@ module AWS
|
|
|
866
869
|
req.add_param('max-parts', options[:max_parts])
|
|
867
870
|
req.add_param('part-number-marker', options[:part_number_marker])
|
|
868
871
|
end
|
|
872
|
+
|
|
869
873
|
end
|
|
870
874
|
|
|
871
|
-
|
|
872
|
-
# @
|
|
873
|
-
#
|
|
874
|
-
#
|
|
875
|
-
#
|
|
876
|
-
#
|
|
877
|
-
#
|
|
878
|
-
#
|
|
879
|
-
#
|
|
880
|
-
#
|
|
881
|
-
#
|
|
882
|
-
#
|
|
883
|
-
#
|
|
875
|
+
# Copies an object from one key to another.
|
|
876
|
+
# @overload copy_object(options = {})
|
|
877
|
+
# @param [Hash] options
|
|
878
|
+
# @option options [required, String] :bucket_name Name of the bucket
|
|
879
|
+
# to copy a object into.
|
|
880
|
+
# @option options [required, String] :key Where (object key) in the
|
|
881
|
+
# bucket the object should be copied to.
|
|
882
|
+
# @option options [required, String] :copy_source The source
|
|
883
|
+
# bucket name and key, joined by a forward slash ('/').
|
|
884
|
+
# This string must be URL-encoded. Additionally, you must
|
|
885
|
+
# have read access to the source object.
|
|
886
|
+
# @option options [Symbol] :acl
|
|
887
|
+
# @return [Core::Response]
|
|
884
888
|
object_method(:copy_object, :put,
|
|
885
889
|
:header_options => {
|
|
886
890
|
:copy_source => 'x-amz-copy-source',
|
|
@@ -912,14 +916,11 @@ module AWS
|
|
|
912
916
|
end
|
|
913
917
|
|
|
914
918
|
process_response do |response|
|
|
915
|
-
|
|
919
|
+
response.data[:version_id] =
|
|
916
920
|
response.http_response.header('x-amz-version-id')
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
response.
|
|
920
|
-
end
|
|
921
|
-
Core::MetaUtils.extend_method(response, :last_modified) do
|
|
922
|
-
Time.parse(response.http_response.header('Last-Modified'))
|
|
921
|
+
response.data[:etag] = response.http_response.header('ETag')
|
|
922
|
+
if time = response.http_response.header('Last-Modified')
|
|
923
|
+
response.data[:last_modified] = Time.parse(time)
|
|
923
924
|
end
|
|
924
925
|
add_sse_to_response(response)
|
|
925
926
|
end
|
|
@@ -927,59 +928,60 @@ module AWS
|
|
|
927
928
|
end
|
|
928
929
|
|
|
929
930
|
protected
|
|
930
|
-
|
|
931
|
-
|
|
931
|
+
|
|
932
|
+
def extract_error_details response
|
|
933
|
+
if
|
|
934
|
+
(response.http_response.status >= 300 ||
|
|
932
935
|
response.request_type == :complete_multipart_upload) and
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
936
|
+
body = response.http_response.body and
|
|
937
|
+
error = Core::XML::Parser.parse(body) and
|
|
938
|
+
error[:code]
|
|
939
|
+
then
|
|
940
|
+
[error[:code], error[:message]]
|
|
937
941
|
end
|
|
938
942
|
end
|
|
939
943
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
944
|
+
# There are a few of s3 requests that can generate empty bodies and
|
|
945
|
+
# yet still be errors. These return empty bodies to comply with the
|
|
946
|
+
# HTTP spec. We have to detect these errors specially.
|
|
947
|
+
def populate_error resp
|
|
948
|
+
code = resp.http_response.status
|
|
949
|
+
if EMPTY_BODY_ERRORS.include?(code) and resp.http_response.body.nil?
|
|
950
|
+
error_class = EMPTY_BODY_ERRORS[code]
|
|
951
|
+
resp.error = error_class.new(resp.http_request, resp.http_response)
|
|
948
952
|
else
|
|
949
953
|
super
|
|
950
954
|
end
|
|
951
955
|
end
|
|
952
956
|
|
|
953
|
-
protected
|
|
954
957
|
def should_retry? response
|
|
955
958
|
super or
|
|
956
959
|
response.request_type == :complete_multipart_upload &&
|
|
957
|
-
|
|
960
|
+
extract_error_details(response)
|
|
961
|
+
# complete multipart upload can return an error inside a
|
|
962
|
+
# 200 level response -- this forces us to parse the
|
|
963
|
+
# response for errors every time
|
|
958
964
|
end
|
|
959
965
|
|
|
960
|
-
protected
|
|
961
966
|
def set_request_data request, options, block
|
|
962
967
|
request.body_stream = data_stream_from(options, &block)
|
|
963
968
|
request.headers['Content-Length'] = content_length_from(options)
|
|
964
969
|
end
|
|
965
970
|
|
|
966
|
-
protected
|
|
967
971
|
def new_request
|
|
968
972
|
S3::Request.new
|
|
969
973
|
end
|
|
970
974
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
if value = response.http_response.header('x-amz-server-side-encryption')
|
|
975
|
-
sse = value.downcase.to_sym
|
|
975
|
+
def add_sse_to_response response
|
|
976
|
+
if sse = response.http_response.header('x-amz-server-side-encryption')
|
|
977
|
+
sse = sse.downcase.to_sym
|
|
976
978
|
end
|
|
977
|
-
|
|
979
|
+
response.data[:server_side_encryption] = sse
|
|
978
980
|
end
|
|
979
981
|
|
|
980
982
|
module Validators
|
|
981
983
|
|
|
982
|
-
# Returns true if the given bucket name is valid.
|
|
984
|
+
# @return [Boolean] Returns true if the given bucket name is valid.
|
|
983
985
|
def valid_bucket_name?(bucket_name)
|
|
984
986
|
validate_bucket_name!(bucket_name) rescue false
|
|
985
987
|
end
|
|
@@ -998,6 +1000,7 @@ module AWS
|
|
|
998
1000
|
# @return [Boolean] Returns true if the given bucket name may be
|
|
999
1001
|
# is dns compatible.
|
|
1000
1002
|
# this bucket n
|
|
1003
|
+
#
|
|
1001
1004
|
def dns_compatible_bucket_name?(bucket_name)
|
|
1002
1005
|
return false if
|
|
1003
1006
|
!valid_bucket_name?(bucket_name) or
|
|
@@ -1034,6 +1037,7 @@ module AWS
|
|
|
1034
1037
|
# @return [Boolean] Returns true if the bucket name should be used
|
|
1035
1038
|
# as a path segement instead of dns prefix when making requests
|
|
1036
1039
|
# against s3.
|
|
1040
|
+
#
|
|
1037
1041
|
def path_style_bucket_name? bucket_name
|
|
1038
1042
|
if dns_compatible_bucket_name?(bucket_name)
|
|
1039
1043
|
bucket_name =~ /\./ ? true : false
|
|
@@ -1042,7 +1046,6 @@ module AWS
|
|
|
1042
1046
|
end
|
|
1043
1047
|
end
|
|
1044
1048
|
|
|
1045
|
-
protected
|
|
1046
1049
|
def validate! name, value, &block
|
|
1047
1050
|
if error_msg = yield
|
|
1048
1051
|
raise ArgumentError, "#{name} #{error_msg}"
|
|
@@ -1050,7 +1053,6 @@ module AWS
|
|
|
1050
1053
|
value
|
|
1051
1054
|
end
|
|
1052
1055
|
|
|
1053
|
-
protected
|
|
1054
1056
|
def validate_key!(key)
|
|
1055
1057
|
validate!('key', key) do
|
|
1056
1058
|
case
|
|
@@ -1060,17 +1062,14 @@ module AWS
|
|
|
1060
1062
|
end
|
|
1061
1063
|
end
|
|
1062
1064
|
|
|
1063
|
-
protected
|
|
1064
1065
|
def require_bucket_name! bucket_name
|
|
1065
1066
|
if [nil, ''].include?(bucket_name)
|
|
1066
1067
|
raise ArgumentError, "bucket_name may not be blank"
|
|
1067
1068
|
end
|
|
1068
1069
|
end
|
|
1069
1070
|
|
|
1070
|
-
|
|
1071
1071
|
# Returns true if the given bucket name is valid. If the name
|
|
1072
1072
|
# is invalid, an ArgumentError is raised.
|
|
1073
|
-
protected
|
|
1074
1073
|
def validate_bucket_name!(bucket_name)
|
|
1075
1074
|
validate!('bucket_name', bucket_name) do
|
|
1076
1075
|
case
|
|
@@ -1091,7 +1090,6 @@ module AWS
|
|
|
1091
1090
|
end
|
|
1092
1091
|
end
|
|
1093
1092
|
|
|
1094
|
-
protected
|
|
1095
1093
|
def require_policy!(policy)
|
|
1096
1094
|
validate!('policy', policy) do
|
|
1097
1095
|
case
|
|
@@ -1103,7 +1101,6 @@ module AWS
|
|
|
1103
1101
|
end
|
|
1104
1102
|
end
|
|
1105
1103
|
|
|
1106
|
-
protected
|
|
1107
1104
|
def require_acl!(acl)
|
|
1108
1105
|
validate!('acl', acl) do
|
|
1109
1106
|
case
|
|
@@ -1120,14 +1117,12 @@ module AWS
|
|
|
1120
1117
|
end
|
|
1121
1118
|
end
|
|
1122
1119
|
|
|
1123
|
-
protected
|
|
1124
1120
|
def require_upload_id!(upload_id)
|
|
1125
1121
|
validate!("upload_id", upload_id) do
|
|
1126
1122
|
"must not be blank" if upload_id.to_s.empty?
|
|
1127
1123
|
end
|
|
1128
1124
|
end
|
|
1129
1125
|
|
|
1130
|
-
protected
|
|
1131
1126
|
def validate_parts!(parts)
|
|
1132
1127
|
validate!("parts", parts) do
|
|
1133
1128
|
if !parts.kind_of?(Array)
|
|
@@ -1146,7 +1141,6 @@ module AWS
|
|
|
1146
1141
|
end
|
|
1147
1142
|
end
|
|
1148
1143
|
|
|
1149
|
-
protected
|
|
1150
1144
|
def json_validation_message(obj)
|
|
1151
1145
|
if obj.respond_to?(:to_str)
|
|
1152
1146
|
obj = obj.to_str
|
|
@@ -1163,7 +1157,6 @@ module AWS
|
|
|
1163
1157
|
"contains invalid JSON: #{error}" if error
|
|
1164
1158
|
end
|
|
1165
1159
|
|
|
1166
|
-
protected
|
|
1167
1160
|
def xml_validation_message(obj)
|
|
1168
1161
|
if obj.respond_to?(:to_str)
|
|
1169
1162
|
obj = obj.to_str
|