Class: Fog::GoGrid::Real
- Inherits:
-
Object
- Object
- Fog::GoGrid::Real
- Includes:
- Collections
- Defined in:
- lib/fog/go_grid.rb,
lib/fog/go_grid/requests/grid_ip_list.rb,
lib/fog/go_grid/requests/grid_image_list.rb,
lib/fog/go_grid/requests/grid_server_list.rb,
lib/fog/go_grid/requests/common_lookup_list.rb,
lib/fog/go_grid/requests/grid_loadbalancer_list.rb
Instance Method Summary collapse
-
#common_lookup_list(lookup, options = {}) ⇒ Object
List options and lookups.
-
#grid_image_list(options = {}) ⇒ Object
List images.
-
#grid_ip_list(options = {}) ⇒ Object
List ips.
-
#grid_loadbalancer_list(options = {}) ⇒ Object
List load balancers.
-
#grid_server_list(options = {}) ⇒ Object
List servers.
-
#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.
43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/go_grid.rb', line 43 def initialize(={}) @go_grid_api_key = [:go_grid_api_key] @go_grid_shared_secret = [:go_grid_shared_secret] @host = [:host] || "api.gogrid.com" @path = [:path] || "/api" @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", [:persistent]) end |
Instance Method Details
#common_lookup_list(lookup, options = {}) ⇒ Object
List options and lookups
Parameters
-
‘lookup’<~String> - the lookup to be listed
-
options<~Hash>:
-
‘sort’<~String> - column to sort result by in [‘description’, ‘id’, ‘name’]
-
‘asc’<~String> - order to sort in [‘true’,‘false’]
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
17 18 19 20 21 22 23 24 |
# File 'lib/fog/go_grid/requests/common_lookup_list.rb', line 17 def common_lookup_list(lookup, ={}) request( :expects => 200, :method => 'GET', :path => 'common/lookup/list', :query => {'lookup' => lookup}.merge!() ) end |
#grid_image_list(options = {}) ⇒ Object
List images
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘isPublic’<~String> - If true only returns public images, in [‘false’, ‘true’]
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
‘state’<~String> - state to limit results to, in [‘Saving’, ‘Available’]
-
‘type’<~String> - image type to limit results to
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
20 21 22 23 24 25 26 27 |
# File 'lib/fog/go_grid/requests/grid_image_list.rb', line 20 def grid_image_list(={}) request( :expects => 200, :method => 'GET', :path => 'grid/image/list', :query => ) end |
#grid_ip_list(options = {}) ⇒ Object
List ips
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘ip.state’<~String> - state to limit results to in ip.state
-
‘ip.type’<~String> - type to limit results to in ip.type
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
19 20 21 22 23 24 25 26 |
# File 'lib/fog/go_grid/requests/grid_ip_list.rb', line 19 def grid_ip_list(={}) request( :expects => 200, :method => 'GET', :path => 'grid/ip/list', :query => ) end |
#grid_loadbalancer_list(options = {}) ⇒ Object
List load balancers
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
17 18 19 20 21 22 23 24 |
# File 'lib/fog/go_grid/requests/grid_loadbalancer_list.rb', line 17 def grid_loadbalancer_list(={}) request( :expects => 200, :method => 'GET', :path => 'grid/loadbalancer/list', :query => ) end |
#grid_server_list(options = {}) ⇒ Object
List servers
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘isSandbox’<~String> - If true only returns Image Sandbox servers, in [‘false’, ‘true’]
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
‘server.type’<~String> - server type to limit results to
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
19 20 21 22 23 24 25 26 |
# File 'lib/fog/go_grid/requests/grid_server_list.rb', line 19 def grid_server_list(={}) request( :expects => 200, :method => 'GET', :path => 'grid/server/list', :query => ) end |
#reload ⇒ Object
53 54 55 |
# File 'lib/fog/go_grid.rb', line 53 def reload @connection.reset end |
#request(params) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/fog/go_grid.rb', line 57 def request(params) params[:query] ||= {} params[:query].merge!({ 'api_key' => @go_grid_api_key, 'format' => 'json', 'sig' => Digest::MD5.hexdigest("#{@go_grid_api_key}#{@go_grid_shared_secret}#{Time.now.to_i}"), 'v' => '1.4' }) begin response = @connection.request( params.merge!(:path => "#{@path}/#{params[:path]}") ) rescue Excon::Errors::Error => error raise case error when Excon::Errors::NotFound Fog::Go_Grid::NotFound.slurp(error) else error end end unless response.body.empty? response.body = JSON.parse(response.body) end response end |