Sha256: 503f22821754f515417119cc2824c8012d556df3bec4ed953926be885509b24a

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Clients
    class MISP < Base
      #
      # @param [String] base_url
      # @param [String, nil] api_key
      # @param [Hash] headers
      # @param [Integer, nil] timeout
      #
      def initialize(base_url, api_key:, headers: {}, timeout: nil)
        raise(ArgumentError, "'api_key' argument is required") unless api_key

        headers["authorization"] = api_key
        headers["accept"] = "application/json"

        super(base_url, headers: headers, timeout: timeout)
      end

      #
      # @param [Hash] payload
      #
      # @return [Hash]
      #
      def create_event(payload)
        res = post("/events/add", json: payload)
        JSON.parse(res.body.to_s)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mihari-5.6.0 lib/mihari/clients/misp.rb
mihari-5.5.0 lib/mihari/clients/misp.rb