Class: Elasticity::AwsSession
- Inherits:
-
Object
- Object
- Elasticity::AwsSession
- Defined in:
- lib/elasticity/aws_session.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(options = {}) ⇒ AwsSession
constructor
Supported values for options: :region - AWS region (e.g. us-west-1) :secure - true or false, default true.
- #submit(ruby_service_hash) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ AwsSession
Supported values for options:
:region - AWS region (e.g. us-west-1)
:secure - true or false, default true.
:timeout - the timeout, in seconds, when making a request to EMR, default 60.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/elasticity/aws_session.rb', line 17 def initialize(={}) # There is a cryptic error if this isn't set if .has_key?(:region) && [:region] == nil raise MissingRegionError, 'A valid :region is required to connect to EMR' end [:region] = 'us-east-1' unless [:region] @region = [:region] @host = "elasticmapreduce.#@region.amazonaws.com" [:timeout] = 60 unless [:timeout] @timeout = [:timeout] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/elasticity/aws_session.rb', line 9 def host @host end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
10 11 12 |
# File 'lib/elasticity/aws_session.rb', line 10 def region @region end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
11 12 13 |
# File 'lib/elasticity/aws_session.rb', line 11 def timeout @timeout end |
Instance Method Details
#==(other) ⇒ Object
48 49 50 51 52 |
# File 'lib/elasticity/aws_session.rb', line 48 def ==(other) return false unless other.is_a? AwsSession return false unless @host == other.host true end |
#submit(ruby_service_hash) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/elasticity/aws_session.rb', line 31 def submit(ruby_service_hash) aws_request = AwsRequestV4.new(self, ruby_service_hash) begin RestClient::Request.execute( :method => :post, :url => aws_request.url, :payload => aws_request.payload, :headers => aws_request.headers, :timeout => @timeout ) rescue RestClient::BadRequest => e type, = AwsSession.parse_error_response(e.http_body) raise ThrottlingException, if type == 'ThrottlingException' raise ArgumentError, end end |