Class: Fog::Compute::Joyent::Mock
- Inherits:
-
Object
- Object
- Fog::Compute::Joyent::Mock
- Defined in:
- lib/rackspace-fog/joyent/compute.rb,
lib/rackspace-fog/joyent/requests/compute/get_key.rb,
lib/rackspace-fog/joyent/requests/compute/list_keys.rb,
lib/rackspace-fog/joyent/requests/compute/create_key.rb,
lib/rackspace-fog/joyent/requests/compute/delete_key.rb,
lib/rackspace-fog/joyent/requests/compute/get_dataset.rb,
lib/rackspace-fog/joyent/requests/compute/get_machine.rb,
lib/rackspace-fog/joyent/requests/compute/get_package.rb,
lib/rackspace-fog/joyent/requests/compute/list_datasets.rb,
lib/rackspace-fog/joyent/requests/compute/list_machines.rb,
lib/rackspace-fog/joyent/requests/compute/list_packages.rb,
lib/rackspace-fog/joyent/requests/compute/list_machine_tags.rb,
lib/rackspace-fog/joyent/requests/compute/delete_machine_snapshot.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_key(params) ⇒ Object
- #data ⇒ Object
- #delete_key(keyname) ⇒ Object
- #get_dataset(id) ⇒ Object
- #get_key(keyid) ⇒ Object
- #get_machine(uuid) ⇒ Object
- #get_package(name) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_datasets ⇒ Object
- #list_keys ⇒ Object
- #list_machines(options = {}) ⇒ Object
- #list_packages ⇒ Object
- #request(opts) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
87 88 89 90 |
# File 'lib/rackspace-fog/joyent/compute.rb', line 87 def initialize( = {}) @joyent_username = [:joyent_username] || Fog.credentials[:joyent_username] @joyent_password = [:joyent_password] || Fog.credentials[:joyent_password] end |
Class Method Details
.data ⇒ Object
77 78 79 80 81 |
# File 'lib/rackspace-fog/joyent/compute.rb', line 77 def self.data @data ||= Hash.new do |hash, key| hash[key] = {} end end |
Instance Method Details
#create_key(params) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rackspace-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 ⇒ Object
83 84 85 |
# File 'lib/rackspace-fog/joyent/compute.rb', line 83 def data self.class.data end |
#delete_key(keyname) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/rackspace-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) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/rackspace-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) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rackspace-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) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rackspace-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) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rackspace-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 ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rackspace-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 ⇒ Object
5 6 7 8 9 10 |
# File 'lib/rackspace-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 = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rackspace-fog/joyent/requests/compute/list_machines.rb', line 6 def list_machines(={}) res = Excon::Response.new res.status = 200 res.body = self.data[:machines].values res end |
#list_packages ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rackspace-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) ⇒ Object
92 93 94 |
# File 'lib/rackspace-fog/joyent/compute.rb', line 92 def request(opts) raise "Not Implemented" end |