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
Autoscaling::Base, Cloudwatch::Base, EC2::Base, ELB::Base, RDS::Base
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
-
#extract_user_data(options = {}) ⇒ Object
If :user_data is passed in then URL escape and Base64 encode it as needed.
-
#initialize(options = {}) ⇒ Object
constructor
The object.
Constructor Details
#initialize(options = {}) ⇒ Object
Returns the object.
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/AWS.rb', line 123 def initialize( = {} ) = { :access_key_id => "", :secret_access_key => "", :use_ssl => true, :server => default_host, :path => "/", :proxy_server => nil }.merge() @server = [:server] @proxy_server = [:proxy_server] @use_ssl = [:use_ssl] @path = [:path] 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.
115 116 117 |
# File 'lib/AWS.rb', line 115 def port @port end |
#proxy_server ⇒ Object (readonly)
Returns the value of attribute proxy_server.
115 116 117 |
# File 'lib/AWS.rb', line 115 def proxy_server @proxy_server end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
115 116 117 |
# File 'lib/AWS.rb', line 115 def server @server end |
#use_ssl ⇒ Object (readonly)
Returns the value of attribute use_ssl.
115 116 117 |
# File 'lib/AWS.rb', line 115 def use_ssl @use_ssl end |
Instance Method Details
#extract_user_data(options = {}) ⇒ Object
If :user_data is passed in then URL escape and Base64 encode it as needed. Need for URL Escape + Base64 encoding is determined by :base64_encoded param.
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/AWS.rb', line 176 def extract_user_data( = {} ) return unless [:user_data] if [:user_data] if [:base64_encoded] Base64.encode64([:user_data]).gsub(/\n/, "").strip() else [:user_data] end end end |