Parent

Class/Module Index [+]

Quicksearch

Fog::Compute::Joyent::Mock

Public Class Methods

data() click to toggle source
# File lib/fog/joyent/compute.rb, line 77
def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {}
  end
end
new(options = {}) click to toggle source
# File lib/fog/joyent/compute.rb, line 87
def initialize(options = {})
  @joyent_username = options[:joyent_username] || Fog.credentials[:joyent_username]
  @joyent_password = options[:joyent_password] || Fog.credentials[:joyent_password]
end

Public Instance Methods

create_key(params) click to toggle source

us-west-1.api.joyentcloud.com/docs#CreateKey

# File lib/fog/joyent/requests/compute/create_key.rb, line 8
def create_key(params)
  name = params[:name]
  key = params[:key]

  record = {
    "name" => name,
    "key" => key,
    "created" => Time.now.utc,
    "updated" => Time.now.utc
  }

  self.data[:keys][name] = record

  response = Excon::Response.new
  response.status = 201
  response.body = record
  response
end
data() click to toggle source
# File lib/fog/joyent/compute.rb, line 83
def data
  self.class.data
end
delete_key(keyname) click to toggle source
# File lib/fog/joyent/requests/compute/delete_key.rb, line 6
def delete_key(keyname)
  if self.data[:keys].delete(keyname)
    response = Excon::Response.new
    response.status = 204
    response
  else
    raise Excon::Errors::NotFound, "Not Found"
  end
end
get_dataset(id) click to toggle source
# File lib/fog/joyent/requests/compute/get_dataset.rb, line 6
def get_dataset(id)
  if ds = self.data[:datasets][id]
    res = Excon::Response.new
    res.status = 200
    res.body = ds
  else
    raise Excon::Errors::NotFound
  end
end
get_key(keyid) click to toggle source
# File lib/fog/joyent/requests/compute/get_key.rb, line 6
def get_key(keyid)
  if key = self.data[:keys][keyid]
    response = Excon::Response.new
    response.status = 200
    response.body = key
    response
  else
    raise Excon::Errors::NotFound
  end
end
get_machine(uuid) click to toggle source
# File lib/fog/joyent/requests/compute/get_machine.rb, line 6
def get_machine(uuid)
  if machine = self.data[:machines][uuid]
    res = Excon::Response.new
    res.status = 200
    res.body = machine
    res
  else
    raise Excon::Errors::NotFound, "Not Found"
  end
end
get_package(name) click to toggle source
# File lib/fog/joyent/requests/compute/get_package.rb, line 8
def get_package(name)
  if pkg = self.data[:packages][name]
    response = Excon::Response.new
    response.body = pkg
    response.status = 200
    response
  else
    raise Excon::Errors::NotFound
  end
end
list_datasets() click to toggle source
# File lib/fog/joyent/requests/compute/list_datasets.rb, line 6
def list_datasets
  res = Excon::Response.new
  res.status = 200
  res.body = self.data[:datasets].values
  res
end
list_keys() click to toggle source
# File lib/fog/joyent/requests/compute/list_keys.rb, line 5
def list_keys
  response = Excon::Response.new
  response.status = 200
  response.body = self.data[:keys].values
  response
end
list_machines(options={}) click to toggle source
# File lib/fog/joyent/requests/compute/list_machines.rb, line 6
def list_machines(options={})
  res = Excon::Response.new
  res.status = 200
  res.body = self.data[:machines].values
  res
end
list_packages() click to toggle source
# File lib/fog/joyent/requests/compute/list_packages.rb, line 6
def list_packages
  response = Excon::Response.new()
  response.status = 200
  response.body = self.data[:packages].values
  response
end
request(opts) click to toggle source
# File lib/fog/joyent/compute.rb, line 92
def request(opts)
  raise "Not Implemented"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.