Module: Zcloudjp::Machine

Defined in:
lib/zcloudjp/machine.rb

Instance Method Summary collapse

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.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 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.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



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

#start(params = {}) ⇒ Object

POST /machines/:id/start.json



41
42
43
44
45
# File 'lib/zcloudjp/machine.rb', line 41

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



48
49
50
51
52
# File 'lib/zcloudjp/machine.rb', line 48

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