Class: Ey::Core::Client::AutoScalingGroup

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/auto_scaling_group.rb

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

range_parser, #save, #to_s, #update!, #url

Instance Method Details

#destroyObject



16
17
18
# File 'lib/ey-core/models/auto_scaling_group.rb', line 16

def destroy
  connection.requests.new(connection.destroy_auto_scaling_group("id" => self.identity).body["request"])
end

#save!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ey-core/models/auto_scaling_group.rb', line 20

def save!
  if new_record?
    requires :maximum_size, :minimum_size, :environment

    params = {
      "url"                => self.collection.url,
      "environment"        => self.environment_id,
      "auto_scaling_group" => {
        "maximum_size" => self.maximum_size,
        "minimum_size" => self.minimum_size,
      }
    }

    connection.requests.new(connection.create_auto_scaling_group(params).body["request"])
  else
    requires :identity

    params = {
      "id" => self.identity,
      "auto_scaling_group" => {
        "maximum_size" => self.maximum_size,
        "minimum_size" => self.minimum_size,
        "desired_capacity" => self.desired_capacity
      }
    }

    connection.requests.new(connection.update_auto_scaling_group(params).body["request"])
  end
end