Class: Fog::Rackspace::Monitoring::Alarm
- Defined in:
- lib/fog/rackspace/models/monitoring/alarm.rb
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #check=(obj) ⇒ Object
- #destroy ⇒ Object
- #entity=(obj) ⇒ Object
- #params(options = {}) ⇒ Object
- #save ⇒ Object
Methods inherited from Base
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
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
50 51 52 53 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 50 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 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 26 def params(={}) h = { 'label' => label, 'criteria' => criteria, 'notification_plan_id' => notification_plan_id, }.merge() h.reject {|key, value| value.nil?} end |
#save ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/rackspace/models/monitoring/alarm.rb', line 35 def save requires :notification_plan_id requires :entity requires :check if identity data = 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 |