1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[rackspace|monitoring] replaced entity_id and check_id attributes with entity and check attributes; removed entity_id from base module.

This commit is contained in:
Kyle Rames 2013-08-08 11:01:52 -05:00
parent 4b13e6c434
commit 5dccb0dd6f
3 changed files with 18 additions and 16 deletions

View file

@ -7,15 +7,22 @@ module Fog
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,
@ -27,13 +34,14 @@ module Fog
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
@ -41,7 +49,7 @@ module Fog
def destroy
requires :id
service.delete_alarm(entity.id,id)
service.delete_alarm(entity.id, id)
end
end

View file

@ -24,12 +24,6 @@ module Fog
remain = a_o.reject {|key, value| b_o[key] === value}
remain.empty?
end
def entity_id
raise(ArgumentError, "entity with id is required for this operation") unless entity && entity.identity
entity.identity
end
end
end
end

View file

@ -17,10 +17,10 @@ Shindo.tests('Fog::Rackspace::Monitoring | alarm', ['rackspace','rackspace_monit
check = Fog::Rackspace::Monitoring::Check.new(:id => check_id)
check.entity = entity
alarm = Fog::Rackspace::Monitoring::Alarm.new
alarm.check_id = check.id
alarm.check = check.id
returns(Fog::Rackspace::Monitoring::Alarm) { alarm.class }
returns(check_id) { alarm.check_id }
returns(check_id) { alarm.check.id }
end
end