Class: AWS::Base
- Inherits:
-
Object
- Object
- AWS::Base
- Defined in:
- lib/AWS.rb
Overview
This class provides all the methods for using the EC2 or ELB service including the handling of header signing and other security concerns. This class uses the Net::HTTP library to interface with the AWS Query API interface. You should not instantiate this directly, instead you should setup an instance of ‘AWS::EC2::Base’ or ‘AWS::ELB::Base’.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#proxy_server ⇒ Object
readonly
Returns the value of attribute proxy_server.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#use_ssl ⇒ Object
readonly
Returns the value of attribute use_ssl.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Object
constructor
The object.
Constructor Details
#initialize(options = {}) ⇒ Object
Returns the object.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/AWS.rb', line 102 def initialize( = {} ) = { :access_key_id => "", :secret_access_key => "", :use_ssl => true, :server => default_host, :proxy_server => nil }.merge() @server = [:server] @proxy_server = [:proxy_server] @use_ssl = [:use_ssl] raise ArgumentError, "No :access_key_id provided" if [:access_key_id].nil? || [:access_key_id].empty? raise ArgumentError, "No :secret_access_key provided" if [:secret_access_key].nil? || [:secret_access_key].empty? raise ArgumentError, "No :use_ssl value provided" if [:use_ssl].nil? raise ArgumentError, "Invalid :use_ssl value provided, only 'true' or 'false' allowed" unless [:use_ssl] == true || [:use_ssl] == false raise ArgumentError, "No :server provided" if [:server].nil? || [:server].empty? if [:port] # user-specified port @port = [:port] elsif @use_ssl # https @port = 443 else # http @port = 80 end @access_key_id = [:access_key_id] @secret_access_key = [:secret_access_key] # Use proxy server if defined # Based on patch by Mathias Dalheimer. 20070217 proxy = @proxy_server ? URI.parse(@proxy_server) : OpenStruct.new @http = Net::HTTP::Proxy( proxy.host, proxy.port, proxy.user, proxy.password).new([:server], @port) @http.use_ssl = @use_ssl # Don't verify the SSL certificates. Avoids SSL Cert warning in log on every GET. @http.verify_mode = OpenSSL::SSL::VERIFY_NONE end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
94 95 96 |
# File 'lib/AWS.rb', line 94 def port @port end |
#proxy_server ⇒ Object (readonly)
Returns the value of attribute proxy_server.
94 95 96 |
# File 'lib/AWS.rb', line 94 def proxy_server @proxy_server end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
94 95 96 |
# File 'lib/AWS.rb', line 94 def server @server end |
#use_ssl ⇒ Object (readonly)
Returns the value of attribute use_ssl.
94 95 96 |
# File 'lib/AWS.rb', line 94 def use_ssl @use_ssl end |