init

splunkjs.Context.init

Constructor for splunkjs.Context

Syntax

init: function(http, params)

Parameters

Name Type Description
http splunkjs.Http

An instance of a splunkjs.Http class

params Object

Dictionary of optional parameters:
- scheme: http or https
- host: hostname for Splunk
- port: port for Splunk
- username: username to login with
- password: password to login with
- owner: owner component of namespace
- app: app component of namespace
- sessionKey: optional pre-loaded session key

Return

splunkjs.Context. A splunkjs.Context instance

request

splunkjs.Context.request

Perform a request

Syntax

request: function(path, method, headers, body, callback)

Parameters

Name Type Description
path String

URL to request (with any query parameters already appended and encoded)

method String

HTTP method (one of GET | POST | DELETE)

headers Object

Object of headers for this request

body Object

Body of parameters for this request

callback Function

Callback for when the request is complete: (err, response)

post

splunkjs.Context.post

Perform a POST request

Syntax

post: function(path, params, callback)

Parameters

Name Type Description
path String

Path to request

params Object

Body parameters for this request

callback Function

Callback for when the request is complete: (err, response)

del

splunkjs.Context.del

Perform a DELETE request

Syntax

del: function(path, params, callback)

Parameters

Name Type Description
path String

Path to request

params Object

Query parameters for this request

callback Function

Callback for when the request is complete: (err, response)

get

splunkjs.Context.get

Perform a GET request

Syntax

get: function(path, params, callback)

Parameters

Name Type Description
path String

Path to request

params Object

Query parameters for this request

callback Function

Callback for when the request is complete: (err, response)

login

splunkjs.Context.login

Login to a Splunk instance

Perform authentication to a Splunk instance and store the resulting session key.

Syntax

login: function(callback)

Parameters

Name Type Description
callback Function

Callback to be executed when login is complete: (err, wasSuccessful)

urlify

splunkjs.Context.urlify

Convert partial paths to a fully qualified URL

Convert any partial path into a fully qualified URL.

Syntax

urlify: function(path)

Parameters

Name Type Description
path String

Partial path

Return

String. Fully qualified URL

fullpath

splunkjs.Context.fullpath

Convert partial paths to fully qualified ones

Convert any partial path into a full path containing the full owner and app prefixes if necessary

Syntax

fullpath: function(path, namespace)

Parameters

Name Type Description
path String

Partial path

Return

String. Fully qualified path

_headers

splunkjs.Context._headers

Append Splunk-specific headers

Syntax

_headers: function (headers)

Parameters

Name Type Description
headers Object

Dictionary of headers (optional)

Return

Object. Augmented dictionary of headers