grempe-amazon-ec2 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,166 +1,122 @@
1
1
  #--
2
- # Amazon Web Services EC2 Query API Ruby library
3
- #
4
- # Ruby Gem Name:: amazon-ec2
5
- # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
- # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
7
- # License:: Distributes under the same terms as Ruby
8
- # Home:: http://github.com/grempe/amazon-ec2/tree/master
2
+ # AWS EC2 CLIENT ERROR CODES
3
+ # AWS EC2 can throw error exceptions that contain a '.' in them.
4
+ # since we can't name an exception class with that '.' I compressed
5
+ # each class name into the non-dot version. This allows us to retain
6
+ # the granularity of the exception.
9
7
  #++
10
8
 
11
9
  module AWS
12
- # OUR CUSTOM ERROR CODES
13
10
 
14
- # All of our errors are superclassed by Error < RuntimeError
15
- class Error < RuntimeError #:nodoc:
16
- end
11
+ # All AWS errors are superclassed by Error < RuntimeError
12
+ class Error < RuntimeError; end
17
13
 
18
- # A client side only argument error
19
- class ArgumentError < Error #:nodoc:
20
- end
14
+ # CLIENT : A client side argument error
15
+ class ArgumentError < Error; end
21
16
 
17
+ # EC2 : User not authorized.
18
+ class AuthFailure < Error; end
22
19
 
23
- # AWS EC2 CLIENT ERROR CODES
20
+ # EC2 : Invalid AWS Account
21
+ class InvalidClientTokenId < Error; end
24
22
 
25
- # AWS EC2 can throw error exceptions that contain a '.' in them.
26
- # since we can't name an exception class with that '.' I compressed
27
- # each class name into the non-dot version. This allows us to retain
28
- # the granularity of the exception.
23
+ # EC2 : Invalid Parameters for Value
24
+ class InvalidParameterValue < Error; end
29
25
 
30
- # User not authorized.
31
- class AuthFailure < Error #:nodoc:
32
- end
26
+ # EC2 : Specified AMI has an unparsable manifest.
27
+ class InvalidManifest < Error; end
33
28
 
34
- # Invalid AWS Account
35
- class InvalidClientTokenId < Error #:nodoc:
36
- end
29
+ # EC2 : Specified AMI ID is not valid.
30
+ class InvalidAMIIDMalformed < Error; end
37
31
 
38
- # Invalid Parameters for Value
39
- class InvalidParameterValue < Error #:nodoc:
40
- end
32
+ # EC2 : Specified AMI ID does not exist.
33
+ class InvalidAMIIDNotFound < Error; end
41
34
 
42
- # Specified AMI has an unparsable manifest.
43
- class InvalidManifest < Error #:nodoc:
44
- end
35
+ # EC2 : Specified AMI ID has been deregistered and is no longer available.
36
+ class InvalidAMIIDUnavailable < Error; end
45
37
 
46
- # Specified AMI ID is not valid.
47
- class InvalidAMIIDMalformed < Error #:nodoc:
48
- end
38
+ # EC2 : Specified instance ID is not valid.
39
+ class InvalidInstanceIDMalformed < Error; end
49
40
 
50
- # Specified AMI ID does not exist.
51
- class InvalidAMIIDNotFound < Error #:nodoc:
52
- end
41
+ # EC2 : Specified instance ID does not exist.
42
+ class InvalidInstanceIDNotFound < Error; end
53
43
 
54
- # Specified AMI ID has been deregistered and is no longer available.
55
- class InvalidAMIIDUnavailable < Error #:nodoc:
56
- end
44
+ # EC2 : Specified keypair name does not exist.
45
+ class InvalidKeyPairNotFound < Error; end
57
46
 
58
- # Specified instance ID is not valid.
59
- class InvalidInstanceIDMalformed < Error #:nodoc:
60
- end
47
+ # EC2 : Attempt to create a duplicate keypair.
48
+ class InvalidKeyPairDuplicate < Error; end
61
49
 
62
- # Specified instance ID does not exist.
63
- class InvalidInstanceIDNotFound < Error #:nodoc:
64
- end
50
+ # EC2 : Specified group name does not exist.
51
+ class InvalidGroupNotFound < Error; end
65
52
 
66
- # Specified keypair name does not exist.
67
- class InvalidKeyPairNotFound < Error #:nodoc:
68
- end
53
+ # EC2 : Attempt to create a duplicate group.
54
+ class InvalidGroupDuplicate < Error; end
69
55
 
70
- # Attempt to create a duplicate keypair.
71
- class InvalidKeyPairDuplicate < Error #:nodoc:
72
- end
56
+ # EC2 : Specified group can not be deleted because it is in use.
57
+ class InvalidGroupInUse < Error; end
73
58
 
