aws-sdk 1.0.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 +6 -0
- data/LICENSE.txt +171 -0
- data/NOTICE.txt +2 -0
- data/README.rdoc +189 -0
- data/lib/aws-sdk.rb +14 -0
- data/lib/aws.rb +63 -0
- data/lib/aws/api_config.rb +45 -0
- data/lib/aws/api_config/.document +0 -0
- data/lib/aws/api_config/EC2-2011-02-28.yml +2314 -0
- data/lib/aws/api_config/SNS-2010-03-31.yml +171 -0
- data/lib/aws/api_config/SQS-2009-02-01.yml +161 -0
- data/lib/aws/api_config/SimpleDB-2009-04-15.yml +278 -0
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +147 -0
- data/lib/aws/api_config_transform.rb +32 -0
- data/lib/aws/async_handle.rb +90 -0
- data/lib/aws/authorize_v2.rb +37 -0
- data/lib/aws/authorize_v3.rb +37 -0
- data/lib/aws/base_client.rb +524 -0
- data/lib/aws/cacheable.rb +92 -0
- data/lib/aws/common.rb +228 -0
- data/lib/aws/configurable.rb +36 -0
- data/lib/aws/configuration.rb +272 -0
- data/lib/aws/configured_client_methods.rb +81 -0
- data/lib/aws/configured_grammars.rb +65 -0
- data/lib/aws/configured_option_grammars.rb +46 -0
- data/lib/aws/configured_xml_grammars.rb +47 -0
- data/lib/aws/default_signer.rb +38 -0
- data/lib/aws/ec2.rb +321 -0
- data/lib/aws/ec2/attachment.rb +149 -0
- data/lib/aws/ec2/attachment_collection.rb +57 -0
- data/lib/aws/ec2/availability_zone.rb +80 -0
- data/lib/aws/ec2/availability_zone_collection.rb +47 -0
- data/lib/aws/ec2/block_device_mappings.rb +53 -0
- data/lib/aws/ec2/client.rb +54 -0
- data/lib/aws/ec2/client/xml.rb +127 -0
- data/lib/aws/ec2/collection.rb +39 -0
- data/lib/aws/ec2/config_transform.rb +63 -0
- data/lib/aws/ec2/elastic_ip.rb +107 -0
- data/lib/aws/ec2/elastic_ip_collection.rb +85 -0
- data/lib/aws/ec2/errors.rb +29 -0
- data/lib/aws/ec2/filtered_collection.rb +65 -0
- data/lib/aws/ec2/has_permissions.rb +46 -0
- data/lib/aws/ec2/image.rb +245 -0
- data/lib/aws/ec2/image_collection.rb +235 -0
- data/lib/aws/ec2/instance.rb +515 -0
- data/lib/aws/ec2/instance_collection.rb +276 -0
- data/lib/aws/ec2/key_pair.rb +86 -0
- data/lib/aws/ec2/key_pair_collection.rb +102 -0
- data/lib/aws/ec2/permission_collection.rb +177 -0
- data/lib/aws/ec2/region.rb +81 -0
- data/lib/aws/ec2/region_collection.rb +55 -0
- data/lib/aws/ec2/request.rb +27 -0
- data/lib/aws/ec2/reserved_instances.rb +50 -0
- data/lib/aws/ec2/reserved_instances_collection.rb +44 -0
- data/lib/aws/ec2/reserved_instances_offering.rb +55 -0
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +43 -0
- data/lib/aws/ec2/resource.rb +340 -0
- data/lib/aws/ec2/resource_tag_collection.rb +218 -0
- data/lib/aws/ec2/security_group.rb +246 -0
- data/lib/aws/ec2/security_group/ip_permission.rb +70 -0
- data/lib/aws/ec2/security_group/ip_permission_collection.rb +59 -0
- data/lib/aws/ec2/security_group_collection.rb +132 -0
- data/lib/aws/ec2/snapshot.rb +138 -0
- data/lib/aws/ec2/snapshot_collection.rb +90 -0
- data/lib/aws/ec2/tag.rb +88 -0
- data/lib/aws/ec2/tag_collection.rb +114 -0
- data/lib/aws/ec2/tagged_collection.rb +48 -0
- data/lib/aws/ec2/tagged_item.rb +87 -0
- data/lib/aws/ec2/volume.rb +190 -0
- data/lib/aws/ec2/volume_collection.rb +95 -0
- data/lib/aws/errors.rb +129 -0
- data/lib/aws/http/builtin_handler.rb +69 -0
- data/lib/aws/http/curb_handler.rb +123 -0
- data/lib/aws/http/handler.rb +77 -0
- data/lib/aws/http/httparty_handler.rb +61 -0
- data/lib/aws/http/request.rb +136 -0
- data/lib/aws/http/request_param.rb +63 -0
- data/lib/aws/http/response.rb +75 -0
- data/lib/aws/ignore_result_element.rb +38 -0
- data/lib/aws/indifferent_hash.rb +86 -0
- data/lib/aws/inflection.rb +46 -0
- data/lib/aws/lazy_error_classes.rb +64 -0
- data/lib/aws/meta_utils.rb +43 -0
- data/lib/aws/model.rb +57 -0
- data/lib/aws/naming.rb +32 -0
- data/lib/aws/option_grammar.rb +544 -0
- data/lib/aws/policy.rb +912 -0
- data/lib/aws/rails.rb +209 -0
- data/lib/aws/record.rb +79 -0
- data/lib/aws/record/attribute.rb +94 -0
- data/lib/aws/record/attribute_macros.rb +288 -0
- data/lib/aws/record/attributes/boolean.rb +49 -0
- data/lib/aws/record/attributes/datetime.rb +86 -0
- data/lib/aws/record/attributes/float.rb +48 -0
- data/lib/aws/record/attributes/integer.rb +68 -0
- data/lib/aws/record/attributes/sortable_float.rb +60 -0
- data/lib/aws/record/attributes/sortable_integer.rb +95 -0
- data/lib/aws/record/attributes/string.rb +69 -0
- data/lib/aws/record/base.rb +728 -0
- data/lib/aws/record/conversion.rb +38 -0
- data/lib/aws/record/dirty_tracking.rb +286 -0
- data/lib/aws/record/errors.rb +153 -0
- data/lib/aws/record/exceptions.rb +48 -0
- data/lib/aws/record/finder_methods.rb +262 -0
- data/lib/aws/record/naming.rb +31 -0
- data/lib/aws/record/scope.rb +157 -0
- data/lib/aws/record/validations.rb +653 -0
- data/lib/aws/record/validator.rb +237 -0
- data/lib/aws/record/validators/acceptance.rb +51 -0
- data/lib/aws/record/validators/block.rb +38 -0
- data/lib/aws/record/validators/confirmation.rb +43 -0
- data/lib/aws/record/validators/count.rb +108 -0
- data/lib/aws/record/validators/exclusion.rb +43 -0
- data/lib/aws/record/validators/format.rb +57 -0
- data/lib/aws/record/validators/inclusion.rb +56 -0
- data/lib/aws/record/validators/length.rb +107 -0
- data/lib/aws/record/validators/numericality.rb +138 -0
- data/lib/aws/record/validators/presence.rb +45 -0
- data/lib/aws/resource_cache.rb +39 -0
- data/lib/aws/response.rb +113 -0
- data/lib/aws/response_cache.rb +50 -0
- data/lib/aws/s3.rb +109 -0
- data/lib/aws/s3/access_control_list.rb +252 -0
- data/lib/aws/s3/acl_object.rb +266 -0
- data/lib/aws/s3/bucket.rb +320 -0
- data/lib/aws/s3/bucket_collection.rb +122 -0
- data/lib/aws/s3/bucket_version_collection.rb +85 -0
- data/lib/aws/s3/client.rb +999 -0
- data/lib/aws/s3/client/xml.rb +190 -0
- data/lib/aws/s3/data_options.rb +99 -0
- data/lib/aws/s3/errors.rb +43 -0
- data/lib/aws/s3/multipart_upload.rb +318 -0
- data/lib/aws/s3/multipart_upload_collection.rb +78 -0
- data/lib/aws/s3/object_collection.rb +159 -0
- data/lib/aws/s3/object_metadata.rb +67 -0
- data/lib/aws/s3/object_upload_collection.rb +83 -0
- data/lib/aws/s3/object_version.rb +141 -0
- data/lib/aws/s3/object_version_collection.rb +78 -0
- data/lib/aws/s3/paginated_collection.rb +94 -0
- data/lib/aws/s3/policy.rb +76 -0
- data/lib/aws/s3/prefix_and_delimiter_collection.rb +56 -0
- data/lib/aws/s3/prefixed_collection.rb +84 -0
- data/lib/aws/s3/presigned_post.rb +504 -0
- data/lib/aws/s3/request.rb +198 -0
- data/lib/aws/s3/s3_object.rb +794 -0
- data/lib/aws/s3/tree.rb +116 -0
- data/lib/aws/s3/tree/branch_node.rb +71 -0
- data/lib/aws/s3/tree/child_collection.rb +108 -0
- data/lib/aws/s3/tree/leaf_node.rb +99 -0
- data/lib/aws/s3/tree/node.rb +22 -0
- data/lib/aws/s3/tree/parent.rb +90 -0
- data/lib/aws/s3/uploaded_part.rb +82 -0
- data/lib/aws/s3/uploaded_part_collection.rb +86 -0
- data/lib/aws/service_interface.rb +60 -0
- data/lib/aws/simple_db.rb +202 -0
- data/lib/aws/simple_db/attribute.rb +159 -0
- data/lib/aws/simple_db/attribute_collection.rb +227 -0
- data/lib/aws/simple_db/client.rb +52 -0
- data/lib/aws/simple_db/client/options.rb +34 -0
- data/lib/aws/simple_db/client/xml.rb +68 -0
- data/lib/aws/simple_db/consistent_read_option.rb +42 -0
- data/lib/aws/simple_db/delete_attributes.rb +64 -0
- data/lib/aws/simple_db/domain.rb +118 -0
- data/lib/aws/simple_db/domain_collection.rb +116 -0
- data/lib/aws/simple_db/domain_metadata.rb +112 -0
- data/lib/aws/simple_db/errors.rb +46 -0
- data/lib/aws/simple_db/expect_condition_option.rb +45 -0
- data/lib/aws/simple_db/item.rb +84 -0
- data/lib/aws/simple_db/item_collection.rb +594 -0
- data/lib/aws/simple_db/item_data.rb +70 -0
- data/lib/aws/simple_db/put_attributes.rb +62 -0
- data/lib/aws/simple_db/request.rb +27 -0
- data/lib/aws/simple_email_service.rb +373 -0
- data/lib/aws/simple_email_service/client.rb +39 -0
- data/lib/aws/simple_email_service/client/options.rb +24 -0
- data/lib/aws/simple_email_service/client/xml.rb +38 -0
- data/lib/aws/simple_email_service/email_address_collection.rb +66 -0
- data/lib/aws/simple_email_service/errors.rb +29 -0
- data/lib/aws/simple_email_service/quotas.rb +64 -0
- data/lib/aws/simple_email_service/request.rb +27 -0
- data/lib/aws/sns.rb +69 -0
- data/lib/aws/sns/client.rb +37 -0
- data/lib/aws/sns/client/options.rb +24 -0
- data/lib/aws/sns/client/xml.rb +38 -0
- data/lib/aws/sns/errors.rb +29 -0
- data/lib/aws/sns/policy.rb +49 -0
- data/lib/aws/sns/request.rb +27 -0
- data/lib/aws/sns/subscription.rb +100 -0
- data/lib/aws/sns/subscription_collection.rb +84 -0
- data/lib/aws/sns/topic.rb +384 -0
- data/lib/aws/sns/topic_collection.rb +70 -0
- data/lib/aws/sns/topic_subscription_collection.rb +58 -0
- data/lib/aws/sqs.rb +70 -0
- data/lib/aws/sqs/client.rb +38 -0
- data/lib/aws/sqs/client/xml.rb +36 -0
- data/lib/aws/sqs/errors.rb +33 -0
- data/lib/aws/sqs/policy.rb +50 -0
- data/lib/aws/sqs/queue.rb +507 -0
- data/lib/aws/sqs/queue_collection.rb +105 -0
- data/lib/aws/sqs/received_message.rb +184 -0
- data/lib/aws/sqs/received_sns_message.rb +112 -0
- data/lib/aws/sqs/request.rb +44 -0
- data/lib/aws/xml_grammar.rb +923 -0
- data/rails/init.rb +15 -0
- metadata +298 -0
|
@@ -0,0 +1,227 @@
|
|
|
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/model'
|
|
15
|
+
require 'aws/simple_db/attribute'
|
|
16
|
+
require 'aws/simple_db/consistent_read_option'
|
|
17
|
+
require 'aws/simple_db/put_attributes'
|
|
18
|
+
require 'aws/simple_db/delete_attributes'
|
|
19
|
+
|
|
20
|
+
module AWS
|
|
21
|
+
class SimpleDB
|
|
22
|
+
class AttributeCollection
|
|
23
|
+
|
|
24
|
+
include Model
|
|
25
|
+
include Enumerable
|
|
26
|
+
include ConsistentReadOption
|
|
27
|
+
include PutAttributes
|
|
28
|
+
include DeleteAttributes
|
|
29
|
+
|
|
30
|
+
# @param [Item] The item to create an attribute collection for.
|
|
31
|
+
# @return [AttributeCollection]
|
|
32
|
+
def initialize item, options = {}
|
|
33
|
+
@item = item
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @return [Item] The item this collection belongs to.
|
|
38
|
+
attr_reader :item
|
|
39
|
+
|
|
40
|
+
# Retuns an Attribute with the given name.
|
|
41
|
+
#
|
|
42
|
+
# @note This does not make a request to SimpleDB.
|
|
43
|
+
#
|
|
44
|
+
# You can ask for any attribute by name. The attribute may or may not
|
|
45
|
+
# actually exist in SimpleDB.
|
|
46
|
+
#
|
|
47
|
+
# @example Get an attribute by symbol or string name
|
|
48
|
+
# colors = item.attributes[:colors]
|
|
49
|
+
# colors = item.attributes['colors']
|
|
50
|
+
# @param [String, Symbol] attribute_name name of the attribute to get.
|
|
51
|
+
# @return [Item] An item with the given name.
|
|
52
|
+
def [] attribute_name
|
|
53
|
+
Attribute.new(item, attribute_name.to_s)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Sets the values for a given attribute.
|
|
57
|
+
#
|
|
58
|
+
# @example Replace all of the values for the named attribute.
|
|
59
|
+
# item.attributes[:color] = 'red', 'blue'
|
|
60
|
+
# @return This method returns the values passed to it.
|
|
61
|
+
def []= attribute_name, *values
|
|
62
|
+
self[attribute_name].set(*values)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Yields all attribute values with their names.
|
|
66
|
+
#
|
|
67
|
+
# @example Getting all values for an item
|
|
68
|
+
#
|
|
69
|
+
# item.attributes.each_value do |name, value|
|
|
70
|
+
# puts "#{name}: #{value}"
|
|
71
|
+
# end
|
|
72
|
+
#
|
|
73
|
+
# @yield [attribute_name, attribute_value] Yields once for every
|
|
74
|
+
# attribute value on the item.
|
|
75
|
+
# @yieldparam [String] attribute_name
|
|
76
|
+
# @yieldparam [String] attribute_value
|
|
77
|
+
# @param [Hash] options
|
|
78
|
+
# @option options [Boolean] :consistent_read (false) Causes this
|
|
79
|
+
# method to yield the most current attributes for this item.
|
|
80
|
+
# @return [nil]
|
|
81
|
+
def each_value options = {}, &block
|
|
82
|
+
|
|
83
|
+
list = client.get_attributes(
|
|
84
|
+
:domain_name => item.domain.name,
|
|
85
|
+
:item_name => item.name,
|
|
86
|
+
:consistent_read => consistent_read(options))
|
|
87
|
+
|
|
88
|
+
list.attributes.each do |attribute|
|
|
89
|
+
attribute_name = attribute.name
|
|
90
|
+
attribute_value = attribute.value
|
|
91
|
+
yield(attribute_name, attribute_value)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
nil
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Yields all attribute for this item.
|
|
99
|
+
#
|
|
100
|
+
# @example Getting all attributes for an item
|
|
101
|
+
#
|
|
102
|
+
# item.attributes.each do |attribute|
|
|
103
|
+
# puts attribute.name
|
|
104
|
+
# end
|
|
105
|
+
#
|
|
106
|
+
# @yield [attribute] Yields once for every attribute
|
|
107
|
+
# on the item. Yields each attribute only one time, even it
|
|
108
|
+
# has multiple values.
|
|
109
|
+
# @yieldparam [Attribute] attribute
|
|
110
|
+
# @param [Hash] options
|
|
111
|
+
# @option options [Boolean] :consistent_read (false) Causes this
|
|
112
|
+
# method to yield the most current attributes for this item.
|
|
113
|
+
# @return [nil]
|
|
114
|
+
def each options = {}, &block
|
|
115
|
+
yielded = {}
|
|
116
|
+
each_value(options) do |attribute_name, attribute_value|
|
|
117
|
+
unless yielded[attribute_name]
|
|
118
|
+
attribute = self[attribute_name]
|
|
119
|
+
yield(attribute)
|
|
120
|
+
yielded[attribute_name] = true
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
nil
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Replaces attributes for the {#item}.
|
|
127
|
+
#
|
|
128
|
+
# The +attributes_hash+ should have attribute names as keys. The
|
|
129
|
+
# hash values should be either strings or arrays of strings.
|
|
130
|
+
#
|
|
131
|
+
# Attributes not named in this hash are left alone. Attributes named
|
|
132
|
+
# in this hash are replaced.
|
|
133
|
+
#
|
|
134
|
+
# @example
|
|
135
|
+
#
|
|
136
|
+
# item.attributes.set(
|
|
137
|
+
# 'colors' => ['red', 'blue'],
|
|
138
|
+
# 'category' => 'clearance')
|
|
139
|
+
#
|
|
140
|
+
# @param [Hash] attributes
|
|
141
|
+
# @return [nil]
|
|
142
|
+
def replace attributes
|
|
143
|
+
do_put(attribute_hashes(attributes, true), attributes)
|
|
144
|
+
end
|
|
145
|
+
alias_method :set, :replace
|
|
146
|
+
|
|
147
|
+
# Adds values to attributes on the {#item}.
|
|
148
|
+
#
|
|
149
|
+
# The +attributes_hash+ should have attribute names as keys. The
|
|
150
|
+
# hash values should be either strings or arrays of strings.
|
|
151
|
+
#
|
|
152
|
+
# @example
|
|
153
|
+
#
|
|
154
|
+
# item.attributes.add(
|
|
155
|
+
# 'colors' => ['red', 'blue'],
|
|
156
|
+
# 'category' => 'clearance')
|
|
157
|
+
#
|
|
158
|
+
# @param[Hash] attribute_hash
|
|
159
|
+
# @return [nil]
|
|
160
|
+
def add attributes
|
|
161
|
+
do_put(attribute_hashes(attributes, false), attributes)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Perform a mixed update of added and replace attribues.
|
|
165
|
+
#
|
|
166
|
+
# item.attributes.put(
|
|
167
|
+
# :add => { 'colors' => %w(green blue), 'tags' => 'cool' }
|
|
168
|
+
# :replace => { 'quantity' => 5 }
|
|
169
|
+
# )
|
|
170
|
+
#
|
|
171
|
+
# @param [Hash] options
|
|
172
|
+
# @option options [Hash] :add A hash of attribute names and values to
|
|
173
|
+
# append to this item.
|
|
174
|
+
# @option options [Hash] :replace A hash of attribute names and values to
|
|
175
|
+
# add to this item. If there are currently attributes of the same
|
|
176
|
+
# name they will be replaced (not appended to).
|
|
177
|
+
# @option options [Hash] :replace
|
|
178
|
+
# @return [nil]
|
|
179
|
+
def put options = {}
|
|
180
|
+
add = options[:add] || {}
|
|
181
|
+
replace = options[:replace] || {}
|
|
182
|
+
attributes = attribute_hashes(add, false)
|
|
183
|
+
attributes += attribute_hashes(replace, true)
|
|
184
|
+
do_put(attributes, options)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Returns a hash of all attributes (names and values).
|
|
188
|
+
# The attribute names are strings and the values are
|
|
189
|
+
# arrays of strings.
|
|
190
|
+
#
|
|
191
|
+
# @example
|
|
192
|
+
# item.attributes.to_h
|
|
193
|
+
# #=> { 'colors' => ['red','blue'], 'size' => ['large'] }
|
|
194
|
+
#
|
|
195
|
+
# @param [Hash] options
|
|
196
|
+
# @option options [Boolean] :consistent_read (false) Causes this
|
|
197
|
+
# method to return the most current attributes values.
|
|
198
|
+
# @return [Hash]
|
|
199
|
+
def to_h options = {}
|
|
200
|
+
hash = {}
|
|
201
|
+
each_value(options) do |attribute_name,attribute_value|
|
|
202
|
+
hash[attribute_name] ||= []
|
|
203
|
+
hash[attribute_name] << attribute_value
|
|
204
|
+
end
|
|
205
|
+
hash
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Delete one or more attributes from {#item}.
|
|
209
|
+
#
|
|
210
|
+
# @example Delete a list of attributes by name
|
|
211
|
+
# item.attributes.delete 'size', 'color'
|
|
212
|
+
# item.attributes.delete %w(size color)
|
|
213
|
+
#
|
|
214
|
+
# @param attribute_names An array or list of attribute names to delete.
|
|
215
|
+
# @return [nil]
|
|
216
|
+
def delete *args
|
|
217
|
+
if args.size == 1 and args.first.kind_of?(Hash)
|
|
218
|
+
delete_attribute_values(args.first)
|
|
219
|
+
else
|
|
220
|
+
delete_named_attributes(*args)
|
|
221
|
+
end
|
|
222
|
+
nil
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
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/base_client'
|
|
15
|
+
require 'aws/configured_client_methods'
|
|
16
|
+
require 'aws/simple_db/request'
|
|
17
|
+
require 'aws/simple_db/client/xml'
|
|
18
|
+
require 'aws/simple_db/client/options'
|
|
19
|
+
require 'aws/inflection'
|
|
20
|
+
require 'aws/simple_db/errors'
|
|
21
|
+
require 'time'
|
|
22
|
+
|
|
23
|
+
module AWS
|
|
24
|
+
class SimpleDB
|
|
25
|
+
|
|
26
|
+
# @private
|
|
27
|
+
class Client < BaseClient
|
|
28
|
+
|
|
29
|
+
include ConfiguredClientMethods
|
|
30
|
+
|
|
31
|
+
API_VERSION = '2009-04-15'
|
|
32
|
+
|
|
33
|
+
REGION_US_E1 = 'sdb.amazonaws.com'
|
|
34
|
+
REGION_US_W1 = 'sdb.us-west-1.amazonaws.com'
|
|
35
|
+
REGION_EU_W1 = 'sdb.eu-west-1.amazonaws.com'
|
|
36
|
+
REGION_APAC_SE1 = 'sdb.ap-southeast-1.amazonaws.com'
|
|
37
|
+
|
|
38
|
+
REQUEST_CLASS = SimpleDB::Request
|
|
39
|
+
|
|
40
|
+
configure_client
|
|
41
|
+
|
|
42
|
+
def valid_domain_name? name
|
|
43
|
+
self.class.valid_domain_name?(name)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.valid_domain_name? name
|
|
47
|
+
name.to_s =~ /^[a-z_\-\.]{3,255}$/i ? true : false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
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/configured_option_grammars'
|
|
15
|
+
|
|
16
|
+
module AWS
|
|
17
|
+
class SimpleDB
|
|
18
|
+
class Client < BaseClient
|
|
19
|
+
|
|
20
|
+
# @private
|
|
21
|
+
module Options
|
|
22
|
+
|
|
23
|
+
include ConfiguredOptionGrammars
|
|
24
|
+
|
|
25
|
+
define_configured_grammars
|
|
26
|
+
|
|
27
|
+
CustomizedListDomains =
|
|
28
|
+
ListDomains.customize("MaxNumberOfDomains" =>
|
|
29
|
+
[{ :rename => "limit" }])
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
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/configured_xml_grammars'
|
|
15
|
+
require 'aws/ignore_result_element'
|
|
16
|
+
require 'aws/xml_grammar'
|
|
17
|
+
|
|
18
|
+
module AWS
|
|
19
|
+
class SimpleDB
|
|
20
|
+
class Client < BaseClient
|
|
21
|
+
|
|
22
|
+
# @private
|
|
23
|
+
module XML
|
|
24
|
+
|
|
25
|
+
include ConfiguredXmlGrammars
|
|
26
|
+
|
|
27
|
+
extend IgnoreResultElement
|
|
28
|
+
|
|
29
|
+
BaseResponse = XmlGrammar.customize do
|
|
30
|
+
element "ResponseMetadata" do
|
|
31
|
+
element "BoxUsage" do
|
|
32
|
+
float_value
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
BaseError = XmlGrammar.customize do
|
|
38
|
+
element("Errors") do
|
|
39
|
+
ignore
|
|
40
|
+
element("Error") do
|
|
41
|
+
ignore
|
|
42
|
+
element("BoxUsage") { float_value }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
define_configured_grammars
|
|
48
|
+
|
|
49
|
+
CustomizedSelect = Select.customize do
|
|
50
|
+
element "SelectResult" do
|
|
51
|
+
element "NextToken" do
|
|
52
|
+
force
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
CustomizedListDomains = ListDomains.customize do
|
|
58
|
+
element "ListDomainsResult" do
|
|
59
|
+
element "NextToken" do
|
|
60
|
+
force
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
module AWS
|
|
15
|
+
class SimpleDB
|
|
16
|
+
|
|
17
|
+
# @private
|
|
18
|
+
module ConsistentReadOption
|
|
19
|
+
|
|
20
|
+
# Determines if SimpleDB should be read consistently or not.
|
|
21
|
+
#
|
|
22
|
+
# Precedence is given to:
|
|
23
|
+
#
|
|
24
|
+
# * +:consistent_read+ option
|
|
25
|
+
# * SimpleDB.consistent_reads block value
|
|
26
|
+
# * AWS.config.simple_db_consistent_reads?
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean] Returns true if a read should be made consistently
|
|
29
|
+
# to SimpleDB.
|
|
30
|
+
def consistent_read options
|
|
31
|
+
if options.has_key?(:consistent_read)
|
|
32
|
+
options[:consistent_read] ? true : false
|
|
33
|
+
elsif SimpleDB.send(:in_consistent_reads_block?)
|
|
34
|
+
SimpleDB.send(:consistent_reads_state)
|
|
35
|
+
else
|
|
36
|
+
config.simple_db_consistent_reads?
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
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/expect_condition_option'
|
|
15
|
+
|
|
16
|
+
module AWS
|
|
17
|
+
class SimpleDB
|
|
18
|
+
|
|
19
|
+
# @private
|
|
20
|
+
module DeleteAttributes
|
|
21
|
+
|
|
22
|
+
include ExpectConditionOption
|
|
23
|
+
|
|
24
|
+
# @private
|
|
25
|
+
protected
|
|
26
|
+
def delete_named_attributes *attribute_names
|
|
27
|
+
expect_opts = attribute_names.pop if attribute_names.last.kind_of?(Hash)
|
|
28
|
+
attributes = attribute_names.flatten.collect{|n| { :name => n.to_s } }
|
|
29
|
+
opts = {
|
|
30
|
+
:domain_name => item.domain.name,
|
|
31
|
+
:item_name => item.name,
|
|
32
|
+
:attributes => attributes,
|
|
33
|
+
:expected => expect_condition_opts(expect_opts || {})
|
|
34
|
+
}
|
|
35
|
+
opts.delete(:expected) if opts[:expected].empty?
|
|
36
|
+
client.delete_attributes(opts) unless attributes.empty?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @private
|
|
40
|
+
protected
|
|
41
|
+
def delete_attribute_values(attributes)
|
|
42
|
+
opts = {
|
|
43
|
+
:domain_name => item.domain.name,
|
|
44
|
+
:item_name => item.name,
|
|
45
|
+
:attributes => [],
|
|
46
|
+
:expected => expect_condition_opts(attributes)
|
|
47
|
+
}
|
|
48
|
+
attributes.each do |name, values|
|
|
49
|
+
if name != :"if" && name != :"unless"
|
|
50
|
+
[values].flatten.each do |value|
|
|
51
|
+
attribute_value = { :name => name.to_s }
|
|
52
|
+
attribute_value[:value] = value unless value == :all
|
|
53
|
+
opts[:attributes] << attribute_value
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
opts.delete(:expected) if opts[:expected].empty?
|
|
58
|
+
client.delete_attributes(opts)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|