Class: Fog::Linode::Real
- Inherits:
-
Object
- Object
- Fog::Linode::Real
- Includes:
- Collections
- Defined in:
- lib/fog/linode.rb,
lib/fog/linode/requests/avail_kernels.rb,
lib/fog/linode/requests/avail_datacenters.rb,
lib/fog/linode/requests/avail_linodeplans.rb,
lib/fog/linode/requests/avail_distributions.rb
Instance Method Summary collapse
-
#avail_datacenters ⇒ Object
Get available data centers.
-
#avail_distributions(options = {}) ⇒ Object
Get available distributions.
-
#avail_kernels(options = {}) ⇒ Object
Get available kernels.
-
#avail_linodeplans ⇒ Object
Get available plans.
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #reload ⇒ Object
- #request(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
40 41 42 43 44 45 46 |
# File 'lib/fog/linode.rb', line 40 def initialize(={}) @linode_api_key = [:linode_api_key] @host = [:host] || "api.linode.com" @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", [:persistent]) end |
Instance Method Details
#avail_datacenters ⇒ Object
Get available data centers
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
11 12 13 14 15 16 17 |
# File 'lib/fog/linode/requests/avail_datacenters.rb', line 11 def avail_datacenters request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.datacenters' } ) end |
#avail_distributions(options = {}) ⇒ Object
Get available distributions
Parameters
-
options<~Hash>:
-
distributionId<~Integer>: id to limit results to
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
15 16 17 18 19 20 21 |
# File 'lib/fog/linode/requests/avail_distributions.rb', line 15 def avail_distributions(={}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.distributions' }.merge!() ) end |
#avail_kernels(options = {}) ⇒ Object
Get available kernels
Parameters
-
options<~Hash>:
-
kernelId<~Integer>: id to limit results to
-
isXen<~Integer>: if 1 limits results to only zen
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
16 17 18 19 20 21 22 |
# File 'lib/fog/linode/requests/avail_kernels.rb', line 16 def avail_kernels(={}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.kernels' }.merge!() ) end |
#avail_linodeplans ⇒ Object
Get available plans
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
11 12 13 14 15 16 17 |
# File 'lib/fog/linode/requests/avail_linodeplans.rb', line 11 def avail_linodeplans request( :expects => 200, :method => 'GET', :query => { :api_action => 'avail.linodeplans' } ) end |
#reload ⇒ Object
48 49 50 |
# File 'lib/fog/linode.rb', line 48 def reload @connection.reset end |
#request(params) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fog/linode.rb', line 52 def request(params) params[:query] ||= {} params[:query].merge!(:api_key => @linode_api_key) begin response = @connection.request(params.merge!({:host => @host})) rescue Excon::Errors::Error => error raise case error when Excon::Errors::NotFound Fog::Linode::NotFound.slurp(error) else error end end unless response.body.empty? response.body = JSON.parse(response.body) end response end |