Sha256: d87184578cd3389da3f7303ec8ca614faedcde1ea3b9e08298c577cbabbf33eb

Contents?: true

Size: 887 Bytes

Versions: 2

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: true

module MISP
  class Server < Base
    # @return [String]
    attr_reader :id
    # @return [String]
    attr_reader :url
    # @return [String]
    attr_reader :name

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

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

    #
    # Returns a hash representation of the attribute data.
    #
    # @return [Hash]
    #
    def to_h
      {
        id: id,
        url: url,
        name: name,
      }.compact
    end

    #
    # List servers
    #
    # @return [Array<MISP::Server>]
    #
    def list
      _get("/servers/") do |servers|
        servers.map do |server|
          Server.new server
        end
      end
    end

    class << self
      def list
        new.list
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
misp-0.1.3 lib/misp/server.rb
misp-0.1.2 lib/misp/server.rb