Class: Fog::Rackspace::Monitoring::Alarm
- Defined in:
- lib/fog/rackspace/models/monitoring/alarm.rb
Instance Method Summary collapse
- #check=(obj) ⇒ Object
- #destroy ⇒ Object
- #entity=(obj) ⇒ Object
- #params(options = {}) ⇒ Object
- #save ⇒ Object
Methods inherited from Base
Instance Method Details
#check=(obj) ⇒ Object
22 23 24 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 22 def check=(obj) attributes[:check] = obj.is_a?(String) ? Check.new(:id => obj) : obj end |
#destroy ⇒ Object
51 52 53 54 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 51 def destroy requires :id service.delete_alarm(entity.id, id) end |
#entity=(obj) ⇒ Object
18 19 20 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 18 def entity=(obj) attributes[:entity] = obj.is_a?(String) ? Entity.new(:id => obj) : obj end |
#params(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 26 def params(={}) h = { 'disabled' => disabled, 'label' => label, 'criteria' => criteria, 'notification_plan_id' => notification_plan_id, }.merge() h.reject {|key, value| value.nil?} end |
#save ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 36 def save requires :notification_plan_id requires :entity requires :check if identity service.update_alarm(entity.id, identity, params) else = params('check_type' => check_type, 'check_id' => check.id) data = service.create_alarm(entity.id, ) self.id = data.headers['X-Object-ID'] end true end |