74
- # Specified group name does not exist.
75
- class InvalidGroupNotFound < Error #:nodoc:
76
- end
59
+ # EC2 : Specified group name is a reserved name.
60
+ class InvalidGroupReserved < Error; end
77
61
 
78
- # Attempt to create a duplicate group.
79
- class InvalidGroupDuplicate < Error #:nodoc:
80
- end
62
+ # EC2 : Attempt to authorize a permission that has already been authorized.
63
+ class InvalidPermissionDuplicate < Error; end
81
64
 
82
- # Specified group can not be deleted because it is in use.
83
- class InvalidGroupInUse < Error #:nodoc:
84
- end
65
+ # EC2 : Specified permission is invalid.
66
+ class InvalidPermissionMalformed < Error; end
85
67
 
86
- # Specified group name is a reserved name.
87
- class InvalidGroupReserved < Error #:nodoc:
88
- end
68
+ # EC2 : Specified reservation ID is invalid.
69
+ class InvalidReservationIDMalformed < Error; end
89
70
 
90
- # Attempt to authorize a permission that has already been authorized.
91
- class InvalidPermissionDuplicate < Error #:nodoc:
92
- end
71
+ # EC2 : Specified reservation ID does not exist.
72
+ class InvalidReservationIDNotFound < Error; end
93
73
 
94
- # Specified permission is invalid.
95
- class InvalidPermissionMalformed < Error #:nodoc:
96
- end
74
+ # EC2 : User has reached max allowed concurrent running instances.
75
+ class InstanceLimitExceeded < Error; end
97
76
 
98
- # Specified reservation ID is invalid.
99
- class InvalidReservationIDMalformed < Error #:nodoc:
100
- end
77
+ # EC2 : An invalid set of parameters were passed as arguments
78
+ class InvalidParameterCombination < Error; end
101
79
 
102
- # Specified reservation ID does not exist.
103
- class InvalidReservationIDNotFound < Error #:nodoc:
104
- end
80
+ # EC2 : An unknown parameter was passed as an argument
81
+ class UnknownParameter < Error; end
105
82
 
106
- # User has reached max allowed concurrent running instances.
107
- class InstanceLimitExceeded < Error #:nodoc:
108
- end
109
-
110
- # An invalid set of parameters were passed as arguments
111
- # e.g. RunInstances was called with minCount and maxCount set to 0 or minCount > maxCount.
112
- class InvalidParameterCombination < Error #:nodoc:
113
- end
114
-
115
- # An unknown parameter was passed as an argument
116
- class UnknownParameter < Error #:nodoc:
117
- end
118
-
119
- # The user ID is neither in the form of an AWS account ID or one
83
+ # EC2 : The user ID is neither in the form of an AWS account ID or one
120
84
  # of the special values accepted by the owner or executableBy flags
121
85
  # in the DescribeImages call.
122
- class InvalidUserIDMalformed < Error #:nodoc:
123
- end
86
+ class InvalidUserIDMalformed < Error; end
124
87
 
125
- # The value of an item added to, or removed from, an image attribute is invalid.
126
- class InvalidAMIAttributeItemValue < Error #:nodoc:
127
- end
88
+ # EC2 : The value of an item added to, or removed from, an image attribute is invalid.
89
+ class InvalidAMIAttributeItemValue < Error; end
128
90
 
129
- # ELB ERRORS
91
+ # ELB : The Load balancer specified was not found.
92
+ class LoadBalancerNotFound < Error; end
130
93
 
131
- class LoadBalancerNotFound < Error #:nodoc:
132
- end
94
+ # ELB :
95
+ class ValidationError < Error; end
133
96
 
134
- class ValidationError < Error #:nodoc:
135
- end
97
+ # ELB :
98
+ class DuplicateLoadBalancerName < Error; end
136
99
 
137
- class DuplicateLoadBalancerName < Error #:nodoc:
138
- end
100
+ # ELB :
101
+ class TooManyLoadBalancers < Error; end
139
102
 
140
- class TooManyLoadBalancers < Error #:nodoc:
141
- end
103
+ # ELB :
104
+ class InvalidInstance < Error; end
142
105
 
143
- class InvalidInstance < Error #:nodoc:
144
- end
106
+ # ELB :
107
+ class InvalidConfigurationRequest < Error; end
145
108
 
146
- class InvalidConfigurationRequest < Error #:nodoc:
147
- end
109
+ # Server : Internal AWS EC2 Error.
110
+ class InternalError < Error; end
148
111
 
149
- # AWS EC2 SERVER ERROR CODES
112
+ # Server : There are not enough available instances to satisfy your minimum request.
113
+ class InsufficientInstanceCapacity < Error; end
150
114
 
151
- # Internal AWS EC2 Error.
152
- class InternalError < Error #:nodoc:
153
- end
115
+ # Server : The server is overloaded and cannot handle the request.
116
+ class Unavailable < Error; end
154
117
 
