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,63 @@
|
|
|
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 'cgi'
|
|
15
|
+
|
|
16
|
+
module AWS
|
|
17
|
+
module Http
|
|
18
|
+
class Request
|
|
19
|
+
|
|
20
|
+
# @private
|
|
21
|
+
class Param
|
|
22
|
+
|
|
23
|
+
attr_accessor :name, :value
|
|
24
|
+
|
|
25
|
+
def initialize name, value = nil
|
|
26
|
+
@name = name
|
|
27
|
+
@value = value
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def <=> other
|
|
31
|
+
@name <=> other.name
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_s
|
|
35
|
+
if value
|
|
36
|
+
"#{name}=#{value}"
|
|
37
|
+
else
|
|
38
|
+
name
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def ==(other)
|
|
43
|
+
other.kind_of?(Param) &&
|
|
44
|
+
to_s == other.to_s
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def encoded
|
|
48
|
+
if value
|
|
49
|
+
"#{escape(name)}=#{escape(value)}"
|
|
50
|
+
else
|
|
51
|
+
escape(name)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def escape value
|
|
56
|
+
CGI::escape(value.to_s).gsub('+', '%20')
|
|
57
|
+
end
|
|
58
|
+
protected :escape
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
|
|
16
|
+
# @private
|
|
17
|
+
module Http
|
|
18
|
+
|
|
19
|
+
# Represents the http response from a service request.
|
|
20
|
+
#
|
|
21
|
+
# Responses have:
|
|
22
|
+
#
|
|
23
|
+
# * status (200, 404, 500, etc)
|
|
24
|
+
# * headers (hash of response headers)
|
|
25
|
+
# * body (the response body)
|
|
26
|
+
#
|
|
27
|
+
# @private
|
|
28
|
+
class Response
|
|
29
|
+
|
|
30
|
+
# @return [Integer] (200) response http status code
|
|
31
|
+
attr_accessor :status
|
|
32
|
+
|
|
33
|
+
# @return [Hash] ({}) response http headers
|
|
34
|
+
attr_accessor :headers
|
|
35
|
+
|
|
36
|
+
# @return [String] ('') response http body
|
|
37
|
+
attr_accessor :body
|
|
38
|
+
|
|
39
|
+
# @return [String] (false) set to true if the client gives up
|
|
40
|
+
# before getting a response from the service.
|
|
41
|
+
attr_accessor :timeout
|
|
42
|
+
alias_method :timeout?, :timeout
|
|
43
|
+
|
|
44
|
+
# @param [Hash] options
|
|
45
|
+
# @option options [Integer] :status (200) HTTP status code
|
|
46
|
+
# @option options [Hash] :headers ({}) HTTP response headers
|
|
47
|
+
# @option options [String] :body ('') HTTP response body
|
|
48
|
+
def initialize options = {}, &block
|
|
49
|
+
@status = options[:status] || 200
|
|
50
|
+
@headers = options[:headers] || {}
|
|
51
|
+
@body = options[:body] || ''
|
|
52
|
+
yield(self) if block_given?
|
|
53
|
+
self
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Returns the header value with the given name.
|
|
57
|
+
#
|
|
58
|
+
# The value is matched case-insensitively so if the headers hash
|
|
59
|
+
# contains a key like 'Date' and you request the value for
|
|
60
|
+
# 'date' the 'Date' value will be returned.
|
|
61
|
+
#
|
|
62
|
+
# @param [String,Symbol] name The name of the header to fetch a value for.
|
|
63
|
+
# @return [String,nil] The value of the given header
|
|
64
|
+
def header name
|
|
65
|
+
headers.each_pair do |header_name, header_value|
|
|
66
|
+
if header_name.downcase == name.to_s.downcase
|
|
67
|
+
return header_value.is_a?(Array) ? header_value.first : header_value
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
nil
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
16
|
+
module AWS
|
|
17
|
+
|
|
18
|
+
# @private
|
|
19
|
+
#
|
|
20
|
+
# Mixin for XML grammar modules to ignore the outer
|
|
21
|
+
# "OperationNameResult" element that wraps the response fields in
|
|
22
|
+
# Coral-like service responses.
|
|
23
|
+
module IgnoreResultElement
|
|
24
|
+
|
|
25
|
+
# @private
|
|
26
|
+
#
|
|
27
|
+
# Invoked by
|
|
28
|
+
# ConfiguredXmlGrammars::ClassMethods#define_configured_grammars
|
|
29
|
+
def process_customizations(name, customizations)
|
|
30
|
+
[{
|
|
31
|
+
"#{name}Result" =>
|
|
32
|
+
[:ignore, *customizations]
|
|
33
|
+
}]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
|
|
16
|
+
# A utility class to provide indifferent access to hash data.
|
|
17
|
+
#
|
|
18
|
+
# Inspired by ActiveSupport's HashWithIndifferentAccess, this class
|
|
19
|
+
# has a few notable differences:
|
|
20
|
+
#
|
|
21
|
+
# * ALL keys are converted to strings (via #to_s)
|
|
22
|
+
# * It does not deep merge/convert hashes indifferently
|
|
23
|
+
# * It will not perserve default value behaviours
|
|
24
|
+
#
|
|
25
|
+
# These features were omitted because our primary use for this class is to
|
|
26
|
+
# wrap a 1-level hash as a return value, but we want the user to access
|
|
27
|
+
# the values with string or symbol keys.
|
|
28
|
+
#
|
|
29
|
+
# @private
|
|
30
|
+
class IndifferentHash < Hash
|
|
31
|
+
|
|
32
|
+
def initialize *args
|
|
33
|
+
if args.first.is_a?(Hash)
|
|
34
|
+
super()
|
|
35
|
+
merge!(*args)
|
|
36
|
+
else
|
|
37
|
+
super(*args)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
alias_method :_getter, :[]
|
|
42
|
+
alias_method :_setter, :[]=
|
|
43
|
+
|
|
44
|
+
def []=(key, value)
|
|
45
|
+
_setter(_convert_key(key), value)
|
|
46
|
+
end
|
|
47
|
+
alias_method :store, :[]=
|
|
48
|
+
|
|
49
|
+
def [] key
|
|
50
|
+
_getter(_convert_key(key))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def merge! hash
|
|
54
|
+
hash.each_pair do |key,value|
|
|
55
|
+
self[key] = value
|
|
56
|
+
end
|
|
57
|
+
self
|
|
58
|
+
end
|
|
59
|
+
alias_method :update, :merge!
|
|
60
|
+
|
|
61
|
+
def merge hash
|
|
62
|
+
self.dup.merge!(hash)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def has_key? key
|
|
66
|
+
super(_convert_key(key))
|
|
67
|
+
end
|
|
68
|
+
alias_method :key?, :has_key?
|
|
69
|
+
alias_method :member?, :has_key?
|
|
70
|
+
alias_method :include?, :has_key?
|
|
71
|
+
|
|
72
|
+
def fetch key, *extras, &block
|
|
73
|
+
super(_convert_key(key), *extras, &block)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def delete key
|
|
77
|
+
super(_convert_key(key))
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
def _convert_key key
|
|
82
|
+
key.is_a?(String) ? key : key.to_s
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
|
|
16
|
+
# @private
|
|
17
|
+
module Inflection
|
|
18
|
+
|
|
19
|
+
def ruby_name(aws_name)
|
|
20
|
+
|
|
21
|
+
#aws_name.sub(/^.*:/, '').
|
|
22
|
+
# gsub(/[A-Z]+[a-z]+/){|str| "_#{str.downcase}_" }.
|
|
23
|
+
# gsub(/(^_|_$)/, '').
|
|
24
|
+
# gsub(/__/, '_').
|
|
25
|
+
# downcase
|
|
26
|
+
|
|
27
|
+
return 'etag' if aws_name == 'ETag'
|
|
28
|
+
|
|
29
|
+
aws_name.
|
|
30
|
+
sub(/^.*:/, ''). # strip namespace
|
|
31
|
+
gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). # split acronyms from words
|
|
32
|
+
scan(/[a-z]+|\d+|[A-Z0-9]+[a-z]*/). # split remaining words
|
|
33
|
+
join('_').downcase # join parts _ and downcase
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
module_function :ruby_name
|
|
37
|
+
|
|
38
|
+
def class_name(name)
|
|
39
|
+
name.sub(/^(.)/) { |m| m.upcase }.
|
|
40
|
+
gsub(/[-_]([a-z])/i) { |m| m[1,1].upcase }
|
|
41
|
+
end
|
|
42
|
+
module_function :class_name
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
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/xml_grammar'
|
|
15
|
+
require 'aws/errors'
|
|
16
|
+
|
|
17
|
+
module AWS
|
|
18
|
+
|
|
19
|
+
# @private
|
|
20
|
+
module LazyErrorClasses
|
|
21
|
+
|
|
22
|
+
# @private
|
|
23
|
+
module ClassMethods
|
|
24
|
+
|
|
25
|
+
def const_missing(name)
|
|
26
|
+
base_error_grammar = self::BASE_ERROR_GRAMMAR
|
|
27
|
+
const_missing_mutex.synchronize do
|
|
28
|
+
return if const_defined?(name)
|
|
29
|
+
const_set(name,
|
|
30
|
+
Class.new(self::Base) do
|
|
31
|
+
include Errors::ModeledError
|
|
32
|
+
|
|
33
|
+
# so that MyService::Errors::Foo::Bar will work
|
|
34
|
+
const_set(:BASE_ERROR_GRAMMAR, base_error_grammar)
|
|
35
|
+
include LazyErrorClasses
|
|
36
|
+
end)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def error_class(code)
|
|
41
|
+
module_eval(code.gsub(".","::"))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def included(mod)
|
|
45
|
+
raise NotImplementedError.new("#{self} lazy-generates error classes; "+
|
|
46
|
+
"therefore it is not suitable for "+
|
|
47
|
+
"inclusion in other modules")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.included(mod)
|
|
53
|
+
unless mod.const_defined?(:BASE_ERROR_GRAMMAR)
|
|
54
|
+
mod.const_set(:BASE_ERROR_GRAMMAR, XmlGrammar)
|
|
55
|
+
end
|
|
56
|
+
mutex = Mutex.new
|
|
57
|
+
MetaUtils.extend_method(mod, :const_missing_mutex) { mutex }
|
|
58
|
+
mod.send(:include, Errors)
|
|
59
|
+
mod.extend(ClassMethods)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
|
|
16
|
+
# @private
|
|
17
|
+
module MetaUtils
|
|
18
|
+
|
|
19
|
+
def extend_method(object, name, &block)
|
|
20
|
+
object.extend(
|
|
21
|
+
Module.new do
|
|
22
|
+
define_method(name, &block)
|
|
23
|
+
end
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
module_function :extend_method
|
|
27
|
+
|
|
28
|
+
def class_extend_method(klass, name, &block)
|
|
29
|
+
klass.send(:include,
|
|
30
|
+
Module.new do
|
|
31
|
+
define_method(name, &block)
|
|
32
|
+
end
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
module_function :class_extend_method
|
|
36
|
+
|
|
37
|
+
def extend(object, &block)
|
|
38
|
+
object.extend(Module.new(&block))
|
|
39
|
+
end
|
|
40
|
+
module_function :extend
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/aws/model.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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/inflection'
|
|
15
|
+
|
|
16
|
+
module AWS
|
|
17
|
+
|
|
18
|
+
# @private
|
|
19
|
+
module Model
|
|
20
|
+
|
|
21
|
+
# @private
|
|
22
|
+
def initialize(*args)
|
|
23
|
+
options = args.last.kind_of?(Hash) ? args.last : {}
|
|
24
|
+
@config = case
|
|
25
|
+
when options[:config] then options[:config]
|
|
26
|
+
when args.first.respond_to?(:config) then args.first.config
|
|
27
|
+
else AWS.config
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @return [Configuration] Returns the configuration for this object.
|
|
32
|
+
attr_reader :config
|
|
33
|
+
|
|
34
|
+
# Each class including this module has its own client class.
|
|
35
|
+
# Generally it is the service namespace suffixed by client:
|
|
36
|
+
#
|
|
37
|
+
# * s3_client
|
|
38
|
+
# * simple_db_client
|
|
39
|
+
#
|
|
40
|
+
# @return Retruns the proper client class for the given model.
|
|
41
|
+
def client
|
|
42
|
+
@config.send("#{config_prefix}_client")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @return [String] The short name of the service as used in coniguration.
|
|
46
|
+
# (e.g. SimpleDB::Client.config_prefix #=> 'simple_db')
|
|
47
|
+
def config_prefix
|
|
48
|
+
Inflection.ruby_name(self.class.to_s.split(/::/)[1])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @return [String] A sensible default inspect string.
|
|
52
|
+
def inspect
|
|
53
|
+
"<#{self.class}>"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|