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,149 @@
|
|
|
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/cacheable'
|
|
16
|
+
|
|
17
|
+
module AWS
|
|
18
|
+
class EC2
|
|
19
|
+
|
|
20
|
+
# Represents an attachment of an Amazon EBS volume to an instance.
|
|
21
|
+
#
|
|
22
|
+
# @example Create an empty 15GiB volume and attach it to an instance
|
|
23
|
+
# volume = ec2.volumes.create(:size => 15,
|
|
24
|
+
# :availability_zone => "us-east-1a")
|
|
25
|
+
# attachment = volume.attach_to(ec2.instances["i-123"], "/dev/sdf")
|
|
26
|
+
# sleep 1 until attachment.status != :attaching
|
|
27
|
+
#
|
|
28
|
+
# @example Remove all attachments from a volume and then delete it
|
|
29
|
+
# volume.attachments.each do |attachment|
|
|
30
|
+
# attachment.delete(:force => true)
|
|
31
|
+
# end
|
|
32
|
+
# sleep 1 until volume.status == :available
|
|
33
|
+
# volume.delete
|
|
34
|
+
class Attachment
|
|
35
|
+
|
|
36
|
+
include Model
|
|
37
|
+
include Cacheable
|
|
38
|
+
|
|
39
|
+
attr_reader :volume
|
|
40
|
+
attr_reader :instance
|
|
41
|
+
attr_reader :device
|
|
42
|
+
|
|
43
|
+
# @private
|
|
44
|
+
def initialize(volume, instance, device, opts = {})
|
|
45
|
+
@volume = volume
|
|
46
|
+
@instance = instance
|
|
47
|
+
@device = device
|
|
48
|
+
super(opts)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# (see Volume#detach_from)
|
|
52
|
+
def delete(opts = {})
|
|
53
|
+
client.detach_volume(opts.merge(:volume_id => volume.id,
|
|
54
|
+
:instance_id => instance.id,
|
|
55
|
+
:device => device))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @return [Symbol] The attachment status. Possible values:
|
|
59
|
+
# * +:attaching+
|
|
60
|
+
# * +:attached+
|
|
61
|
+
# * +:detaching+
|
|
62
|
+
# * +:detached+
|
|
63
|
+
def status
|
|
64
|
+
retrieve_attribute(:status) { describe_call }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @return [Time] The time at which this attachment was created.
|
|
68
|
+
def attach_time
|
|
69
|
+
retrieve_attribute(:attach_time) { describe_call }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# @return [Boolean] True if the volume will be deleted on
|
|
73
|
+
# instance termination.
|
|
74
|
+
def delete_on_termination?
|
|
75
|
+
retrieve_attribute(:delete_on_termination?) { describe_call }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @return [Boolean] True if the attachment exists.
|
|
79
|
+
def exists?
|
|
80
|
+
!describe_attachment.nil?
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @return [Boolean] True if the attachments are the same.
|
|
84
|
+
#
|
|
85
|
+
# @param [Object] other The object to compare with.
|
|
86
|
+
def ==(other)
|
|
87
|
+
other.kind_of?(Attachment) and
|
|
88
|
+
other.volume == volume and
|
|
89
|
+
other.instance == instance and
|
|
90
|
+
other.device == device
|
|
91
|
+
end
|
|
92
|
+
alias_method :eql?, :==
|
|
93
|
+
|
|
94
|
+
populate_from :describe_volumes do |resp|
|
|
95
|
+
if volume = resp.volume_index[self.volume.id] and
|
|
96
|
+
attachments = volume.attachment_set and
|
|
97
|
+
attachment = attachments.find do |att|
|
|
98
|
+
att.instance_id == self.instance.id &&
|
|
99
|
+
att.volume_id == self.volume.id &&
|
|
100
|
+
att.device == self.device
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
attributes_from_response_object(attachment)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
[:attach_volume,
|
|
108
|
+
:detach_volume].each do |op|
|
|
109
|
+
populate_from op do |resp|
|
|
110
|
+
attributes_from_response_object(resp) if
|
|
111
|
+
resp.volume_id == volume.id and
|
|
112
|
+
resp.instance_id == instance.id and
|
|
113
|
+
resp.device == device
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
protected
|
|
118
|
+
def attributes_from_response_object(attachment)
|
|
119
|
+
atts = {}
|
|
120
|
+
atts[:status] = (attachment.status.to_sym if
|
|
121
|
+
attachment.respond_to?(:status))
|
|
122
|
+
atts[:attach_time] = (attachment.attach_time if
|
|
123
|
+
attachment.respond_to?(:attach_time))
|
|
124
|
+
atts[:delete_on_termination?] = (attachment.delete_on_termination? if
|
|
125
|
+
attachment.respond_to?(:delete_on_termination?))
|
|
126
|
+
atts
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
protected
|
|
130
|
+
def describe_call
|
|
131
|
+
client.describe_volumes(:volume_ids => [self.volume.id])
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
private
|
|
135
|
+
def describe_attachment
|
|
136
|
+
(resp = describe_call and
|
|
137
|
+
volume = resp.volume_index[self.volume.id] and
|
|
138
|
+
attachments = volume.attachment_set and
|
|
139
|
+
attachment = attachments.find do |att|
|
|
140
|
+
att.instance_id == self.instance.id &&
|
|
141
|
+
att.volume_id == self.volume.id &&
|
|
142
|
+
att.device == self.device
|
|
143
|
+
end) or nil
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|
|
149
|
+
end
|
|
@@ -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/model'
|
|
15
|
+
require 'aws/ec2/volume'
|
|
16
|
+
require 'aws/ec2/instance'
|
|
17
|
+
require 'aws/ec2/attachment'
|
|
18
|
+
|
|
19
|
+
module AWS
|
|
20
|
+
class EC2
|
|
21
|
+
|
|
22
|
+
# Represents the collection of attachments for an Amazon EBS
|
|
23
|
+
# volume.
|
|
24
|
+
#
|
|
25
|
+
# @see Volume
|
|
26
|
+
class AttachmentCollection
|
|
27
|
+
|
|
28
|
+
include Model
|
|
29
|
+
include Enumerable
|
|
30
|
+
|
|
31
|
+
attr_reader :volume
|
|
32
|
+
|
|
33
|
+
# @private
|
|
34
|
+
def initialize(volume, opts = {})
|
|
35
|
+
@volume = volume
|
|
36
|
+
super(opts)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @yield [attachment] Each attachment of the volume as an
|
|
40
|
+
# {Attachment} object.
|
|
41
|
+
# @return [nil]
|
|
42
|
+
def each(&block)
|
|
43
|
+
volume.attachment_set.each do |att|
|
|
44
|
+
instance = Instance.new(att.instance_id, :config => config)
|
|
45
|
+
attachment = Attachment.new(self.volume,
|
|
46
|
+
instance,
|
|
47
|
+
att.device,
|
|
48
|
+
:config => config)
|
|
49
|
+
yield(attachment)
|
|
50
|
+
end
|
|
51
|
+
nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
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/ec2/resource'
|
|
15
|
+
|
|
16
|
+
module AWS
|
|
17
|
+
class EC2
|
|
18
|
+
|
|
19
|
+
# Represents an EC2 availability zone. You can use this class
|
|
20
|
+
# to get information about the state of an availability zone
|
|
21
|
+
# that is available to your account.
|
|
22
|
+
class AvailabilityZone < Resource
|
|
23
|
+
|
|
24
|
+
# @return [String] Returns the name of the availability zone,
|
|
25
|
+
# e.g. "us-east-1a".
|
|
26
|
+
attr_reader :name
|
|
27
|
+
|
|
28
|
+
alias_method :to_s, :name
|
|
29
|
+
alias_method :to_str, :name
|
|
30
|
+
|
|
31
|
+
# @param [String] name The name of the availability zone.
|
|
32
|
+
def initialize(name, opts = {})
|
|
33
|
+
@name = name
|
|
34
|
+
@region = opts[:region]
|
|
35
|
+
super(opts)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @return [Region] The region of this availability zone.
|
|
39
|
+
def region; end
|
|
40
|
+
describe_call_attribute :region_name, :getter => :region, :memoize => true do
|
|
41
|
+
translate_output do |value|
|
|
42
|
+
Region.new(value, :config => config) if value
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [Symbol] The state of the availability zone,
|
|
47
|
+
# e.g. +:available+.
|
|
48
|
+
def state; end
|
|
49
|
+
describe_call_attribute :zone_state, :getter => :state, :to_sym => true
|
|
50
|
+
|
|
51
|
+
# @return [Array] A list of messages about the Availability
|
|
52
|
+
# Zone.
|
|
53
|
+
def messages; end
|
|
54
|
+
describe_call_attribute :message_set, :getter => :messages do
|
|
55
|
+
translate_output { |set| set.map { |m| m.message } if set }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
protected
|
|
59
|
+
def inflected_name
|
|
60
|
+
"zone"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
protected
|
|
64
|
+
def find_in_response(resp)
|
|
65
|
+
resp.availability_zone_info.find { |az| az.zone_name == name }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# @private
|
|
69
|
+
private
|
|
70
|
+
def get_attribute(name)
|
|
71
|
+
resp = client.describe_availability_zones(:zone_names =>
|
|
72
|
+
[self.name])
|
|
73
|
+
az = resp.availability_zone_info.first
|
|
74
|
+
az.send(name)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
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/ec2/collection'
|
|
15
|
+
require 'aws/ec2/availability_zone'
|
|
16
|
+
|
|
17
|
+
module AWS
|
|
18
|
+
class EC2
|
|
19
|
+
|
|
20
|
+
# Represents all EC2 availability zones that are currently
|
|
21
|
+
# available to your account.
|
|
22
|
+
class AvailabilityZoneCollection < Collection
|
|
23
|
+
|
|
24
|
+
# Yields each of the EC2 availability zones.
|
|
25
|
+
# @return [nil]
|
|
26
|
+
def each &block
|
|
27
|
+
resp = filtered_request(:describe_availability_zones)
|
|
28
|
+
resp.availability_zone_info.each do |az|
|
|
29
|
+
zone = AvailabilityZone.new(az.zone_name,
|
|
30
|
+
:region => Region.new(az.region_name, :config => config),
|
|
31
|
+
:config => config
|
|
32
|
+
)
|
|
33
|
+
yield(zone)
|
|
34
|
+
end
|
|
35
|
+
nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @private
|
|
39
|
+
protected
|
|
40
|
+
def member_class
|
|
41
|
+
AvailabilityZone
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
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 EC2
|
|
16
|
+
|
|
17
|
+
# @private
|
|
18
|
+
module BlockDeviceMappings
|
|
19
|
+
|
|
20
|
+
# @private
|
|
21
|
+
private
|
|
22
|
+
def translate_block_device_mappings(mapping)
|
|
23
|
+
raise ArgumentError.new("block_device_mappings must be a hash") unless
|
|
24
|
+
mapping.kind_of?(Hash)
|
|
25
|
+
mapping.map do |device, dest|
|
|
26
|
+
raise ArgumentError.new("keys of block_device_mappings must be strings") unless
|
|
27
|
+
device.kind_of?(String)
|
|
28
|
+
entry = { :device_name => device }
|
|
29
|
+
case dest
|
|
30
|
+
when :no_device
|
|
31
|
+
# for some reason EC2 rejects boolean values for this seemingly boolean option
|
|
32
|
+
entry[:no_device] = ""
|
|
33
|
+
when Symbol
|
|
34
|
+
raise ArgumentError.new("unrecognized block device mapping: #{dest}")
|
|
35
|
+
when String
|
|
36
|
+
entry[:virtual_name] = dest
|
|
37
|
+
when Hash
|
|
38
|
+
if snapshot = dest.delete(:snapshot)
|
|
39
|
+
dest[:snapshot_id] = snapshot.id
|
|
40
|
+
end
|
|
41
|
+
entry[:ebs] = dest
|
|
42
|
+
else
|
|
43
|
+
raise ArgumentError.new("values of block_device_mappings must "+
|
|
44
|
+
"be strings, symbols, or hashes")
|
|
45
|
+
end
|
|
46
|
+
entry
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
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/ec2/request'
|
|
17
|
+
require 'aws/ec2/client/xml'
|
|
18
|
+
require 'aws/ec2/errors'
|
|
19
|
+
require 'aws/inflection'
|
|
20
|
+
|
|
21
|
+
module AWS
|
|
22
|
+
class EC2
|
|
23
|
+
|
|
24
|
+
# @private
|
|
25
|
+
class Client < BaseClient
|
|
26
|
+
|
|
27
|
+
include ConfiguredClientMethods
|
|
28
|
+
|
|
29
|
+
API_VERSION = '2011-02-28'
|
|
30
|
+
|
|
31
|
+
REQUEST_CLASS = EC2::Request
|
|
32
|
+
|
|
33
|
+
# @private
|
|
34
|
+
CACHEABLE_REQUESTS = Set[:describe_instances,
|
|
35
|
+
:describe_instance_attribute,
|
|
36
|
+
:describe_images,
|
|
37
|
+
:describe_image_attribute,
|
|
38
|
+
:describe_volumes,
|
|
39
|
+
:describe_security_groups,
|
|
40
|
+
:describe_addresses,
|
|
41
|
+
:describe_key_pairs,
|
|
42
|
+
:describe_regions,
|
|
43
|
+
:describe_availability_zones,
|
|
44
|
+
:describe_reserved_instances,
|
|
45
|
+
:describe_reserved_instances_offerings,
|
|
46
|
+
:describe_snapshots,
|
|
47
|
+
:describe_snapshot_attribute,
|
|
48
|
+
:describe_tags]
|
|
49
|
+
|
|
50
|
+
configure_client
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
class EC2
|
|
18
|
+
class Client < BaseClient
|
|
19
|
+
module XML
|
|
20
|
+
|
|
21
|
+
include ConfiguredXmlGrammars
|
|
22
|
+
|
|
23
|
+
BaseError = XmlGrammar.customize do
|
|
24
|
+
element "Errors" do
|
|
25
|
+
ignore
|
|
26
|
+
element("Error") { ignore }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
define_configured_grammars
|
|
31
|
+
|
|
32
|
+
CustomizedDescribeSecurityGroups = DescribeSecurityGroups.customize do
|
|
33
|
+
element "securityGroupInfo" do
|
|
34
|
+
element "item" do
|
|
35
|
+
index(:security_group_index) { |i| i.group_id }
|
|
36
|
+
|
|
37
|
+
element "ipPermissions" do
|
|
38
|
+
list "item"
|
|
39
|
+
element "item" do
|
|
40
|
+
element("ipProtocol") { symbol_value }
|
|
41
|
+
element("fromPort") { integer_value }
|
|
42
|
+
element("toPort") { integer_value }
|
|
43
|
+
element("groups") { list "item" }
|
|
44
|
+
element("ipRanges") { list "item" }
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
CustomizedDescribeInstances = DescribeInstances.customize do
|
|
52
|
+
element "reservationSet" do
|
|
53
|
+
element "item" do
|
|
54
|
+
index :reservation_index do |r|
|
|
55
|
+
r.instances_set.map { |i| i.instance_id }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
element "instancesSet" do
|
|
59
|
+
element "item" do
|
|
60
|
+
index(:instance_index) { |i| i.instance_id }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
CustomizedDescribeImages = DescribeImages.customize do
|
|
68
|
+
element "imagesSet" do
|
|
69
|
+
element "item" do
|
|
70
|
+
index(:image_index) { |i| i.image_id }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
CustomizedDescribeVolumes = DescribeVolumes.customize do
|
|
76
|
+
element "volumeSet" do
|
|
77
|
+
element "item" do
|
|
78
|
+
index(:volume_index) { |v| v.volume_id }
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
CustomizedDescribeSnapshots = DescribeSnapshots.customize do
|
|
84
|
+
element "snapshotSet" do
|
|
85
|
+
element "item" do
|
|
86
|
+
index(:snapshot_index) { |s| s.snapshot_id }
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
CustomizedDescribeAddresses = DescribeAddresses.customize do
|
|
92
|
+
element "addressesSet" do
|
|
93
|
+
element "item" do
|
|
94
|
+
index(:address_index) { |a| a.public_ip }
|
|
95
|
+
element "instanceId" do
|
|
96
|
+
force
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
CustomizedDescribeKeyPairs = DescribeKeyPairs.customize do
|
|
103
|
+
element "keySet" do
|
|
104
|
+
element "item" do
|
|
105
|
+
index(:key_index) { |k| k.key_name }
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
CustomizedDescribeTags = DescribeTags.customize do
|
|
111
|
+
element "tagSet" do
|
|
112
|
+
element "item" do
|
|
113
|
+
element("resourceType") { force }
|
|
114
|
+
element("resourceId") { force }
|
|
115
|
+
element("key") { force }
|
|
116
|
+
index(:tag_index) do |t|
|
|
117
|
+
"#{t.resource_type}:#{t.resource_id}:#{t.key}"
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|