Class: Ey::Core::Client::AutoScalingAlarm

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

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

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

Instance Method Details

#destroy!Object



47
48
49
50
51
52
53
# File 'lib/ey-core/models/auto_scaling_alarm.rb', line 47

def destroy!
  requires :identity

  connection.requests.new(
    connection.destroy_auto_scaling_alarm("id" => identity).body["request"]
  )
end

#save!Object



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
# File 'lib/ey-core/models/auto_scaling_alarm.rb', line 21

def save!
  requires :auto_scaling_policy_id, :trigger_value, :period_length
  params = {
    "auto_scaling_alarm" => {
      "name" => name,
      "trigger_value" => trigger_value,
      "aggregation_type" => aggregation_type,
      "metric_type" => metric_type,
      "operand" => operand,
      "period_length" => period_length,
      "number_of_periods" => number_of_periods
    },
    "auto_scaling_policy_id"  => auto_scaling_policy_id
  }

  if new_record?
    requires :name
    request_attributes = connection.create_auto_scaling_alarm(params).body["request"]
    connection.requests.new(request_attributes)
  else
    requires :identity
    params.merge!("id" => identity)
    connection.requests.new(connection.update_auto_scaling_alarm(params).body["request"])
  end
end