Class: FogClient
- Inherits:
-
Object
- Object
- FogClient
- Defined in:
- lib/fog-pry/fog_client.rb
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
readonly
Returns the value of attribute access_key_id.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#secret_access_key ⇒ Object
readonly
Returns the value of attribute secret_access_key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #compute ⇒ Object
- #credentials(op) ⇒ Object
- #dns ⇒ Object
- #elb ⇒ Object
- #endpoint_params(url) ⇒ Object
- #iam ⇒ Object
-
#initialize(type, config) ⇒ FogClient
constructor
A new instance of FogClient.
- #op_endpoint(op) ⇒ Object
- #uri_params(url) ⇒ Object
Constructor Details
#initialize(type, config) ⇒ FogClient
Returns a new instance of FogClient.
6 7 8 9 10 11 |
# File 'lib/fog-pry/fog_client.rb', line 6 def initialize(type, config) @type, @config = type, config creds = config.credentials @secret_access_key, @access_key_id = creds.secret_access_key, creds.access_key_id end |
Instance Attribute Details
#access_key_id ⇒ Object (readonly)
Returns the value of attribute access_key_id.
4 5 6 |
# File 'lib/fog-pry/fog_client.rb', line 4 def access_key_id @access_key_id end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/fog-pry/fog_client.rb', line 4 def config @config end |
#secret_access_key ⇒ Object (readonly)
Returns the value of attribute secret_access_key.
4 5 6 |
# File 'lib/fog-pry/fog_client.rb', line 4 def secret_access_key @secret_access_key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/fog-pry/fog_client.rb', line 4 def type @type end |
Instance Method Details
#compute ⇒ Object
63 64 65 |
# File 'lib/fog-pry/fog_client.rb', line 63 def compute Fog::Compute.new(credentials(:compute)) end |
#credentials(op) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fog-pry/fog_client.rb', line 13 def credentials(op) if op == :elb || op == :iam return { :aws_secret_access_key=>secret_access_key, :aws_access_key_id=>access_key_id, :connection_options => { :ssl_verify_peer => false } }.merge(uri_params(op_endpoint(op))) end endpoint = op_endpoint(op) { :provider=>'AWS', :aws_secret_access_key=>secret_access_key, :aws_access_key_id=>access_key_id, :connection_options=>{:ssl_verify_peer=>false}.merge(uri_params(endpoint)) }.merge(endpoint_params(endpoint)) end |
#dns ⇒ Object
59 60 61 |
# File 'lib/fog-pry/fog_client.rb', line 59 def dns Fog::DNS.new(credentials(:dns)) end |
#elb ⇒ Object
71 72 73 |
# File 'lib/fog-pry/fog_client.rb', line 71 def elb Fog::AWS::ELB.new(credentials(:elb)) end |
#endpoint_params(url) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/fog-pry/fog_client.rb', line 38 def endpoint_params(url) if url {:endpoint=>url} else {} end end |
#iam ⇒ Object
67 68 69 |
# File 'lib/fog-pry/fog_client.rb', line 67 def iam Fog::AWS::IAM.new(credentials(:iam)) end |
#op_endpoint(op) ⇒ Object
34 35 36 |
# File 'lib/fog-pry/fog_client.rb', line 34 def op_endpoint(op) config.respond_to?(op) ? config.send(op) : nil end |
#uri_params(url) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fog-pry/fog_client.rb', line 46 def uri_params(url) if url uri = URI.parse url {:scheme => uri.scheme, :host => uri.host, :port => uri.port, :path => uri.path, } else {} end end |