Class: Hachi::API

Inherits:
Object
  • Object
show all
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



17
18
19
20
21
22
23
# File 'lib/hachi/api.rb', line 17

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
end

Instance Attribute Details

#api_endpointString (readonly)

Returns TheHive API endpoint.

Returns:

  • (String)

    TheHive API endpoint



6
7
8
# File 'lib/hachi/api.rb', line 6

def api_endpoint
  @api_endpoint
end

#api_keyString (readonly)

Returns TheHive API key.

Returns:

  • (String)

    TheHive API key



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

def api_key
  @api_key
end

Instance Method Details

#alertClients::Alert

Alert API endpoint client

Returns:



30
31
32
# File 'lib/hachi/api.rb', line 30

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

#artifactClients::Artifact

Artifact API endpoint client

Returns:



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

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

#caseClients::Case

Case API endpoint client

Returns:



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

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

#userClients::User

User API endpoint client

Returns:



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

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