module CloudServers

Cloud Servers API

Connects Ruby Applications to Rackspace's Cloud Servers service

By H. Wade Minter <minter@lunenburg.org>, Mike Mayo <rackspace at mike.mayo.com>, and Dan Prince <rackspace at dan.prince.com>

See COPYING for license information. Copyright (c) 2009, Rackspace US, Inc.


Documentation & Examples

To begin reviewing the available methods and examples, peruse the README.rodc file, or begin by looking at documentation for the CloudServers::Connection class.

The CloudServers class is the base class. Not much of note aside from housekeeping happens here. To create a new CloudServers connection, use the CloudServers::Connection.new(:username => USERNAME, :api_key => API_KEY)

Constants

AUTH_UK
AUTH_USA
MAX_PERSONALITY_FILE_SIZE
MAX_PERSONALITY_ITEMS

Constants that set limits on server creation

MAX_PERSONALITY_METADATA_ITEMS
MAX_SERVER_PATH_LENGTH
VERSION

Public Class Methods

paginate(options = {}) click to toggle source
# File lib/cloudservers.rb, line 86
def self.paginate(options = {})
  path_args = []
  path_args.push(URI.encode("limit=#{options[:limit]}")) if options[:limit]
  path_args.push(URI.encode("offset=#{options[:offset]}")) if options[:offset]
  path_args.join("&")
end
symbolize_keys(obj) click to toggle source

Helper method to recursively symbolize hash keys.

# File lib/cloudservers.rb, line 52
def self.symbolize_keys(obj)
  case obj
  when Array
    obj.inject([]){|res, val|
      res << case val
      when Hash, Array
        symbolize_keys(val)
      else
        val
      end
      res
    }
  when Hash
    obj.inject({}){|res, (key, val)|
      nkey = case key
      when String
        key.to_sym
      else
        key
      end
      nval = case val
      when Hash, Array
        symbolize_keys(val)
      else
        val
      end
      res[nkey] = nval
      res
    }
  else
    obj
  end
end