class Flapjack::Data::Acknowledgement
Attributes
queue[RW]
Public Class Methods
jsonapi_associations()
click to toggle source
# File lib/flapjack/data/acknowledgement.rb, line 155 def self.jsonapi_associations unless instance_variable_defined?('@jsonapi_associations') @jsonapi_associations = { :check => Flapjack::Gateways::JSONAPI::Data::JoinDescriptor.new( :post => true, :number => :singular, :link => false, :includable => false, :type => 'check', :klass => Flapjack::Data::Check ), :tag => Flapjack::Gateways::JSONAPI::Data::JoinDescriptor.new( :post => true, :number => :singular, :link => false, :includable => false, :type => 'tag', :klass => Flapjack::Data::Tag ) } populate_association_data(@jsonapi_associations) end @jsonapi_associations end
jsonapi_methods()
click to toggle source
# File lib/flapjack/data/acknowledgement.rb, line 143 def self.jsonapi_methods @jsonapi_methods ||= { :post => Flapjack::Gateways::JSONAPI::Data::MethodDescriptor.new( :attributes => [:duration, :summary], :descriptions => { :singular => "Acknowledge a check, or acknowledge all checks linked to a tag.", :multiple => "Acknowledge multiple checks, or checks linked to different tags." } ) } end
swagger_included_classes()
click to toggle source
# File lib/flapjack/data/acknowledgement.rb, line 138 def self.swagger_included_classes # hack -- hardcoding for now [] end
Public Instance Methods
check=(c)
click to toggle source
# File lib/flapjack/data/acknowledgement.rb, line 43 def check=(c) raise "Acknowledgement not saved" unless persisted? raise "Acknowledgement queue not set" if @queue.nil? || @queue.empty? raise "Acknowledgement already sent" if @sent if c.failing && c.enabled @checks = [c] Flapjack::Data::Event.create_acknowledgements( @queue, @checks, :duration => self.duration, :summary => self.summary ) end @sent = true end
persisted?()
click to toggle source
# File lib/flapjack/data/acknowledgement.rb, line 39 def persisted? !@id.nil? && @saved.is_a?(TrueClass) end
save!()
click to toggle source
# File lib/flapjack/data/acknowledgement.rb, line 33 def save! @id ||= SecureRandom.uuid @duration ||= (4 * 60 * 60) @saved = true end
tag=(t)
click to toggle source
# File lib/flapjack/data/acknowledgement.rb, line 58 def tag=(t) raise "Acknowledgement not saved" unless persisted? raise "Acknowledgement queue not set" if @queue.nil? || @queue.empty? raise "Acknowledgement already sent" if @sent checks = t.checks.intersect(:failing => true, :enabled => true) unless checks.empty? @checks = checks.all Flapjack::Data::Event.create_acknowledgements( @queue, @checks, :duration => self.duration, :summary => self.summary ) end @sent = true end