Class: Deltacloud::EC2::QueryParser
- Inherits:
-
Object
- Object
- Deltacloud::EC2::QueryParser
- Defined in:
- lib/ec2/query_parser.rb
Defined Under Namespace
Classes: InvalidAction
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#authentication ⇒ Object
readonly
Returns the value of attribute authentication.
-
#expiration ⇒ Object
readonly
Returns the value of attribute expiration.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request_id, params = {}) ⇒ QueryParser
constructor
A new instance of QueryParser.
- #valid_action? ⇒ Boolean
- #valid_actions ⇒ Object
Constructor Details
#initialize(request_id, params = {}) ⇒ QueryParser
Returns a new instance of QueryParser.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/ec2/query_parser.rb', line 141 def initialize(request_id, params={}) @request_id = request_id @action = (params.delete('Action') || 'Unknown').underscore.intern @version = params.delete('Version') @authentication = { :security_token => params.delete('SecurityToken'), :access_key_id => params.delete('AWSAccessKeyId'), :signature => { :version => params.delete('SignatureVersion'), :value => params.delete('Signature'), :method => params.delete('SignatureMethod'), :timestamp => params.delete('Timestamp') } } @expiration = params.delete('Expires') @parameters = params end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
134 135 136 |
# File 'lib/ec2/query_parser.rb', line 134 def action @action end |
#authentication ⇒ Object (readonly)
Returns the value of attribute authentication.
138 139 140 |
# File 'lib/ec2/query_parser.rb', line 138 def authentication @authentication end |
#expiration ⇒ Object (readonly)
Returns the value of attribute expiration.
137 138 139 |
# File 'lib/ec2/query_parser.rb', line 137 def expiration @expiration end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
135 136 137 |
# File 'lib/ec2/query_parser.rb', line 135 def parameters @parameters end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
139 140 141 |
# File 'lib/ec2/query_parser.rb', line 139 def request_id @request_id end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
136 137 138 |
# File 'lib/ec2/query_parser.rb', line 136 def version @version end |
Class Method Details
.parse(params, request_id) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/ec2/query_parser.rb', line 125 def self.parse(params, request_id) parser = new(request_id, params) unless parser.valid_action? raise InvalidAction.new('Invalid action (%s)' % parser.action) else ActionHandler.new(parser) end end |
Instance Method Details
#valid_action? ⇒ Boolean
163 164 165 166 167 |
# File 'lib/ec2/query_parser.rb', line 163 def valid_action? return false if @action == :unknown return false unless valid_actions.include?(@action) true end |
#valid_actions ⇒ Object
159 160 161 |
# File 'lib/ec2/query_parser.rb', line 159 def valid_actions ActionHandler::mappings.keys end |