lib/fog/rackspace/models/monitoring/alarm.rb in fog-maestrodev-1.14.0.20130806165225 vs lib/fog/rackspace/models/monitoring/alarm.rb in fog-maestrodev-1.15.0.20130829165835

- old
+ new

@@ -5,19 +5,26 @@ module Rackspace class Monitoring class Alarm < Fog::Rackspace::Monitoring::Base identity :id - attribute :entity - attribute :entity_id + attribute :entity, :aliases => 'entity_id' + attribute :check, :aliases => 'check_id' attribute :label attribute :criteria attribute :check_type - attribute :check_id attribute :notification_plan_id + def entity=(obj) + attributes[:entity] = obj.is_a?(String) ? Entity.new(:id => obj) : obj + end + + def check=(obj) + attributes[:check] = obj.is_a?(String) ? Check.new(:id => obj) : obj + end + def params(options={}) h = { 'label' => label, 'criteria' => criteria, 'notification_plan_id' => notification_plan_id, @@ -25,24 +32,25 @@ h.reject {|key, value| value.nil?} end def save requires :notification_plan_id - requires :entity_id + requires :entity + requires :check if identity - data = service.update_alarm(entity_id, identity, params) + data = service.update_alarm(entity.id, identity, params) else - options = params('check_type' => check_type, 'check_id' => check_id) - data = service.create_alarm(entity_id, options) + options = params('check_type' => check_type, 'check_id' => check.id) + data = service.create_alarm(entity.id, options) self.id = data.headers['X-Object-ID'] end true end def destroy requires :id - service.delete_alarm(entity.id,id) + service.delete_alarm(entity.id, id) end end end