Class: Hachi::Clients::Case

Inherits:
Base
  • Object
show all
Defined in:
lib/hachi/clients/case.rb

Instance Attribute Summary

Attributes inherited from Base

#api_endpoint, #api_key

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Hachi::Clients::Base

Instance Method Details

#create(title:, description:, severity: nil, start_date: nil, owner: nil, flag: nil, tlp: nil, tags: nil) ⇒ Hash

Create a case

Parameters:

  • title (String, nil)
  • description (String, nil)
  • severity (Integer, nil) (defaults to: nil)
  • start_date (String, nil) (defaults to: nil)
  • owner (String, nil) (defaults to: nil)
  • flag (Boolean, nil) (defaults to: nil)
  • tlp (Intege, nil) (defaults to: nil)
  • tags (String, nil) (defaults to: nil)

Returns:

  • (Hash)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/hachi/clients/case.rb', line 51

def create(title:, description:, severity: nil, start_date: nil, owner: nil, flag: nil, tlp: nil, tags: nil)
  kase = Models::Case.new(
    title: title,
    description: description,
    severity: severity,
    start_date: start_date,
    owner: owner,
    flag: flag,
    tlp: tlp,
    tags: tags,
  )

  post("/api/case", kase.payload) { |json| json }
end

#delete_by_id(id) ⇒ String

Delete a case

Parameters:

  • id (String)

    Case ID

Returns:

  • (String)


33
34
35
# File 'lib/hachi/clients/case.rb', line 33

def delete_by_id(id)
  delete("/api/case/#{id}") { |json| json }
end

#get_by_id(id) ⇒ Hash

Get a case

Parameters:

  • id (String)

    Case ID

Returns:

  • (Hash)


22
23
24
# File 'lib/hachi/clients/case.rb', line 22

def get_by_id(id)
  get("/api/case/#{id}") { |json| json }
end

Get list of cases linked to this case

Parameters:

  • id (String)

    Case ID

Returns:

  • (Array)


85
86
87
# File 'lib/hachi/clients/case.rb', line 85

def links(id)
  get("/api/case/#{id}/links") { |json| json }
end

#listArray

List cases

Returns:

  • (Array)


11
12
13
# File 'lib/hachi/clients/case.rb', line 11

def list
  get("/api/case") { |json| json }
end

#merge(id1, id2) ⇒ Hash

Merge two cases

Parameters:

  • id1 (String)

    Case ID

  • id2 (String)

    Case ID

Returns:

  • (Hash)


97
98
99
# File 'lib/hachi/clients/case.rb', line 97

def merge(id1, id2)
  post("/api/case/#{id1}/_merge/#{id2}") { |json| json }
end

#search(range: "all", **attributes) ⇒ Hash

Find cases

Parameters:

  • attributes (Hash)
  • range (String) (defaults to: "all")

Returns:

  • (Hash)


74
75
76
# File 'lib/hachi/clients/case.rb', line 74

def search(range: "all", **attributes)
  _search("/api/case/_search", attributes: attributes, range: range) { |json| json }
end

#update(id, title: nil, description: nil, severity: nil, start_date: nil, owner: nil, flag: nil, tlp: nil, tags: nil, status: nil, resolution_status: nil, impact_status: nil, summary: nil, end_date: nil, metrics: nil, custom_fields: nil) ⇒ Hash

Update a case

Parameters:

  • id (String, nil)
  • title (String, nil) (defaults to: nil)
  • description (String, nil) (defaults to: nil)
  • severity (String, nil) (defaults to: nil)
  • start_date (String, nil) (defaults to: nil)
  • owner (String, nil) (defaults to: nil)
  • flag (Boolean, nil) (defaults to: nil)
  • tlp (Integer, nil) (defaults to: nil)
  • tags (String, nil) (defaults to: nil)
  • status (String, nil) (defaults to: nil)
  • resolution_status (String, nil) (defaults to: nil)
  • impact_status (String, nil) (defaults to: nil)
  • summary (String, nil) (defaults to: nil)
  • end_date (String, nil) (defaults to: nil)
  • metrics (String, nil) (defaults to: nil)
  • custom_fields (String, nil) (defaults to: nil)

Returns:

  • (Hash)


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/hachi/clients/case.rb', line 123

def update(id, title: nil, description: nil, severity: nil, start_date: nil, owner: nil, flag: nil, tlp: nil, tags: nil, status: nil, resolution_status: nil, impact_status: nil, summary: nil, end_date: nil, metrics: nil, custom_fields: nil )
  attributes = {
    title: title,
    description: description,
    severity: severity,
    startDate: start_date,
    owner: owner,
    flag: flag,
    tlp: tlp,
    tags: tags,
    status: status,
    resolutionStatus: resolution_status,
    impactStatus: impact_status,
    summary: summary,
    endDate: end_date,
    metrics: metrics,
    customFields: custom_fields
  }.compact
  patch("/api/case/#{id}", attributes) { |json| json }
end