Class: Hachi::API

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hachi/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_endpoint: ENV["THEHIVE_API_ENDPOINT"], api_key: ENV["THEHIVE_API_KEY"]) ⇒ API

Returns a new instance of API.

Parameters:

  • api_endpoint (String, nil) (defaults to: ENV["THEHIVE_API_ENDPOINT"])

    TheHive API endpoint

  • api_key (String, nil) (defaults to: ENV["THEHIVE_API_KEY"])

    TheHive API key

Raises:

  • (ArgumentError)

    When given or an empty endpoint or key



21
22
23
24
25
26
27
28
29
# File 'lib/hachi/api.rb', line 21

def initialize(api_endpoint: ENV["THEHIVE_API_ENDPOINT"], api_key: ENV["THEHIVE_API_KEY"])
  @api_endpoint = api_endpoint
  raise ArgumentError, "api_endpoint argument is required" unless api_endpoint

  @api_key = api_key
  raise ArgumentError, "api_key argument is required" unless api_key

  @base = Clients::Base.new(api_endpoint: api_endpoint, api_key: api_key)
end

Instance Attribute Details

#api_endpointString (readonly)

Returns TheHive API endpoint.

Returns:

  • (String)

    TheHive API endpoint



10
11
12
# File 'lib/hachi/api.rb', line 10

def api_endpoint
  @api_endpoint
end

#api_keyString (readonly)

Returns TheHive API key.

Returns:

  • (String)

    TheHive API key



13
14
15
# File 'lib/hachi/api.rb', line 13

def api_key
  @api_key
end

Instance Method Details

#alertClients::Alert

Alert API endpoint client

Returns:



38
39
40
# File 'lib/hachi/api.rb', line 38

def alert
  @alert ||= Clients::Alert.new(api_endpoint: api_endpoint, api_key: api_key)
end

#artifactClients::Artifact

Artifact API endpoint client

Returns:



47
48
49
# File 'lib/hachi/api.rb', line 47

def artifact
  @artifact ||= Clients::Artifact.new(api_endpoint: api_endpoint, api_key: api_key)
end

#caseClients::Case

Case API endpoint client

Returns:



56
57
58
# File 'lib/hachi/api.rb', line 56

def case
  @case ||= Clients::Case.new(api_endpoint: api_endpoint, api_key: api_key)
end

#userClients::User

User API endpoint client

Returns:



65
66
67
# File 'lib/hachi/api.rb', line 65

def user
  @user ||= Clients::User.new(api_endpoint: api_endpoint, api_key: api_key)
end