Class: Garrison::Api::Alert
- Inherits:
-
Object
- Object
- Garrison::Api::Alert
- Defined in:
- lib/garrison/api/alert.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#departments ⇒ Object
Returns the value of attribute departments.
-
#detail ⇒ Object
Returns the value of attribute detail.
-
#family ⇒ Object
Returns the value of attribute family.
-
#finding ⇒ Object
Returns the value of attribute finding.
-
#finding_id ⇒ Object
Returns the value of attribute finding_id.
-
#first_detected_at ⇒ Object
Returns the value of attribute first_detected_at.
-
#key_values ⇒ Object
Returns the value of attribute key_values.
-
#last_detected_at ⇒ Object
Returns the value of attribute last_detected_at.
-
#name ⇒ Object
Returns the value of attribute name.
-
#no_repeat ⇒ Object
Returns the value of attribute no_repeat.
-
#run_uuid ⇒ Object
Returns the value of attribute run_uuid.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#source ⇒ Object
Returns the value of attribute source.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
-
#urls ⇒ Object
Returns the value of attribute urls.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Alert
constructor
A new instance of Alert.
- #save ⇒ Object
Constructor Details
#initialize ⇒ Alert
Returns a new instance of Alert.
50 |
# File 'lib/garrison/api/alert.rb', line 50 def initialize; end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
48 49 50 |
# File 'lib/garrison/api/alert.rb', line 48 def count @count end |
#departments ⇒ Object
Returns the value of attribute departments.
46 47 48 |
# File 'lib/garrison/api/alert.rb', line 46 def departments @departments end |
#detail ⇒ Object
Returns the value of attribute detail.
38 39 40 |
# File 'lib/garrison/api/alert.rb', line 38 def detail @detail end |
#family ⇒ Object
Returns the value of attribute family.
34 35 36 |
# File 'lib/garrison/api/alert.rb', line 34 def family @family end |
#finding ⇒ Object
Returns the value of attribute finding.
40 41 42 |
# File 'lib/garrison/api/alert.rb', line 40 def finding @finding end |
#finding_id ⇒ Object
Returns the value of attribute finding_id.
41 42 43 |
# File 'lib/garrison/api/alert.rb', line 41 def finding_id @finding_id end |
#first_detected_at ⇒ Object
Returns the value of attribute first_detected_at.
42 43 44 |
# File 'lib/garrison/api/alert.rb', line 42 def first_detected_at @first_detected_at end |
#key_values ⇒ Object
Returns the value of attribute key_values.
44 45 46 |
# File 'lib/garrison/api/alert.rb', line 44 def key_values @key_values end |
#last_detected_at ⇒ Object
Returns the value of attribute last_detected_at.
43 44 45 |
# File 'lib/garrison/api/alert.rb', line 43 def last_detected_at @last_detected_at end |
#name ⇒ Object
Returns the value of attribute name.
36 37 38 |
# File 'lib/garrison/api/alert.rb', line 36 def name @name end |
#no_repeat ⇒ Object
Returns the value of attribute no_repeat.
47 48 49 |
# File 'lib/garrison/api/alert.rb', line 47 def no_repeat @no_repeat end |
#run_uuid ⇒ Object
Returns the value of attribute run_uuid.
32 33 34 |
# File 'lib/garrison/api/alert.rb', line 32 def run_uuid @run_uuid end |
#severity ⇒ Object
Returns the value of attribute severity.
39 40 41 |
# File 'lib/garrison/api/alert.rb', line 39 def severity @severity end |
#source ⇒ Object
Returns the value of attribute source.
35 36 37 |
# File 'lib/garrison/api/alert.rb', line 35 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
37 38 39 |
# File 'lib/garrison/api/alert.rb', line 37 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
33 34 35 |
# File 'lib/garrison/api/alert.rb', line 33 def type @type end |
#urls ⇒ Object
Returns the value of attribute urls.
45 46 47 |
# File 'lib/garrison/api/alert.rb', line 45 def urls @urls end |
Class Method Details
.obsolete_previous_runs(check) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/garrison/api/alert.rb', line 6 def obsolete_previous_runs(check) raise ArgumentError, "No source defined" unless check.source url = File.join(Api.configuration.url, 'api', 'v1', 'alerts', 'obsolete') party_params = { body: { source: check.source, agent_id: Api.configuration.uuid, run_id: check.run_uuid, }.to_json, headers: { 'Content-Type' => 'application/json' }, logger: Logging.logger, log_level: :debug, raise_on: (400..599).to_a } Logging.debug "Alert::obsolete_previous_runs - #{party_params[:body]}" HTTParty.post(url, party_params) rescue Errno::ECONNREFUSED => e Logging.error "#{e.class} to the Garrison API during Alert::obsolete_previous_runs - #{e.}" rescue HTTParty::ResponseError => e Logging.error "#{e.class} #{e..split(" - ")[0]} - When calling the Garrison API during Alert::obsolete_previous_runs" end |
Instance Method Details
#save ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/garrison/api/alert.rb', line 52 def save url = File.join(Api.configuration.url, 'api', 'v1', 'alerts') party_params = { body: { name: name, target: target, detail: detail, finding: finding, finding_id: finding_id, first_detected_at: first_detected_at, last_detected_at: last_detected_at, kind: type, family: family, source: source, severity: severity, key_values: key_values, urls: urls, departments: departments, no_repeat: no_repeat, count: count, agent_id: Api.configuration.uuid, run_id: run_uuid, }.to_json, headers: { 'Content-Type' => 'application/json' }, logger: Logging.logger, log_level: :debug, raise_on: (400..599).to_a } Logging.debug "Alert::save - #{party_params[:body]}" HTTParty.post(url, party_params) rescue Errno::ECONNREFUSED => e Logging.error "#{e.class} to the Garrison API during Alert::save - #{e.}" rescue HTTParty::ResponseError => e Logging.error "#{e.class} #{e..split(" - ")[0]} - When calling the Garrison API during Alert::save" end |