Class: Elasticity::AwsRequest
- Inherits:
-
Object
- Object
- Elasticity::AwsRequest
- Defined in:
- lib/elasticity/aws_request.rb
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(access = nil, secret = nil, options = {}) ⇒ AwsRequest
constructor
Supported values for options: :region - AWS region (e.g. us-west-1) :secure - true or false, default true.
- #submit(ruby_params) ⇒ Object
Constructor Details
#initialize(access = nil, secret = nil, options = {}) ⇒ AwsRequest
Supported values for options:
:region - AWS region (e.g. us-west-1)
:secure - true or false, default true.
16 17 18 19 20 21 |
# File 'lib/elasticity/aws_request.rb', line 16 def initialize(access=nil, secret=nil, ={}) @access_key = get_access_key(access) @secret_key = get_secret_key(secret) @host = "elasticmapreduce.#{{:region => 'us-east-1'}.merge(options)[:region]}.amazonaws.com" @protocol = {:secure => true}.merge()[:secure] ? 'https' : 'http' end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
8 9 10 |
# File 'lib/elasticity/aws_request.rb', line 8 def access_key @access_key end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/elasticity/aws_request.rb', line 10 def host @host end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
11 12 13 |
# File 'lib/elasticity/aws_request.rb', line 11 def protocol @protocol end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
9 10 11 |
# File 'lib/elasticity/aws_request.rb', line 9 def secret_key @secret_key end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/elasticity/aws_request.rb', line 33 def ==(other) return false unless other.is_a? AwsRequest return false unless @access_key == other.access_key return false unless @secret_key == other.secret_key return false unless @host == other.host return false unless @protocol == other.protocol true end |
#submit(ruby_params) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/elasticity/aws_request.rb', line 23 def submit(ruby_params) aws_params = AwsRequest.convert_ruby_to_aws(ruby_params) signed_params = sign_params(aws_params) begin RestClient.post("#@protocol://#@host", signed_params, :content_type => 'application/x-www-form-urlencoded; charset=utf-8') rescue RestClient::BadRequest => e raise ArgumentError, AwsRequest.parse_error_response(e.http_body) end end |