Class: AceClient::Base
- Inherits:
-
Object
- Object
- AceClient::Base
- Includes:
- HTTParty
- Defined in:
- lib/ace-client/base.rb
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#http_proxy ⇒ Object
Returns the value of attribute http_proxy.
-
#last_response ⇒ Object
Returns the value of attribute last_response.
-
#last_response_time ⇒ Object
Returns the value of attribute last_response_time.
-
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #endpoint_url ⇒ Object
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #record_response ⇒ Object
- #set_http_proxy ⇒ Object
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ace-client/base.rb', line 19 def initialize() @access_key_id = [:access_key_id] || ENV['ACE_ACCESS_KEY_ID'] @secret_access_key = [:secret_access_key] || ENV['ACE_SECRET_ACCESS_KEY'] @endpoint = [:endpoint] || ENV['ACE_ENDPOINT'] @http_proxy = [:http_proxy] || ENV['HTTP_PROXY'] @http_method = [:http_method] || :post @access_key_id_key = [:access_key_id_key] || ENV['ACE_ACCESS_KEY_ID_KEY'] || 'AWSAccessKeyId' @host = [:host] if @timeout = [:timeout] || ENV['ACE_TIMEOUT'] self.class.default_timeout @timeout end if .key?(:use_ssl) @use_ssl = [:use_ssl] elsif ENV['ACE_USE_SSL'] if ENV['ACE_USE_SSL'] == 'false' @use_ssl = false else @use_ssl = true end else @use_ssl = true end if .key?(:host_with_port) @host_with_port = [:host_with_port] elsif ENV['ACE_HOST_WITH_PORT'] if ENV['ACE_HOST_WITH_PORT'] == 'false' @host_with_port = false else @host_with_port = true end else @host_with_port = false end if [:debug_output] self.class.debug_output([:debug_output]) elsif %w(STDOUT STDERR).include?(ENV['ACE_DEBUG_OUTPUT']) if ENV['ACE_DEBUG_OUTPUT'] == 'STDOUT' self.class.debug_output($stdout) else self.class.debug_output($stderr) end end self.class.format ([:response_format] || ENV['ACE_RESPONSE_FORMAT'] || 'xml').to_sym @version = [:version] @path = [:path] || ENV['ACE_PATH'] || '/' @user_agent = [:user_agent] @headers = [:headers] || {} set_http_proxy end |
Instance Attribute Details
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
9 10 11 |
# File 'lib/ace-client/base.rb', line 9 def access_key_id @access_key_id end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
11 12 13 |
# File 'lib/ace-client/base.rb', line 11 def endpoint @endpoint end |
#http_method ⇒ Object
Returns the value of attribute http_method.
13 14 15 |
# File 'lib/ace-client/base.rb', line 13 def http_method @http_method end |
#http_proxy ⇒ Object
Returns the value of attribute http_proxy.
12 13 14 |
# File 'lib/ace-client/base.rb', line 12 def http_proxy @http_proxy end |
#last_response ⇒ Object
Returns the value of attribute last_response.
15 16 17 |
# File 'lib/ace-client/base.rb', line 15 def last_response @last_response end |
#last_response_time ⇒ Object
Returns the value of attribute last_response_time.
16 17 18 |
# File 'lib/ace-client/base.rb', line 16 def last_response_time @last_response_time end |
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
10 11 12 |
# File 'lib/ace-client/base.rb', line 10 def secret_access_key @secret_access_key end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
14 15 16 |
# File 'lib/ace-client/base.rb', line 14 def use_ssl @use_ssl end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
17 18 19 |
# File 'lib/ace-client/base.rb', line 17 def user_agent @user_agent end |
Instance Method Details
#endpoint_url ⇒ Object
83 84 85 86 |
# File 'lib/ace-client/base.rb', line 83 def endpoint_url protocol = use_ssl ? 'https' : 'http' protocol + '://' + endpoint end |
#record_response ⇒ Object
76 77 78 79 80 81 |
# File 'lib/ace-client/base.rb', line 76 def record_response start_time = Time.now @last_response = yield @last_response_time = Time.now - start_time @last_response end |
#set_http_proxy ⇒ Object
69 70 71 72 73 74 |
# File 'lib/ace-client/base.rb', line 69 def set_http_proxy if @http_proxy uri = URI.parse(@http_proxy) self.class.http_proxy(uri.host, uri.port) end end |