Class: Hachi::Clients::Alert
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(title:, description:, type:, source:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, source_ref: nil, artifacts: nil, follow: nil) ⇒ Hash
Create an alert.
-
#delete_by_id(id) ⇒ String
Delete an alert.
-
#get_by_id(id) ⇒ Hash
Get an alert.
-
#list ⇒ Array
List alerts.
-
#mark_as_read(id) ⇒ Hash
Mark an alert as read.
-
#mark_as_unread(id) ⇒ Hash
Mark an alert as unread.
-
#merge_into_case(*ids, case_id) ⇒ Hash
Merge an alert / alerts in a case.
-
#promote_to_case(id) ⇒ Hash
Create a case from an alert.
-
#search(query, range: "all", sort: nil) ⇒ Array
Find alerts.
-
#update(id, title: nil, description: nil, severity: nil, tags: nil, tlp: nil, artifacts: nil) ⇒ Hash
Update an alert.
Methods inherited from Base
#delete, #get, #initialize, #patch, #post
Constructor Details
This class inherits a constructor from Hachi::Clients::Base
Instance Method Details
#create(title:, description:, type:, source:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, source_ref: nil, artifacts: nil, follow: nil) ⇒ Hash
Create an alert
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/hachi/clients/alert.rb', line 58 def create(title:, description:, type:, source:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, source_ref: nil, artifacts: nil, follow: nil) alert = Models::Alert.new( title: title, description: description, severity: severity, date: date, tags: , tlp: tlp, status: status, type: type, source: source, source_ref: source_ref, artifacts: artifacts, follow: follow, ) post("/api/alert", json: alert.payload) { |json| json } end |
#delete_by_id(id) ⇒ String
Delete an alert
36 37 38 |
# File 'lib/hachi/clients/alert.rb', line 36 def delete_by_id(id) delete("/api/alert/#{id}") { |json| json } end |
#get_by_id(id) ⇒ Hash
Get an alert
25 26 27 |
# File 'lib/hachi/clients/alert.rb', line 25 def get_by_id(id) get("/api/alert/#{id}") { |json| json } end |
#list ⇒ Array
List alerts
14 15 16 |
# File 'lib/hachi/clients/alert.rb', line 14 def list get("/api/alert") { |json| json } end |
#mark_as_read(id) ⇒ Hash
Mark an alert as read
96 97 98 |
# File 'lib/hachi/clients/alert.rb', line 96 def mark_as_read(id) post("/api/alert/#{id}/markAsRead") { |json| json } end |
#mark_as_unread(id) ⇒ Hash
Mark an alert as unread
107 108 109 |
# File 'lib/hachi/clients/alert.rb', line 107 def mark_as_unread(id) post("/api/alert/#{id}/markAsUnread") { |json| json } end |
#merge_into_case(*ids, case_id) ⇒ Hash
Merge an alert / alerts in a case
130 131 132 133 134 135 136 |
# File 'lib/hachi/clients/alert.rb', line 130 def merge_into_case(*ids, case_id) params = { alertIds: ids.flatten, caseId: case_id } post("/api/alert/merge/_bulk", json: params) { |json| json } end |
#promote_to_case(id) ⇒ Hash
Create a case from an alert
118 119 120 |
# File 'lib/hachi/clients/alert.rb', line 118 def promote_to_case(id) post("/api/alert/#{id}/createCase") { |json| json } end |
#search(query, range: "all", sort: nil) ⇒ Array
Find alerts
85 86 87 |
# File 'lib/hachi/clients/alert.rb', line 85 def search(query, range: "all", sort: nil) _search("/api/alert/_search", query: query, range: range, sort: sort) { |json| json } end |
#update(id, title: nil, description: nil, severity: nil, tags: nil, tlp: nil, artifacts: nil) ⇒ Hash
Update an alert
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/hachi/clients/alert.rb', line 151 def update(id, title: nil, description: nil, severity: nil, tags: nil, tlp: nil, artifacts: nil) attributes = { title: title, description: description, severity: severity, tags: , tlp: tlp, artifacts: artifacts, }.compact patch("/api/alert/#{id}", json: attributes) { |json| json } end |