module RightScale::Api
Constants
- AWS_CLOUDS
Every supported AWS cloud must be hardcoded here. FIXME: Once this list exceeds 10 entries, must also update cloud_id logic elsewhere!
- BASE_COOKIE_REFRESH
- DATETIME_FMT
TODO: move this to
McAuditEntry
- GATEWAY_COOKIE_REFRESH
Refresh cookie by logging in again
Public Class Methods
api0_1?()
click to toggle source
Checks for API 0.1 access Requires an account with internal API access on a legacy cluster
# File lib/rest_connection/rightscale/rightscale_api_base.rb, line 100 def self.api0_1? if class_variable_defined?("@@api0_1") return @@api0_1 unless @@api0_1.nil? end if RestConnection::Connection.new.settings[:legacy_shard] begin Ec2SshKeyInternal.find_all @@api0_1 = true rescue RestConnection::Errors::Forbidden @@api0_1 = false rescue RestConnection::Errors::UnprocessableEntity @@api0_1 = false end else @@api0_1 = false end end
api1_0?()
click to toggle source
Checks for API 1.0 access Should always succeed
# File lib/rest_connection/rightscale/rightscale_api_base.rb, line 121 def self.api1_0? if class_variable_defined?("@@api1_0") return @@api1_0 unless @@api1_0.nil? end Ec2SecurityGroup.find_all @@api1_0 = true rescue RestConnection::Errors::Forbidden @@api1_0 = false end
api1_5?()
click to toggle source
Check for API 1.5 access Should always succeed
# File lib/rest_connection/rightscale/rightscale_api_base.rb, line 133 def self.api1_5? if class_variable_defined?("@@api1_5") return @@api1_5 unless @@api1_5.nil? end Cloud.find_all @@api1_5 = true rescue RestConnection::Errors::Forbidden @@api1_5 = false end
update_connection_settings(*settings)
click to toggle source
Pass no arguments to reset to the default configuration, pass a hash to update the settings for all API versions
# File lib/rest_connection/rightscale/rightscale_api_base.rb, line 78 def self.update_connection_settings(*settings) if settings.size > 1 raise ArgumentError.new("wrong number of arguments (#{settings.size} for 1)") end konstants = constants.map { |c| const_get(c) } konstants.reject! { |c| !(Module === c) } konstants.reject! { |c| !(c.instance_methods.include?("connection")) } konstants.each do |c| c.instance_exec(settings) do |opts| class_variable_set("@@connection", RestConnection::Connection.new(*opts)) end end @@api0_1, @@api1_0, @@api1_5 = nil, nil, nil true end