class Ey::Core::Client::BaseAutoScalingPolicy

Public Instance Methods

alarm() click to toggle source
# File lib/ey-core/models/base_auto_scaling_policy.rb, line 42
def alarm
  requires :identity

  data = self.connection.get_auto_scaling_alarms(
    "auto_scaling_policy_id" => identity
  ).body["auto_scaling_alarms"]

  self.connection.auto_scaling_alarms.load(data).first
end
destroy!() click to toggle source
# File lib/ey-core/models/base_auto_scaling_policy.rb, line 36
def destroy!
  connection.requests.new(
    self.connection.destroy_auto_scaling_policy("id" => self.id).body["request"]
  )
end
save!() click to toggle source
# File lib/ey-core/models/base_auto_scaling_policy.rb, line 15
def save!
  requires :auto_scaling_group_id, :type
  params = {
    "url"                 => self.collection.url,
    "auto_scaling_policy" => {
      "name" => self.name
    }.merge(policy_params),
    "auto_scaling_group_id"  => self.auto_scaling_group_id
  }

  if new_record?
    policy_requires
    requires :name
    connection.requests.new(connection.create_auto_scaling_policy(params).body["request"])
  else
    requires :identity
    params.merge("id" => identity)
    connection.requests.new(connection.update_auto_scaling_policy(params).body["request"])
  end
end

Private Instance Methods

policy_params() click to toggle source
# File lib/ey-core/models/base_auto_scaling_policy.rb, line 54
def policy_params
  raise NotImplementedError
end
policy_requires() click to toggle source
# File lib/ey-core/models/base_auto_scaling_policy.rb, line 58
def policy_requires
  raise NotImplementedError
end