Class: MISP::Tag
Instance Attribute Summary collapse
Class Method Summary collapse
- .create(**attributes) ⇒ Object
- .delete(id) ⇒ Object
- .get(id) ⇒ Object
- .update(id, **attributes) ⇒ Object
Instance Method Summary collapse
-
#create(**attributes) ⇒ MISP::Tag
Create a tag.
-
#delete ⇒ Hash
Delete a tag.
-
#get ⇒ MISP::Tag
Get a tag.
-
#initialize(**attributes) ⇒ Tag
constructor
A new instance of Tag.
-
#search(**params) ⇒ MISP::Tag
Search for tags.
-
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
-
#update(**attributes) ⇒ MISP::Tag
Update a tag.
Constructor Details
#initialize(**attributes) ⇒ Tag
Returns a new instance of Tag.
16 17 18 19 20 21 22 23 24 |
# File 'lib/misp/tag.rb', line 16 def initialize(**attributes) attributes = normalize_attributes(attributes) @id = attributes.dig(:id) @name = attributes.dig(:name) @colour = attributes.dig(:colour) @exportable = attributes.dig(:exportable) @hide_tag = attributes.dig(:hide_tag) end |
Instance Attribute Details
#colour ⇒ String
10 11 12 |
# File 'lib/misp/tag.rb', line 10 def colour @colour end |
#exportable ⇒ Boolean
12 13 14 |
# File 'lib/misp/tag.rb', line 12 def exportable @exportable end |
#hide_tag ⇒ Boolean
14 15 16 |
# File 'lib/misp/tag.rb', line 14 def hide_tag @hide_tag end |
#id ⇒ String
6 7 8 |
# File 'lib/misp/tag.rb', line 6 def id @id end |
#name ⇒ String
8 9 10 |
# File 'lib/misp/tag.rb', line 8 def name @name end |
Class Method Details
.create(**attributes) ⇒ Object
100 101 102 |
# File 'lib/misp/tag.rb', line 100 def create(**attributes) new.create attributes end |
.delete(id) ⇒ Object
104 105 106 |
# File 'lib/misp/tag.rb', line 104 def delete(id) Tag.new(id: id).delete end |
.get(id) ⇒ Object
96 97 98 |
# File 'lib/misp/tag.rb', line 96 def get(id) new(id: id).get end |
Instance Method Details
#create(**attributes) ⇒ MISP::Tag
Create a tag
57 58 59 |
# File 'lib/misp/tag.rb', line 57 def create(**attributes) _post("/tags/add", wrap(attributes)) { |json| Tag.new json } end |
#delete ⇒ Hash
Delete a tag
66 67 68 |
# File 'lib/misp/tag.rb', line 66 def delete _post("/tags/delete/#{id}") { |json| json } end |
#get ⇒ MISP::Tag
Get a tag
46 47 48 |
# File 'lib/misp/tag.rb', line 46 def get _get("/tags/view/#{id}") { |json| Tag.new json } end |
#search(**params) ⇒ MISP::Tag
Search for tags
89 90 91 92 93 |
# File 'lib/misp/tag.rb', line 89 def search(**params) _post("/tags/search", params) do || .map { |tag| Tag.new tag } end end |
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
31 32 33 34 35 36 37 38 39 |
# File 'lib/misp/tag.rb', line 31 def to_h { id: id, name: name, colour: colour, exportable: exportable, hide_tag: hide_tag, }.compact end |