Class: MISP::Galaxy

Inherits:
Base
  • Object
show all
Defined in:
lib/misp/galaxy.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Galaxy

Returns a new instance of Galaxy.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/misp/galaxy.rb', line 21

def initialize(**attributes)
  attributes = normalize_attributes(attributes)

  @id = attributes.dig(:id)
  @uuid = attributes.dig(:uuid)
  @name = attributes.dig(:name)
  @type = attributes.dig(:type)
  @description = attributes.dig(:description)
  @version = attributes.dig(:version)

  @galaxy_clusters = build_plural_attribute(items: attributes.dig(:GalaxyCluster), klass: GalaxyCluster)
end

Instance Attribute Details

#descriptionString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/misp/galaxy.rb', line 14

def description
  @description
end

#galaxy_clustersArray<MISP::GalaxyCluster> (readonly)

Returns:



19
20
21
# File 'lib/misp/galaxy.rb', line 19

def galaxy_clusters
  @galaxy_clusters
end

#idString (readonly)

Returns:

  • (String)


6
7
8
# File 'lib/misp/galaxy.rb', line 6

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/misp/galaxy.rb', line 10

def name
  @name
end

#typeString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/misp/galaxy.rb', line 12

def type
  @type
end

#uuidString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/misp/galaxy.rb', line 8

def uuid
  @uuid
end

#versionString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/misp/galaxy.rb', line 16

def version
  @version
end

Class Method Details

.get(id) ⇒ Object



78
79
80
# File 'lib/misp/galaxy.rb', line 78

def get(id)
  new(id: id).get
end

.listObject



74
75
76
# File 'lib/misp/galaxy.rb', line 74

def list
  new.list
end

Instance Method Details

#getMISP::Galaxy

Get a galaxy

Returns:



69
70
71
# File 'lib/misp/galaxy.rb', line 69

def get
  _get("/galaxies/view/#{id}") { |galaxy| Galaxy.new galaxy }
end

#listArray<Galaxy>

List galaxies

Returns:



56
57
58
59
60
61
62
# File 'lib/misp/galaxy.rb', line 56

def list
  _get("/galaxies/") do |galaxies|
    galaxies.map do |galaxy|
      Galaxy.new galaxy
    end
  end
end

#to_hHash

Returns a hash representation of the attribute data.

Returns:

  • (Hash)


39
40
41
42
43
44
45
46
47
48
49
# File 'lib/misp/galaxy.rb', line 39

def to_h
  {
    id: id,
    uuid: uuid,
    name: name,
    type: type,
    description: description,
    version: version,
    GalaxyCluster: galaxy_clusters.map(&:to_h)
  }.compact
end