Module: Zcloudjp::Machine
- Defined in:
- lib/zcloudjp/machine.rb
Instance Method Summary collapse
-
#create(params = {}) ⇒ Object
POST /machines.json.
-
#delete(params = {}) ⇒ Object
(also: #destroy)
DELETE /machines/:id.json.
-
#index(params = {}) ⇒ Object
(also: #list)
GET /machines.json.
-
#metadata ⇒ Object
Create a Metadata object related to the specified machine.
-
#show(params = {}) ⇒ Object
(also: #find_by, #reload)
GET /machines/:id.json.
-
#start(params = {}) ⇒ Object
POST /machines/:id/start.json.
-
#stop(params = {}) ⇒ Object
POST /machines/:id/stop.json.
Instance Method Details
#create(params = {}) ⇒ Object
POST /machines.json
26 27 28 29 30 |
# File 'lib/zcloudjp/machine.rb', line 26 def create(params={}) self. = self..merge(body: params.to_json) response = Zcloudjp::Client.post("/machines", self.) update_attributes(response.parsed_response) end |
#delete(params = {}) ⇒ Object Also known as: destroy
DELETE /machines/:id.json
33 34 35 36 37 |
# File 'lib/zcloudjp/machine.rb', line 33 def delete(params={}) id = params.delete(:id) || self.id response = Zcloudjp::Client.delete("/machines/#{id}", self.) update_attributes(response.parsed_response) end |
#index(params = {}) ⇒ Object Also known as: list
GET /machines.json
7 8 9 10 11 12 13 |
# File 'lib/zcloudjp/machine.rb', line 7 def index(params={}) self. = self..merge(params[:query] || {}) response = Zcloudjp::Client.get("/machines", self.) response.parsed_response.map do |res| update_attributes(res).clone end end |
#metadata ⇒ Object
Create a Metadata object related to the specified machine
55 56 57 |
# File 'lib/zcloudjp/machine.rb', line 55 def Metadata.new(self) end |
#show(params = {}) ⇒ Object Also known as: find_by, reload
GET /machines/:id.json
17 18 19 20 21 |
# File 'lib/zcloudjp/machine.rb', line 17 def show(params={}) id = params.delete(:id) || self.id response = Zcloudjp::Client.get("/machines/#{id}", self.) update_attributes(response.parsed_response) end |