Class: MISP::Server

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
17
18
# File 'lib/misp/server.rb', line 12

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

  @id = attributes.dig(:id)
  @url = attributes.dig(:url)
  @name = attributes.dig(:name)
end

Instance Attribute Details

#idString (readonly)

Returns:

  • (String)


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

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


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

def name
  @name
end

#urlString (readonly)

Returns:

  • (String)


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

def url
  @url
end

Class Method Details

.listObject



47
48
49
# File 'lib/misp/server.rb', line 47

def list
  new.list
end

Instance Method Details

#listArray<MISP::Server>

List servers

Returns:



38
39
40
41
42
43
44
# File 'lib/misp/server.rb', line 38

def list
  _get("/servers/") do |servers|
    servers.map do |server|
      Server.new server
    end
  end
end

#to_hHash

Returns a hash representation of the attribute data.

Returns:

  • (Hash)


25
26
27
28
29
30
31
# File 'lib/misp/server.rb', line 25

def to_h
  {
    id: id,
    url: url,
    name: name,
  }.compact
end