lib/smartdc/api/machines.rb in smartdc-1.3.0 vs lib/smartdc/api/machines.rb in smartdc-2.0.0
- old
+ new
@@ -1,70 +1,36 @@
-require 'smartdc/api/machine/tags'
-require 'smartdc/api/machine/metadata'
-require 'smartdc/api/machine/snapshots'
+module Smartdc::Api
+ module Machines
+ def machines(params={})
+ get 'my/machines', params
+ end
-module Smartdc
- module Api
- class Machines
- attr_reader :request
+ def create_machine(body={})
+ post 'my/machines', body
+ end
- def initialize(options)
- @options = options
- @request = Smartdc::Request.new(options)
- end
+ def machine(id)
+ get 'my/machines/' + id.to_s
+ end
- def create(raw={})
- request.post('my/machines/', raw)
- end
-
- def read(id)
- raise ArgumentError unless id
- request.get('my/machines/' + id.to_s)
- end
+ def destroy_machine(id)
+ delete 'my/machines/' + id.to_s
+ end
- def all(query={})
- request.get('my/machines', query)
- end
+ def stop_machine(id)
+ post 'my/machines/' + id.to_s, {action: :stop}
+ end
- def destroy(id)
- raise ArgumentError unless id
- request.del('my/machines/' + id.to_s)
- end
+ def start_machine(id)
+ post 'my/machines/' + id.to_s, {action: :start}
+ end
- def stop(id)
- raise ArgumentError unless id
- request.post('my/machines/' + id.to_s, {'action'=>'stop'})
- end
+ def reboot_machine(id)
+ post 'my/machines/' + id.to_s, {action: :reboot}
+ end
- def start(id)
- raise ArgumentError unless id
- request.post('my/machines/' + id.to_s, {'action'=>'start'})
- end
-
- def reboot(id)
- raise ArgumentError unless id
- request.post('my/machines/' + id.to_s, {'action'=>'reboot'})
- end
-
- def resize(id, query={})
- raise ArgumentError unless id
- query['action'] = 'resize'
- request.post('my/machines/' + id.to_s, query)
- end
-
- def tags(id)
- raise ArgumentError unless id
- Smartdc::Api::Machine::Tags.new(id, @options)
- end
-
- def metadata(id)
- raise ArgumentError unless id
- Smartdc::Api::Machine::Metadata.new(id, @options)
- end
-
- def snapshots(id)
- raise ArgumentError unless id
- Smartdc::Api::Machine::Snapshots.new(id, @options)
- end
+ def resize_machine(id, params={})
+ params[:action] = 'resize'
+ post 'my/machines/' + id.to_s, params
end
end
end