155
- # There are not enough available instances to satify your minimum request.
156
- class InsufficientInstanceCapacity < Error #:nodoc:
157
- end
158
-
159
- # The server is overloaded and cannot handle request.
160
- class Unavailable < Error #:nodoc:
161
- end
162
-
163
- class SignatureDoesNotMatch < Error #:nodoc:
164
- end
118
+ # Server : The provided signature does not match.
119
+ class SignatureDoesNotMatch < Error; end
165
120
 
166
121
  end
122
+
@@ -1,61 +1,21 @@
1
- #--
2
- # Amazon Web Services EC2 Query API Ruby library
3
- #
4
- # Ruby Gem Name:: amazon-ec2
5
- # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
- # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
7
- # License:: Distributes under the same terms as Ruby
8
- # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
- #++
10
-
11
- # This allows us to access hash values as if they were methods
12
- # e.g. foo[:bar] can be accessed as foo.bar
13
-
14
- class Hash
15
- def method_missing(meth, *args, &block)
16
- if args.size == 0
17
- self[meth.to_s] || self[meth.to_sym]
18
- end
19
- end
20
- end
21
-
22
1
  module AWS
23
2
 
24
- # The make_request() and aws_error? methods, which are shared by all, will raise any
25
- # exceptions encountered along the way as it converses with EC2.
26
- #
27
- # Exception Handling: If for some reason an error occurrs when executing a method
28
- # (e.g. its arguments were incorrect, or it simply failed) then an exception will
29
- # be thrown. The exceptions are defined in exceptions.rb as individual classes and should
30
- # match the exceptions that Amazon has defined for EC2. If the exception raised cannot be
31
- # identified then a more generic exception class will be thrown.
32
- #
33
- # The implication of this is that you need to be prepared to handle any exceptions that
34
- # may be raised by this library in YOUR code with a 'rescue' clauses. It is up to you
35
- # how gracefully you want to handle these exceptions that are raised.
36
-
37
- begin
38
- require 'xmlsimple' unless defined? XmlSimple
39
- rescue Exception => e
40
- require 'xml-simple' unless defined? XmlSimple
41
- end
42
-
43
3
  class Response
44
4
 
5
+ # Parse the XML response from AWS
6
+ #
7
+ # @option options [String] :xml The XML response from AWS that we want to parse
8
+ # @option options [Hash] :parse_options Override the options for XmlSimple.
9
+ # @return [Hash] the input :xml converted to a custom Ruby Hash by XmlSimple.
45
10
  def self.parse(options = {})
46
11
  options = {
47
12
  :xml => "",
48
13
  :parse_options => { 'forcearray' => ['item', 'member'], 'suppressempty' => nil, 'keeproot' => false }
49
14
  }.merge(options)
50
-
51
- # NOTE: Parsing the response as a nested set of Response objects was extremely
52
- # memory intensive and appeared to leak (the memory was not freed on subsequent requests).
53
- # It was changed to return the raw XmlSimple response.
54
15
  response = XmlSimple.xml_in(options[:xml], options[:parse_options])
55
-
56
- return response
57
16
  end
58
17
 
59
18
  end # class Response
60
19
 
61
20
  end # module AWS
21
+
@@ -8,6 +8,9 @@
8
8
  # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
9
  #++
10
10
 
11
+ require 'rubygems'
12
+ gem 'test-unit'
13
+
11
14
  %w[ test/unit test/spec mocha ].each { |f|
12
15
  begin
13
16
  require f
@@ -17,3 +20,4 @@
17
20
  }
18
21
 
19
22
  require File.dirname(__FILE__) + '/../lib/AWS'
23
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grempe-amazon-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Rempe
@@ -78,6 +78,7 @@ extra_rdoc_files:
78
78
  - README_dev.rdoc
79
79
  files:
80
80
  - .gitignore
81
+ - .yardopts
81
82
  - ChangeLog
82
83
  - LICENSE
83
84
  - README.rdoc
@@ -131,7 +132,7 @@ files:
131
132
  - wsdl/2008-02-01.ec2.wsdl
132
133
  - wsdl/2008-05-05.ec2.wsdl
133
134
  - wsdl/2008-12-01.ec2.wsdl
134
- has_rdoc: true
135
+ has_rdoc: false
135
136
  homepage: http://github.com/grempe/amazon-ec2
136
137
  licenses:
137
138
  post_install_message:
@@ -160,7 +161,7 @@ requirements: []
160
161
  rubyforge_project: amazon-ec2
161
162
  rubygems_version: 1.3.5
162
163
  signing_key:
163
- specification_version: 2
164
+ specification_version: 3
164
165
  summary: Amazon EC2 Ruby Gem
165
166
  test_files:
166
167
  - test/test_EC2.rb