aws-sdk 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ca-bundle.crt +2 -348
- data/lib/aws.rb +24 -49
- data/lib/aws/{common.rb → core.rb} +120 -9
- data/lib/aws/{api_config.rb → core/api_config.rb} +19 -20
- data/lib/aws/core/api_config_transform.rb +36 -0
- data/lib/aws/core/async_handle.rb +91 -0
- data/lib/aws/core/authorize_v2.rb +39 -0
- data/lib/aws/{authorize_v3.rb → core/authorize_v3.rb} +16 -15
- data/lib/aws/{api_config_transform.rb → core/authorize_with_session_token.rb} +9 -12
- data/lib/aws/core/autoloader.rb +64 -0
- data/lib/aws/core/cacheable.rb +78 -0
- data/lib/aws/core/client.rb +471 -0
- data/lib/aws/core/client_logging.rb +125 -0
- data/lib/aws/core/collections.rb +229 -0
- data/lib/aws/core/configuration.rb +358 -0
- data/lib/aws/core/configured_client_methods.rb +76 -0
- data/lib/aws/core/configured_grammars.rb +63 -0
- data/lib/aws/{configured_option_grammars.rb → core/configured_option_grammars.rb} +18 -20
- data/lib/aws/{configured_xml_grammars.rb → core/configured_xml_grammars.rb} +19 -21
- data/lib/aws/core/default_signer.rb +67 -0
- data/lib/aws/core/http/curb_handler.rb +129 -0
- data/lib/aws/core/http/handler.rb +77 -0
- data/lib/aws/core/http/httparty_handler.rb +113 -0
- data/lib/aws/core/http/net_http_handler.rb +124 -0
- data/lib/aws/core/http/request.rb +207 -0
- data/lib/aws/core/http/response.rb +73 -0
- data/lib/aws/{ignore_result_element.rb → core/ignore_result_element.rb} +14 -18
- data/lib/aws/core/indifferent_hash.rb +88 -0
- data/lib/aws/core/inflection.rb +47 -0
- data/lib/aws/core/lazy_error_classes.rb +62 -0
- data/lib/aws/{uri_escape.rb → core/meta_utils.rb} +24 -23
- data/lib/aws/core/model.rb +57 -0
- data/lib/aws/{authorize_with_session_token.rb → core/naming.rb} +9 -8
- data/lib/aws/core/option_grammar.rb +562 -0
- data/lib/aws/core/policy.rb +914 -0
- data/lib/aws/core/resource.rb +380 -0
- data/lib/aws/core/resource_cache.rb +40 -0
- data/lib/aws/core/response.rb +125 -0
- data/lib/aws/core/response_cache.rb +50 -0
- data/lib/aws/core/service_interface.rb +60 -0
- data/lib/aws/core/uri_escape.rb +46 -0
- data/lib/aws/core/xml_grammar.rb +926 -0
- data/lib/aws/ec2.rb +47 -16
- data/lib/aws/ec2/attachment.rb +0 -2
- data/lib/aws/ec2/attachment_collection.rb +1 -6
- data/lib/aws/ec2/availability_zone.rb +0 -2
- data/lib/aws/ec2/availability_zone_collection.rb +0 -3
- data/lib/aws/ec2/client.rb +6 -9
- data/lib/aws/ec2/client/xml.rb +3 -6
- data/lib/aws/ec2/collection.rb +1 -4
- data/lib/aws/ec2/config.rb +18 -0
- data/lib/aws/ec2/elastic_ip.rb +0 -2
- data/lib/aws/ec2/elastic_ip_collection.rb +0 -4
- data/lib/aws/ec2/errors.rb +1 -4
- data/lib/aws/ec2/has_permissions.rb +0 -2
- data/lib/aws/ec2/image.rb +0 -5
- data/lib/aws/ec2/image_collection.rb +0 -6
- data/lib/aws/ec2/instance.rb +23 -9
- data/lib/aws/ec2/instance_collection.rb +85 -22
- data/lib/aws/ec2/key_pair.rb +0 -2
- data/lib/aws/ec2/key_pair_collection.rb +1 -4
- data/lib/aws/ec2/permission_collection.rb +2 -5
- data/lib/aws/ec2/region.rb +0 -2
- data/lib/aws/ec2/region_collection.rb +0 -4
- data/lib/aws/ec2/request.rb +4 -9
- data/lib/aws/ec2/reserved_instances.rb +0 -3
- data/lib/aws/ec2/reserved_instances_collection.rb +0 -4
- data/lib/aws/ec2/reserved_instances_offering.rb +0 -3
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +0 -4
- data/lib/aws/ec2/resource.rb +3 -5
- data/lib/aws/ec2/resource_tag_collection.rb +1 -6
- data/lib/aws/ec2/security_group.rb +204 -72
- data/lib/aws/ec2/security_group/egress_ip_permission_collection.rb +53 -0
- data/lib/aws/ec2/security_group/ip_permission.rb +92 -10
- data/lib/aws/ec2/security_group/ip_permission_collection.rb +14 -15
- data/lib/aws/ec2/security_group_collection.rb +11 -8
- data/lib/aws/ec2/snapshot.rb +0 -4
- data/lib/aws/ec2/snapshot_collection.rb +0 -4
- data/lib/aws/ec2/tag.rb +0 -3
- data/lib/aws/ec2/tag_collection.rb +1 -8
- data/lib/aws/ec2/tagged_item.rb +1 -3
- data/lib/aws/ec2/volume.rb +0 -6
- data/lib/aws/ec2/volume_collection.rb +0 -4
- data/lib/aws/errors.rb +0 -3
- data/lib/aws/iam.rb +33 -12
- data/lib/aws/iam/access_key.rb +0 -3
- data/lib/aws/iam/access_key_collection.rb +0 -3
- data/lib/aws/iam/account_alias_collection.rb +0 -2
- data/lib/aws/iam/client.rb +6 -8
- data/lib/aws/iam/client/xml.rb +4 -8
- data/lib/aws/iam/collection.rb +2 -5
- data/lib/aws/iam/config.rb +18 -0
- data/lib/aws/iam/errors.rb +2 -4
- data/lib/aws/iam/group.rb +0 -5
- data/lib/aws/iam/group_collection.rb +0 -3
- data/lib/aws/iam/group_policy_collection.rb +0 -2
- data/lib/aws/iam/group_user_collection.rb +1 -4
- data/lib/aws/iam/login_profile.rb +0 -2
- data/lib/aws/iam/mfa_device.rb +1 -3
- data/lib/aws/iam/mfa_device_collection.rb +0 -3
- data/lib/aws/iam/policy.rb +2 -4
- data/lib/aws/iam/policy_collection.rb +0 -3
- data/lib/aws/iam/request.rb +3 -7
- data/lib/aws/iam/resource.rb +1 -4
- data/lib/aws/iam/server_certificate.rb +0 -2
- data/lib/aws/iam/server_certificate_collection.rb +0 -3
- data/lib/aws/iam/signing_certificate.rb +0 -2
- data/lib/aws/iam/signing_certificate_collection.rb +0 -3
- data/lib/aws/iam/user.rb +0 -7
- data/lib/aws/iam/user_collection.rb +0 -3
- data/lib/aws/iam/user_group_collection.rb +0 -3
- data/lib/aws/iam/user_policy.rb +0 -2
- data/lib/aws/iam/user_policy_collection.rb +0 -3
- data/lib/aws/rails.rb +5 -4
- data/lib/aws/record.rb +4 -1
- data/lib/aws/record/base.rb +3 -2
- data/lib/aws/record/errors.rb +1 -3
- data/lib/aws/s3.rb +31 -6
- data/lib/aws/s3/access_control_list.rb +0 -2
- data/lib/aws/s3/acl_object.rb +10 -12
- data/lib/aws/s3/bucket.rb +1 -9
- data/lib/aws/s3/bucket_collection.rb +2 -5
- data/lib/aws/s3/bucket_version_collection.rb +1 -5
- data/lib/aws/s3/client.rb +34 -37
- data/lib/aws/s3/client/xml.rb +11 -14
- data/lib/aws/{resource_cache.rb → s3/config.rb} +6 -20
- data/lib/aws/s3/errors.rb +6 -7
- data/lib/aws/s3/multipart_upload.rb +1 -4
- data/lib/aws/s3/multipart_upload_collection.rb +1 -6
- data/lib/aws/s3/object_collection.rb +1 -5
- data/lib/aws/s3/object_metadata.rb +1 -3
- data/lib/aws/s3/object_upload_collection.rb +1 -7
- data/lib/aws/s3/object_version.rb +1 -4
- data/lib/aws/s3/object_version_collection.rb +1 -4
- data/lib/aws/s3/policy.rb +3 -5
- data/lib/aws/s3/prefix_and_delimiter_collection.rb +0 -2
- data/lib/aws/s3/prefixed_collection.rb +0 -2
- data/lib/aws/s3/presigned_post.rb +1 -3
- data/lib/aws/s3/request.rb +2 -5
- data/lib/aws/s3/s3_object.rb +1 -8
- data/lib/aws/s3/tree.rb +8 -6
- data/lib/aws/s3/tree/branch_node.rb +0 -3
- data/lib/aws/s3/tree/child_collection.rb +1 -5
- data/lib/aws/s3/tree/leaf_node.rb +0 -5
- data/lib/aws/s3/tree/parent.rb +1 -4
- data/lib/aws/s3/uploaded_part.rb +1 -3
- data/lib/aws/s3/uploaded_part_collection.rb +1 -5
- data/lib/aws/simple_db.rb +21 -6
- data/lib/aws/simple_db/attribute.rb +1 -6
- data/lib/aws/simple_db/attribute_collection.rb +1 -7
- data/lib/aws/simple_db/client.rb +7 -9
- data/lib/aws/simple_db/client/options.rb +2 -4
- data/lib/aws/simple_db/client/xml.rb +5 -10
- data/lib/aws/{naming.rb → simple_db/config.rb} +3 -14
- data/lib/aws/simple_db/delete_attributes.rb +0 -2
- data/lib/aws/simple_db/domain.rb +1 -6
- data/lib/aws/simple_db/domain_collection.rb +1 -4
- data/lib/aws/simple_db/domain_metadata.rb +1 -3
- data/lib/aws/simple_db/errors.rb +1 -4
- data/lib/aws/simple_db/item.rb +1 -7
- data/lib/aws/simple_db/item_collection.rb +22 -23
- data/lib/aws/simple_db/put_attributes.rb +0 -2
- data/lib/aws/simple_db/request.rb +3 -7
- data/lib/aws/simple_email_service.rb +11 -6
- data/lib/aws/simple_email_service/client.rb +7 -9
- data/lib/aws/simple_email_service/client/options.rb +3 -6
- data/lib/aws/simple_email_service/client/xml.rb +4 -8
- data/lib/aws/simple_email_service/config.rb +19 -0
- data/lib/aws/simple_email_service/email_address_collection.rb +1 -3
- data/lib/aws/simple_email_service/errors.rb +1 -4
- data/lib/aws/simple_email_service/quotas.rb +1 -3
- data/lib/aws/simple_email_service/request.rb +3 -7
- data/lib/aws/sns.rb +15 -8
- data/lib/aws/sns/client.rb +7 -8
- data/lib/aws/sns/client/options.rb +3 -6
- data/lib/aws/sns/client/xml.rb +4 -8
- data/lib/aws/sns/config.rb +18 -0
- data/lib/aws/sns/errors.rb +1 -4
- data/lib/aws/sns/policy.rb +3 -5
- data/lib/aws/sns/request.rb +4 -9
- data/lib/aws/sns/subscription.rb +1 -5
- data/lib/aws/sns/subscription_collection.rb +1 -5
- data/lib/aws/sns/topic.rb +1 -6
- data/lib/aws/sns/topic_collection.rb +1 -4
- data/lib/aws/sns/topic_subscription_collection.rb +1 -4
- data/lib/aws/sqs.rb +14 -5
- data/lib/aws/sqs/client.rb +6 -9
- data/lib/aws/sqs/client/xml.rb +4 -7
- data/lib/aws/sqs/config.rb +18 -0
- data/lib/aws/sqs/errors.rb +1 -4
- data/lib/aws/sqs/policy.rb +3 -5
- data/lib/aws/sqs/queue.rb +2 -7
- data/lib/aws/sqs/queue_collection.rb +4 -5
- data/lib/aws/sqs/received_message.rb +1 -3
- data/lib/aws/sqs/received_sns_message.rb +2 -2
- data/lib/aws/sqs/request.rb +4 -7
- data/lib/aws/sts.rb +12 -6
- data/lib/aws/sts/client.rb +6 -8
- data/lib/aws/sts/client/xml.rb +4 -8
- data/lib/aws/sts/config.rb +18 -0
- data/lib/aws/sts/errors.rb +1 -4
- data/lib/aws/sts/federated_session.rb +0 -2
- data/lib/aws/sts/policy.rb +3 -5
- data/lib/aws/sts/request.rb +3 -7
- metadata +60 -50
- data/lib/aws/async_handle.rb +0 -90
- data/lib/aws/authorize_v2.rb +0 -37
- data/lib/aws/base_client.rb +0 -488
- data/lib/aws/cacheable.rb +0 -79
- data/lib/aws/client_logging.rb +0 -122
- data/lib/aws/collections.rb +0 -230
- data/lib/aws/configuration.rb +0 -357
- data/lib/aws/configured_client_methods.rb +0 -81
- data/lib/aws/configured_grammars.rb +0 -65
- data/lib/aws/default_signer.rb +0 -65
- data/lib/aws/http/curb_handler.rb +0 -127
- data/lib/aws/http/handler.rb +0 -77
- data/lib/aws/http/httparty_handler.rb +0 -103
- data/lib/aws/http/request.rb +0 -165
- data/lib/aws/http/request_param.rb +0 -64
- data/lib/aws/http/response.rb +0 -72
- data/lib/aws/indifferent_hash.rb +0 -86
- data/lib/aws/inflection.rb +0 -46
- data/lib/aws/lazy_error_classes.rb +0 -64
- data/lib/aws/meta_utils.rb +0 -43
- data/lib/aws/model.rb +0 -57
- data/lib/aws/option_grammar.rb +0 -565
- data/lib/aws/policy.rb +0 -914
- data/lib/aws/resource.rb +0 -381
- data/lib/aws/response.rb +0 -125
- data/lib/aws/response_cache.rb +0 -50
- data/lib/aws/service_interface.rb +0 -60
- data/lib/aws/xml_grammar.rb +0 -925
data/lib/aws/cacheable.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
require 'aws/naming'
|
15
|
-
|
16
|
-
module AWS
|
17
|
-
|
18
|
-
# @private
|
19
|
-
module Cacheable
|
20
|
-
|
21
|
-
# @private
|
22
|
-
class NoData < StandardError; end
|
23
|
-
|
24
|
-
def self.included base
|
25
|
-
base.extend Naming unless base.respond_to?(:service_ruby_name)
|
26
|
-
end
|
27
|
-
|
28
|
-
# @private
|
29
|
-
protected
|
30
|
-
def local_cache_key
|
31
|
-
raise NotImplementedError
|
32
|
-
end
|
33
|
-
|
34
|
-
# @private
|
35
|
-
protected
|
36
|
-
def cache_key
|
37
|
-
@cache_key ||= begin
|
38
|
-
endpoint_method = self.class.service_ruby_name + "_endpoint"
|
39
|
-
config.signer.access_key_id + ":" +
|
40
|
-
config.send(endpoint_method) + ":" +
|
41
|
-
self.class.name + ":" +
|
42
|
-
local_cache_key
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# @private
|
47
|
-
public
|
48
|
-
def retrieve_attribute attr, &block
|
49
|
-
|
50
|
-
if cache = AWS.response_cache
|
51
|
-
|
52
|
-
if cache.resource_cache.cached?(cache_key, attr.name)
|
53
|
-
return cache.resource_cache.get(cache_key, attr.name)
|
54
|
-
end
|
55
|
-
|
56
|
-
cache.select(*attr.request_types).each do |response|
|
57
|
-
if attributes = attributes_from_response(response)
|
58
|
-
cache.resource_cache.store(cache_key, attributes)
|
59
|
-
return attributes[attr.name] if attributes.key?(attr.name)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
response = yield
|
66
|
-
|
67
|
-
if attributes = attributes_from_response(response)
|
68
|
-
if cache = AWS.response_cache
|
69
|
-
cache.resource_cache.store(cache_key, attributes)
|
70
|
-
end
|
71
|
-
attributes[attr.name] if attributes.key?(attr.name)
|
72
|
-
else
|
73
|
-
raise NoData.new("no data in #{response.request_type} response")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
data/lib/aws/client_logging.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
module AWS
|
15
|
-
|
16
|
-
# @private
|
17
|
-
module ClientLogging
|
18
|
-
|
19
|
-
MAX_STRING_LENGTH = 50
|
20
|
-
|
21
|
-
def log_client_request(name, options)
|
22
|
-
response = nil
|
23
|
-
time = Benchmark.measure do
|
24
|
-
response = yield
|
25
|
-
end
|
26
|
-
|
27
|
-
if options[:async]
|
28
|
-
response.on_complete do
|
29
|
-
log_client_request_on_success(name, options, response, time)
|
30
|
-
end
|
31
|
-
else
|
32
|
-
log_client_request_on_success(name, options, response, time)
|
33
|
-
end
|
34
|
-
response
|
35
|
-
end
|
36
|
-
|
37
|
-
# Summarizes long strings and adds file size information
|
38
|
-
# @private
|
39
|
-
def sanitize_options(options)
|
40
|
-
sanitize_hash(options)
|
41
|
-
end
|
42
|
-
|
43
|
-
protected
|
44
|
-
def log severity, message
|
45
|
-
config.logger.send(severity, message + "\n") if config.logger
|
46
|
-
end
|
47
|
-
|
48
|
-
protected
|
49
|
-
def log_client_request_on_success(method_name, options, response, time)
|
50
|
-
status = response.http_response.status
|
51
|
-
service = self.class.service_name
|
52
|
-
|
53
|
-
pattern = "[AWS %s %s %.06f] %s(%s)"
|
54
|
-
parts = [service, status, time.real, method_name, sanitize_options(options)]
|
55
|
-
severity = :info
|
56
|
-
|
57
|
-
if response.error
|
58
|
-
pattern += " %s: %s"
|
59
|
-
parts << response.error.class
|
60
|
-
parts << response.error.message
|
61
|
-
severity = :error
|
62
|
-
end
|
63
|
-
|
64
|
-
if response.cached
|
65
|
-
pattern << " [CACHED]"
|
66
|
-
end
|
67
|
-
|
68
|
-
log(severity, pattern % parts)
|
69
|
-
end
|
70
|
-
|
71
|
-
protected
|
72
|
-
def sanitize_value(value)
|
73
|
-
case value
|
74
|
-
when Hash
|
75
|
-
'{' + sanitize_hash(value) + '}'
|
76
|
-
when Array
|
77
|
-
sanitize_array(value)
|
78
|
-
when File
|
79
|
-
sanitize_file(value)
|
80
|
-
when String
|
81
|
-
sanitize_string(value)
|
82
|
-
else
|
83
|
-
value.inspect
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
protected
|
88
|
-
def sanitize_string str
|
89
|
-
summary = summarize_string(str)
|
90
|
-
inspected = str.inspect
|
91
|
-
if inspected.size > summary.size
|
92
|
-
summary
|
93
|
-
else
|
94
|
-
inspected
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
protected
|
99
|
-
def summarize_string str
|
100
|
-
"#<String #{str[0,6].inspect} ... #{str[-6,6].inspect} (#{str.size} characters)>"
|
101
|
-
end
|
102
|
-
|
103
|
-
protected
|
104
|
-
def sanitize_file file
|
105
|
-
"#<File:#{file.path} (#{File.size(file.path)} bytes)>"
|
106
|
-
end
|
107
|
-
|
108
|
-
protected
|
109
|
-
def sanitize_array array
|
110
|
-
"[" + array.map { |v| sanitize_value(v) }.join(",") + "]"
|
111
|
-
end
|
112
|
-
|
113
|
-
protected
|
114
|
-
def sanitize_hash hash
|
115
|
-
hash.map do |k,v|
|
116
|
-
"#{sanitize_value(k)}=>#{sanitize_value(v)}"
|
117
|
-
end.sort.join(",")
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
data/lib/aws/collections.rb
DELETED
@@ -1,230 +0,0 @@
|
|
1
|
-
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
3
|
-
# may not use this file except in compliance with the License. A copy of
|
4
|
-
# the License is located at
|
5
|
-
#
|
6
|
-
# http://aws.amazon.com/apache2.0/
|
7
|
-
#
|
8
|
-
# or in the "license" file accompanying this file. This file is
|
9
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
10
|
-
# ANY KIND, either express or implied. See the License for the specific
|
11
|
-
# language governing permissions and limitations under the License.
|
12
|
-
|
13
|
-
require 'aws/model'
|
14
|
-
|
15
|
-
module AWS
|
16
|
-
|
17
|
-
|
18
|
-
# There are 3 collection modules:
|
19
|
-
#
|
20
|
-
# AWS::Collections::Basic
|
21
|
-
# - single request returns all items
|
22
|
-
# - (sqs, ec2, ses)
|
23
|
-
#
|
24
|
-
# AWS::Collections::Paged
|
25
|
-
# - responses may be truncated
|
26
|
-
# - truncated responses return a "next token"
|
27
|
-
# - (sns, sdb)
|
28
|
-
#
|
29
|
-
# AWS::Collections::PagedWithLimits
|
30
|
-
# - requests accept a "max items"
|
31
|
-
# - responses may be "truncated"
|
32
|
-
# - truncated responses return a "next token"
|
33
|
-
# - (s3, iam)
|
34
|
-
#
|
35
|
-
# @private
|
36
|
-
module Collections
|
37
|
-
|
38
|
-
# @private
|
39
|
-
module Basic
|
40
|
-
|
41
|
-
include Model
|
42
|
-
include Enumerable
|
43
|
-
|
44
|
-
def enumerator options = {}
|
45
|
-
Enumerator.new(self, :each, options)
|
46
|
-
end
|
47
|
-
|
48
|
-
def each options = {}, &block
|
49
|
-
each_batch(options) do |batch|
|
50
|
-
batch.each(&block)
|
51
|
-
end
|
52
|
-
nil
|
53
|
-
end
|
54
|
-
|
55
|
-
def each_batch options = {}, &block
|
56
|
-
|
57
|
-
options = options.dup
|
58
|
-
|
59
|
-
limit = options.delete(:limit)
|
60
|
-
batch_size = options.delete(:batch_size)
|
61
|
-
|
62
|
-
total = 0 # count of items yeileded across all batches
|
63
|
-
|
64
|
-
each_response(options, limit, batch_size) do |response|
|
65
|
-
|
66
|
-
batch = []
|
67
|
-
each_item(response) do |item|
|
68
|
-
batch << item
|
69
|
-
if limit and (total += 1) == limit
|
70
|
-
yield(batch)
|
71
|
-
return
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
yield(batch)
|
76
|
-
|
77
|
-
batch.size
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
nil
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
def in_groups_of size, options = {}, &block
|
86
|
-
|
87
|
-
group = []
|
88
|
-
|
89
|
-
each_batch(options) do |batch|
|
90
|
-
batch.each do |item|
|
91
|
-
group << item
|
92
|
-
if group.size == size
|
93
|
-
yield(group)
|
94
|
-
group = []
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
yield(group) unless group.empty?
|
100
|
-
|
101
|
-
nil
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
# @note +limit+ has no effect, simply ignored
|
106
|
-
# @note +batch_size+ has no effect, simply ignored
|
107
|
-
# @private
|
108
|
-
protected
|
109
|
-
def each_response options, limit, batch_size, &block
|
110
|
-
response = client.send(request_method, options)
|
111
|
-
yield(response)
|
112
|
-
end
|
113
|
-
|
114
|
-
# @note Define this method in classes including this module.
|
115
|
-
# @private
|
116
|
-
protected
|
117
|
-
def request_method
|
118
|
-
raise NotImplementedError
|
119
|
-
end
|
120
|
-
|
121
|
-
# @note Define this method in classes including this module.
|
122
|
-
# @private
|
123
|
-
protected
|
124
|
-
def each_item response
|
125
|
-
raise NotImplementedError
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
# @private
|
131
|
-
module Paged
|
132
|
-
|
133
|
-
include Basic
|
134
|
-
|
135
|
-
# @note +limit+ has no effect, simply ignored
|
136
|
-
# @note +batch_size+ has no effect, simply ignored
|
137
|
-
protected
|
138
|
-
def each_response options, limit, batch_size, &block
|
139
|
-
|
140
|
-
next_token = nil
|
141
|
-
|
142
|
-
begin
|
143
|
-
|
144
|
-
page_opts = {}
|
145
|
-
page_opts[next_token_key] = next_token if next_token
|
146
|
-
|
147
|
-
response = client.send(request_method, options.merge(page_opts))
|
148
|
-
|
149
|
-
yield(response)
|
150
|
-
|
151
|
-
next_token = next_token_for(response)
|
152
|
-
|
153
|
-
end until next_token.nil?
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
# Override this methid in collections that use a different name
|
158
|
-
# for the param that offsets the find (e.g. :marker, :next_key, etc).
|
159
|
-
# @private
|
160
|
-
protected
|
161
|
-
def next_token_key
|
162
|
-
raise NotImplementedError
|
163
|
-
end
|
164
|
-
|
165
|
-
# Override this method in collections that have an alternate method
|
166
|
-
# for finding the next token.
|
167
|
-
# @private
|
168
|
-
protected
|
169
|
-
def next_token_for response
|
170
|
-
method = next_token_key
|
171
|
-
response.respond_to?(method) ? response.send(method) : nil
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
# @private
|
177
|
-
module PagedWithLimits
|
178
|
-
|
179
|
-
include Paged
|
180
|
-
|
181
|
-
# A custom first method makes getting exactly one item much more
|
182
|
-
# efficient. Without the :limit => 1, an entire page of items
|
183
|
-
# is received and then only one is grabbed.
|
184
|
-
# @private
|
185
|
-
def first
|
186
|
-
enumerator(:limit => 1).first
|
187
|
-
end
|
188
|
-
|
189
|
-
# @private
|
190
|
-
protected
|
191
|
-
def each_response options, limit, batch_size, &block
|
192
|
-
|
193
|
-
total = 0
|
194
|
-
next_token = nil
|
195
|
-
|
196
|
-
begin
|
197
|
-
|
198
|
-
page_opts = {}
|
199
|
-
|
200
|
-
page_opts[next_token_key] = next_token if next_token
|
201
|
-
|
202
|
-
if limit or batch_size
|
203
|
-
max_items = []
|
204
|
-
max_items << (limit - total) if limit
|
205
|
-
max_items << batch_size if batch_size
|
206
|
-
page_opts[limit_key] = max_items.min
|
207
|
-
end
|
208
|
-
|
209
|
-
response = client.send(request_method, options.merge(page_opts))
|
210
|
-
|
211
|
-
total += yield(response)
|
212
|
-
|
213
|
-
next_token = next_token_for(response)
|
214
|
-
|
215
|
-
end until next_token.nil? or (limit and limit == total)
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
# Override this methid in collections that use a different name
|
220
|
-
# for the param that offsets the find (e.g. :marker, :next_key, etc).
|
221
|
-
# @private
|
222
|
-
protected
|
223
|
-
def limit_key
|
224
|
-
raise NotImplementedError
|
225
|
-
end
|
226
|
-
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|
230
|
-
end
|
data/lib/aws/configuration.rb
DELETED
@@ -1,357 +0,0 @@
|
|
1
|
-
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
require 'aws/default_signer'
|
15
|
-
require 'aws/http/httparty_handler'
|
16
|
-
require 'set'
|
17
|
-
require 'uri'
|
18
|
-
|
19
|
-
module AWS
|
20
|
-
|
21
|
-
# A configuration object for AWS interfaces and clients.
|
22
|
-
#
|
23
|
-
# == Configuring Credential
|
24
|
-
#
|
25
|
-
# In order to do anything with AWS you will need to assign credentials.
|
26
|
-
# The simplest method is to assing your credentials into the default
|
27
|
-
# configuration:
|
28
|
-
#
|
29
|
-
# AWS.config(:access_key_id => 'KEY', :secret_access_key => 'SECRET')
|
30
|
-
#
|
31
|
-
# You can also export them into your environment and they will be picked up
|
32
|
-
# automatically:
|
33
|
-
#
|
34
|
-
# export AWS_ACCESS_KEY_ID='YOUR_KEY_ID_HERE'
|
35
|
-
# export AWS_SECRET_ACCESS_KEY='YOUR_SECRET_KEY_HERE'
|
36
|
-
#
|
37
|
-
# For compatability with other AWS gems, the credentials can also be
|
38
|
-
# exported like:
|
39
|
-
#
|
40
|
-
# export AMAZON_ACCESS_KEY_ID='YOUR_KEY_ID_HERE'
|
41
|
-
# export AMAZON_SECRET_ACCESS_KEY='YOUR_SECRET_KEY_HERE'
|
42
|
-
#
|
43
|
-
# == Modifying a Configuration
|
44
|
-
#
|
45
|
-
# Configuration objects are read-only. If you need a different set of
|
46
|
-
# configuration values, call {#with}, passing in the updates
|
47
|
-
# and a new configuration object will be returned.
|
48
|
-
#
|
49
|
-
# config = Configuration.new(:max_retires => 3)
|
50
|
-
# new_config = config.with(:max_retries => 2)
|
51
|
-
#
|
52
|
-
# config.max_retries #=> 3
|
53
|
-
# new_config.max_retries #=> 2
|
54
|
-
#
|
55
|
-
# == Global Configuration
|
56
|
-
#
|
57
|
-
# The global default configuration can be found at {AWS.config}
|
58
|
-
#
|
59
|
-
# @attr_reader [String,nil] access_key_id AWS access key id credential.
|
60
|
-
# Defaults to +nil+.
|
61
|
-
#
|
62
|
-
# @attr_reader [String] ec2_endpoint The service endpoint for Amazon EC2.
|
63
|
-
# Defaults to 'ec2.amazonaws.com'.
|
64
|
-
#
|
65
|
-
# @attr_reader [Object] http_handler The http handler that sends requests
|
66
|
-
# to AWS. Defaults to an {AWS::HTTPartyHandler}.
|
67
|
-
#
|
68
|
-
# @attr_reader [String] iam_endpoint The service endpoint for AWS Idenity
|
69
|
-
# Access Management (IAM). Defaults to 'iam.amazonaws.com'.
|
70
|
-
#
|
71
|
-
# @attr_reader [Object,nil] logger A logger instance that
|
72
|
-
# should receive log messages generated by service requets.
|
73
|
-
# A logger needs to respond to #log and must accept a
|
74
|
-
# severity (e.g. :info, :error, etc) and a string message.
|
75
|
-
# Defaults to +nil+.
|
76
|
-
#
|
77
|
-
# @attr_reader [Integer] max_retries The maximum number of times
|
78
|
-
# service errors (500) should be retried. There is an exponential
|
79
|
-
# backoff in between service request retries, so the more retries the
|
80
|
-
# longer it can take to fail. Defautls to 3.
|
81
|
-
#
|
82
|
-
# @attr_reader [String, URI, nil] proxy_uri The URI of the proxy
|
83
|
-
# to send service requests through. You can pass a URI object or a
|
84
|
-
# URI string. Defautls to +nil+.
|
85
|
-
#
|
86
|
-
# AWS.config(:proxy_uri => 'https://user:password@my.proxy:443/path?query')
|
87
|
-
#
|
88
|
-
#
|
89
|
-
# @attr_reader [String] s3_endpoint The service endpoint for Amazon S3.
|
90
|
-
# Defaults to 's3.amazonaws.com'.
|
91
|
-
#
|
92
|
-
# @attr_reader [Integer] s3_multipart_max_parts The maximum number of
|
93
|
-
# parts to split a file into when uploading in parts to S3.
|
94
|
-
# Defaults to 1000.
|
95
|
-
#
|
96
|
-
# @attr_reader [Integer] s3_multipart_threshold (16777216) When uploading
|
97
|
-
# data to S3, if the number of bytes to send exceedes
|
98
|
-
# +:s3_multipart_threshold+ then a multi part session is automatically
|
99
|
-
# started and the data is sent up in chunks. The size of each part
|
100
|
-
# is specified by +:s3_multipart_min_part_size+. Defaults to
|
101
|
-
# 16777216 (16MB).
|
102
|
-
#
|
103
|
-
# @attr_reader [Integer] s3_multipart_min_part_size The absolute minimum
|
104
|
-
# size (in bytes) each S3 multipart segment should be.
|
105
|
-
# Defaults to 5242880 (5MB).
|
106
|
-
#
|
107
|
-
# @attr_reader [String,nil] secret_access_key AWS secret access key
|
108
|
-
# credential. Defaults to +nil+.
|
109
|
-
#
|
110
|
-
# @attr_reader [String,nil] session_token AWS secret token credential.
|
111
|
-
# Defaults to +nil+.
|
112
|
-
#
|
113
|
-
# @attr_reader [String] simple_db_endpoint The service endpoint for Amazon
|
114
|
-
# SimpleDB. Defaults to 'sdb.amazonaws.com'.
|
115
|
-
#
|
116
|
-
# @attr_reader [Boolean] simple_db_consistent_reads Determines
|
117
|
-
# if all SimpleDB read requests should be done consistently.
|
118
|
-
# Consistent reads are slower, but reflect all changes to SDB.
|
119
|
-
# Defaults to +false+.
|
120
|
-
#
|
121
|
-
# @attr_reader [String] simple_email_service_endpoint The service endpoint
|
122
|
-
# for Amazon Simple Email Service. Defaults to
|
123
|
-
# 'email.us-east-1.amazonaws.com'.
|
124
|
-
#
|
125
|
-
# @attr_reader [Object] signer The request signer. Defaults to
|
126
|
-
# a default request signer implementation.
|
127
|
-
#
|
128
|
-
# @attr_reader [String] ssl_ca_file The path to a CA cert bundle in
|
129
|
-
# PEM format.
|
130
|
-
#
|
131
|
-
# If +ssl_verify_peer+ is true (the default) this bundle will be
|
132
|
-
# used to validate the server certificate in each HTTPS request.
|
133
|
-
# The AWS SDK for Ruby ships with a CA cert bundle, which is the
|
134
|
-
# default value for this option.
|
135
|
-
#
|
136
|
-
# @attr_reader [Boolean] ssl_verify_peer When +true+
|
137
|
-
# the HTTP handler validate server certificates for HTTPS requests.
|
138
|
-
# Defaults to +true+.
|
139
|
-
#
|
140
|
-
# This option should only be disabled for diagnostic purposes;
|
141
|
-
# leaving this option set to +false+ exposes your application to
|
142
|
-
# man-in-the-middle attacks and can pose a serious security
|
143
|
-
# risk.
|
144
|
-
#
|
145
|
-
# @attr_reader [Boolean] stub_requests When +true+ requests are not
|
146
|
-
# sent to AWS, instead empty reponses are generated and returned to
|
147
|
-
# each service request.
|
148
|
-
#
|
149
|
-
# @attr_reader [String] sns_endpoint The service endpoint for Amazon SNS.
|
150
|
-
# Defaults to 'sns.us-east-1.amazonaws.com'.
|
151
|
-
#
|
152
|
-
# @attr_reader [String] sqs_endpoint The service endpoint for Amazon SQS.
|
153
|
-
# Defaults to 'sqs.us-east-1.amazonaws.com'.
|
154
|
-
#
|
155
|
-
# @attr_reader [String] sts_endpoint The service endpoint for AWS
|
156
|
-
# Security Token Service. Defaults to 'sts.amazonaws.com'.
|
157
|
-
#
|
158
|
-
# @attr_reader [Boolean] use_ssl When +true+, all requests
|
159
|
-
# to AWS are sent using HTTPS instead vanilla HTTP.
|
160
|
-
# Defaults to +true+.
|
161
|
-
#
|
162
|
-
# @attr_reader [String] user_agent_prefix A string prefix to
|
163
|
-
# append to all requets against AWS services. This should be set
|
164
|
-
# for clients and applications built ontop of the aws-sdk gem.
|
165
|
-
# Defaults to +nil+.
|
166
|
-
#
|
167
|
-
class Configuration
|
168
|
-
|
169
|
-
# Creates a new Configuration object.
|
170
|
-
# @param options (see AWS.config)
|
171
|
-
# @option options (see AWS.config)
|
172
|
-
def initialize options = {}
|
173
|
-
|
174
|
-
@created = options.delete(:__created__) || {}
|
175
|
-
|
176
|
-
options.each_pair do |opt_name, value|
|
177
|
-
opt_name = opt_name.to_sym
|
178
|
-
if self.class.accepted_options.include?(opt_name)
|
179
|
-
supplied[opt_name] = value
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
# Used to create a new Configuration object with the given modifications.
|
186
|
-
# The current configuration object is not modified.
|
187
|
-
#
|
188
|
-
# AWS.config(:max_retries => 2)
|
189
|
-
#
|
190
|
-
# no_retries_config = AWS.config.with(:max_retries => 0)
|
191
|
-
#
|
192
|
-
# AWS.config.max_retries #=> 2
|
193
|
-
# no_retries_config.max_retries #=> 0
|
194
|
-
#
|
195
|
-
# You can use these configuration objects returned by #with to create
|
196
|
-
# AWS objects:
|
197
|
-
#
|
198
|
-
# AWS::S3.new(:config => no_retries_config)
|
199
|
-
# AWS::SQS.new(:config => no_retries_config)
|
200
|
-
#
|
201
|
-
# @param options (see AWS.config)
|
202
|
-
# @option options (see AWS.config)
|
203
|
-
# @return [Configuration] Copies the current configuration and returns
|
204
|
-
# a new one with modifications as provided in +:options+.
|
205
|
-
def with options = {}
|
206
|
-
|
207
|
-
# symbolize option keys
|
208
|
-
options = options.inject({}) {|h,kv| h[kv.first.to_sym] = kv.last; h }
|
209
|
-
|
210
|
-
values = supplied.merge(options)
|
211
|
-
|
212
|
-
if supplied == values
|
213
|
-
self # nothing changed
|
214
|
-
else
|
215
|
-
self.class.new(values.merge(:__created__ => @created.dup))
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|
219
|
-
|
220
|
-
# @return [Hash] Returns a hash of all configuration values.
|
221
|
-
def to_h
|
222
|
-
self.class.accepted_options.inject({}) do |h,k|
|
223
|
-
h[k] = send(k)
|
224
|
-
h
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
# @return [Boolean] Returns true if the two configuration objects have
|
229
|
-
# the same values.
|
230
|
-
def == other
|
231
|
-
other.is_a?(self.class) and self.supplied == other.supplied
|
232
|
-
end
|
233
|
-
|
234
|
-
alias_method :eql, :==
|
235
|
-
|
236
|
-
# @private
|
237
|
-
def inspect
|
238
|
-
"<#{self.class.name}>"
|
239
|
-
end
|
240
|
-
|
241
|
-
protected
|
242
|
-
def supplied
|
243
|
-
@supplied ||= {}
|
244
|
-
end
|
245
|
-
|
246
|
-
class << self
|
247
|
-
|
248
|
-
# @private
|
249
|
-
def accepted_options
|
250
|
-
@options ||= Set.new
|
251
|
-
end
|
252
|
-
|
253
|
-
# @private
|
254
|
-
def add_option name, default_value = nil, options = {}, &transform
|
255
|
-
|
256
|
-
accepted_options << name
|
257
|
-
|
258
|
-
define_method(name) do
|
259
|
-
value = supplied.has_key?(name) ? supplied[name] : default_value
|
260
|
-
transform ? transform.call(value) : value
|
261
|
-
end
|
262
|
-
|
263
|
-
alias_method("#{name}?", name) if options[:boolean]
|
264
|
-
|
265
|
-
end
|
266
|
-
|
267
|
-
# Configuration options that have dependencies are re-recreated
|
268
|
-
# anytime one of their dependendent configuration values are
|
269
|
-
# changed.
|
270
|
-
# @private
|
271
|
-
def add_option_with_needs name, needs, &create_block
|
272
|
-
|
273
|
-
accepted_options << name
|
274
|
-
|
275
|
-
define_method(name) do
|
276
|
-
|
277
|
-
return supplied[name] if supplied.has_key?(name)
|
278
|
-
|
279
|
-
needed = needs.collect{|need| send(need) }
|
280
|
-
|
281
|
-
unless @created.key?(name) and @created[name][:needed] == needed
|
282
|
-
@created[name] = {}
|
283
|
-
@created[name][:object] = create_block.call(self)
|
284
|
-
@created[name][:needed] = needed
|
285
|
-
end
|
286
|
-
|
287
|
-
@created[name][:object]
|
288
|
-
|
289
|
-
end
|
290
|
-
|
291
|
-
end
|
292
|
-
|
293
|
-
end
|
294
|
-
|
295
|
-
add_option :access_key_id,
|
296
|
-
ENV['AWS_ACCESS_KEY_ID'] || ENV['AMAZON_ACCESS_KEY_ID']
|
297
|
-
|
298
|
-
add_option :ec2_endpoint, 'ec2.amazonaws.com'
|
299
|
-
|
300
|
-
add_option :s3_endpoint, 's3.amazonaws.com'
|
301
|
-
|
302
|
-
add_option :http_handler, Http::HTTPartyHandler.new
|
303
|
-
|
304
|
-
add_option :iam_endpoint, 'iam.amazonaws.com'
|
305
|
-
|
306
|
-
add_option :logger
|
307
|
-
|
308
|
-
add_option :max_retries, 3
|
309
|
-
|
310
|
-
add_option :proxy_uri do |uri| uri ? URI.parse(uri.to_s) : nil end
|
311
|
-
|
312
|
-
add_option :s3_multipart_threshold, 16 * 1024 * 1024
|
313
|
-
|
314
|
-
add_option :s3_multipart_min_part_size, 5 * 1024 * 1024
|
315
|
-
|
316
|
-
add_option :s3_multipart_max_parts, 10000
|
317
|
-
|
318
|
-
add_option :secret_access_key,
|
319
|
-
ENV['AWS_SECRET_ACCESS_KEY'] || ENV['AMAZON_SECRET_ACCESS_KEY']
|
320
|
-
|
321
|
-
add_option :session_token
|
322
|
-
|
323
|
-
add_option_with_needs :signer,
|
324
|
-
[:access_key_id, :secret_access_key, :session_token] do |config|
|
325
|
-
|
326
|
-
DefaultSigner.new(
|
327
|
-
config.access_key_id,
|
328
|
-
config.secret_access_key,
|
329
|
-
config.session_token)
|
330
|
-
|
331
|
-
end
|
332
|
-
|
333
|
-
add_option :simple_db_endpoint, 'sdb.amazonaws.com'
|
334
|
-
|
335
|
-
add_option :simple_db_consistent_reads, false, :boolean => true
|
336
|
-
|
337
|
-
add_option :simple_email_service_endpoint, 'email.us-east-1.amazonaws.com'
|
338
|
-
|
339
|
-
add_option :sns_endpoint, 'sns.us-east-1.amazonaws.com'
|
340
|
-
|
341
|
-
add_option :sqs_endpoint, 'sqs.us-east-1.amazonaws.com'
|
342
|
-
|
343
|
-
add_option :ssl_verify_peer, true, :boolean => true
|
344
|
-
|
345
|
-
add_option :ssl_ca_file,
|
346
|
-
File.expand_path(File.dirname(__FILE__) + "/../../ca-bundle.crt")
|
347
|
-
|
348
|
-
add_option :sts_endpoint, 'sts.amazonaws.com'
|
349
|
-
|
350
|
-
add_option :stub_requests, false, :boolean => true
|
351
|
-
|
352
|
-
add_option :use_ssl, true, :boolean => true
|
353
|
-
|
354
|
-
add_option :user_agent_prefix
|
355
|
-
|
356
|
-
end
|
357
|
-
end
|