class Ey::Core::Client::AutoScalingAlarm

Public Instance Methods

destroy!() click to toggle source
# 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!() click to toggle source
# 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