_headers

splunkjs.Context._headers

Appends Splunk-specific headers.

Syntax

_headers: function (headers)

Parameters

Name Type Description
headers Object

A dictionary of headers (optional).

Return

Object.

An augmented dictionary of headers.

del

splunkjs.Context.del

Performs a DELETE request.

Syntax

del: function(path, params, callback)

Parameters

Name Type Description
path String

The path of the DELETE request.

params Object

The query parameters for this request.

callback Function

The function to call when the request is complete: (err, response).

fullpath

splunkjs.Context.fullpath

Converts a partial path to a fully-qualified path, and if necessary includes the owner and app prefixes.

Syntax

fullpath: function(path, namespace)

Parameters

Name Type Description
path String

Partial path

namespace String

The namespace context, as 'owner/app'.

Return

String.

Fully qualified path

get

splunkjs.Context.get

Performs a GET request.

Syntax

get: function(path, params, callback)

Parameters

Name Type Description
path String

The path of the GET request.

params Object

The query parameters for this request.

callback Function

The function to call when the request is complete: (err, response).

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

A dictionary of optional parameters:
* scheme: The scheme (http or https) for accessing Splunk.
* host: The host name (the default is localhost).
* port: The port number (the default is 8089).
* username: The Splunk account username, which is used to authenticate the Splunk instance.
* password: The password, which is used to authenticate the Splunk instance.
* owner: The owner (username) component of the namespace context.
* app: The app component of the namespace context.
* sessionKey: The current session token.
* autologin: Enable or disable autologin functionaly (enabled by default).
* version: Version string for Splunk (e.g. 4.3, 4.3.2, 5.0) - defaults to 4.3.

Return

splunkjs.Context.

A new splunkjs.Context instance.

login

splunkjs.Context.login

Authenticates and logs in to a Splunk instance, then stores the resulting session key.

Syntax

login: function(callback)

Parameters

Name Type Description
callback Function

The function to call when the login has completed: (err, wasSuccessful).

post

splunkjs.Context.post

Performs a POST request.

Syntax

post: function(path, params, callback)

Parameters

Name Type Description
path String

The path of the POST request.

params Object

The query parameters for this request.

callback Function

The function to call when the request is complete: (err, response).

request

splunkjs.Context.request

Performs a request.

Syntax

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

Parameters

Name Type Description
path String

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

method String

The HTTP method (can be GET, POST, or DELETE).

headers Object

An object of headers for this request.

body Object

The body parameters for this request.

callback Function

The function to call when the request is complete: (err, response).

urlify

splunkjs.Context.urlify

Converts a partial path to a fully-qualified URL.

Syntax

urlify: function(path)

Parameters

Name Type Description
path String

The partial path.

Return

String.

The fully-qualified URL.