Module: Splunker

Defined in:
lib/splunker.rb,
lib/splunker/cli.rb,
lib/splunker/auth.rb,
lib/splunker/client.rb,
lib/splunker/errors.rb,
lib/splunker/request.rb,
lib/splunker/version.rb,
lib/splunker/connection.rb,
lib/splunker/configuration.rb,
lib/splunker/auth/http_auth.rb,
lib/splunker/auth/token_auth.rb,
lib/splunker/models/resource.rb,
lib/splunker/auth/splunk_auth.rb,
lib/splunker/faraday_middleware.rb,
lib/splunker/models/xml_processor.rb

Overview

The parent Splunker module can directly invoke any method invokable by the client returned in Splunker.client, so long as Splunker.client has been called once with options to instantiate a new client.

If using the helper models, you must first configure Splunker with Splunker.client({ :options => “…” }), as they all reference Splunker.client when they make requests.

Defined Under Namespace

Modules: Auth, CLI, Configuration, Connection, Errors, Models, Request Classes: Client, FaradayMiddleware

Constant Summary collapse

VERSION =
File.read(File.dirname(__FILE__) + "/../../VERSION").chomp

Class Method Summary collapse

Class Method Details

.client(options = {}) ⇒ Object

Returns a reference to the current Splunk API client if no options are supplied. Otherwise, generates a new Splunker client.

Parameters:

  • options => See Splunker::Client’s initialize method for details.

Returns an instance of Splunker::Client



22
23
24
25
26
27
28
# File 'lib/splunker.rb', line 22

def self.client(options={})
  unless options.empty?
    Thread.current[:splunker_client] = Splunker::Client.new(options)
  end

  Thread.current[:splunker_client] 
end

.loggerObject

A reference to the Splunker logger



31
32
33
34
35
36
37
# File 'lib/splunker.rb', line 31

def self.logger
  if @logger.nil?
    @logger = Logger.new(STDOUT)
    @logger.level = Logger::INFO
  end 
  @logger
end

.logger=(custom_logger) ⇒ Object

Parameters:

  • custom_logger => A custom logger to use instead of Logger



41
42
43
# File 'lib/splunker.rb', line 41

def self.logger=(custom_logger)
  @logger = custom_logger
end

.method_missing(method, *args, &block) ⇒ Object



45
46
47
48
49
50
# File 'lib/splunker.rb', line 45

def self.method_missing(method,*args,&block)
  if self.client.respond_to?(method)
    return self.client.send(method,*args,&block)
  end
  super
end

.respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/splunker.rb', line 52

def self.respond_to?(method)
  self.client.respond_to?(method) || super
end