Class: Ey::Core::Client::Slots

Inherits:
Ey::Core::Collection show all
Defined in:
lib/vendor/core/ey-core/collections/slots.rb

Instance Method Summary collapse

Methods inherited from Ey::Core::Collection

#==, #all, #collection_request, #collection_root, #each_entry, #each_page, #first, #get, #get!, #last_page, #load, #model_request, #model_root, #new_page, #next_page, #one, #page_parameters, #perform_get, #previous_page

Instance Method Details

#create(options = {}) ⇒ Object



24
25
26
27
28
29
# File 'lib/vendor/core/ey-core/collections/slots.rb', line 24

def create(options={})
  create!(options)
  self
rescue Ey::Core::Response::Error
  false
end

#create!(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vendor/core/ey-core/collections/slots.rb', line 10

def create!(options={})
  response = connection.create_slots(
    "url"     => self.url,
    "cluster" => options[:cluster_id] || (options[:cluster] && options[:cluster].identity),
    "slots" => {
      "names"    => options[:names],
      "quantity" => options[:quantity],
      "flavor"   => options[:flavor],
      "image"    => options[:image],
    }.reject {|key,val| val.nil? }
  )
  connection.slots.load(response.body["slots"])
end