Sha256: 4940393e13d57171a5897db3b22798f2b06b54708a85f1047187554dac4e78ff

Contents?: true

Size: 866 Bytes

Versions: 2

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

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

        base_url += "/#{api_version}" unless api_version.nil?
        headers["authorization"] = "Bearer #{api_key}"

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

      #
      # @param [Hash] json
      #
      # @return [Hash]
      #
      def alert(json)
        json = json.to_camelback_keys.compact
        res = post("/alert", json: json)
        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.2 lib/mihari/clients/the_hive.rb
mihari-5.6.1 lib/mihari/clients/the_hive.rb