Module: Zcloudjp::Machine

Defined in:
lib/zcloudjp/machine.rb

Instance Method Summary collapse

Instance Method Details

#create(params = {}) ⇒ Object

POST /machines.json



25
26
27
28
29
# File 'lib/zcloudjp/machine.rb', line 25

def create(params={})
  self.request_options = self.request_options.merge(body: params.to_json)
  response = Zcloudjp::Client.post("/machines", self.request_options)
  update_attributes(response.parsed_response)
end

#delete(params = {}) ⇒ Object

DELETE /machines/:id.json



32
33
34
35
36
# File 'lib/zcloudjp/machine.rb', line 32

def delete(params={})
  id = params.delete(:id) || self.id
  response = Zcloudjp::Client.delete("/machines/#{id}", self.request_options)
  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.request_options = self.request_options.merge(params[:query] || {})
  response = Zcloudjp::Client.get("/machines", self.request_options)
  response.parsed_response.map do |res|
    update_attributes(res).clone
  end
end

#metadataObject

Create a Metadata object related to the specified machine



53
54
55
# File 'lib/zcloudjp/machine.rb', line 53

def 
  .new(self)
end

#show(params = {}) ⇒ Object Also known as: find_by

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.request_options)
  update_attributes(response.parsed_response)
end

#start(params = {}) ⇒ Object

POST /machines/:id/start.json



39
40
41
42
43
# File 'lib/zcloudjp/machine.rb', line 39

def start(params={})
  id = params.delete(:id) || self.id
  response = Zcloudjp::Client.post("/machines/#{id}/start", self.request_options)
  update_attributes(response.parsed_response)
end

#stop(params = {}) ⇒ Object

POST /machines/:id/stop.json



46
47
48
49
50
# File 'lib/zcloudjp/machine.rb', line 46

def stop(params={})
  id = params.delete(:id) || self.id
  response = Zcloudjp::Client.post("/machines/#{id}/stop", self.request_options)
  update_attributes(response.parsed_response)
end