class Hachi::Clients::Alert

Public Instance Methods

create(title:, description:, type:, source:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, source_ref: nil, artifacts: nil, follow: nil) click to toggle source

Create an alert

@param [String] title @param [String] description @param [String, nil] severity @param [String, nil] date @param [String, nil] tags @param [String, nil] tlp @param [String, nil] status @param [String, nil] type @param [String, nil] source @param [String, nil] source_ref @param [String, nil] artifacts @param [String, nil] follow

@return [Hash]

# 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: 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) click to toggle source

Delete an alert

@param [String] id Alert ID

@return [String]

# File lib/hachi/clients/alert.rb, line 36
def delete_by_id(id)
  delete("/api/alert/#{id}") { |json| json }
end
get_by_id(id) click to toggle source

Get an alert

@param [String] id Alert ID

@return [Hash]

# File lib/hachi/clients/alert.rb, line 25
def get_by_id(id)
  get("/api/alert/#{id}") { |json| json }
end
list() click to toggle source

List alerts

@return [Array]

# File lib/hachi/clients/alert.rb, line 14
def list
  get("/api/alert") { |json| json }
end
mark_as_read(id) click to toggle source

Mark an alert as read

@param [String] id Alert ID

@return [Hash]

# 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) click to toggle source

Mark an alert as unread

@param [String] id Alert ID

@return [Hash] hash

# 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) click to toggle source

Merge an alert / alerts in a case

@param [String, Array] *ids Alert ID(s) @param [String] case_id Case ID

@return [Hash]

# 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) click to toggle source

Create a case from an alert

@param [String] id Alert ID

@return [Hash]

# File lib/hachi/clients/alert.rb, line 118
def promote_to_case(id)
  post("/api/alert/#{id}/createCase") { |json| json }
end
update(id, title: nil, description: nil, severity: nil, tags: nil, tlp: nil, artifacts: nil) click to toggle source

Update an alert

@param [String, nil] id @param [String, nil] title @param [String, nil] description @param [String, nil] severity @param [String, nil] tags @param [String, nil] tlp @param [String, nil] artifacts

@return [Hash]

# 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: tags,
    tlp: tlp,
    artifacts: artifacts,
  }.compact
  patch("/api/alert/#{id}", json: attributes) { |json| json }
end