_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 REST endpoint path of the DELETE request.

params Object

The entity-specific 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 to a REST endpoint, and if necessary includes the namespace owner and app.

Syntax

fullpath: function(path, namespace)

Parameters

Name Type Description
path String

The partial path.

namespace String

The namespace, in the format "owner/app".

Return

String.

The fully-qualified path.

get

splunkjs.Context.get

Performs a GET request.

Syntax

get: function(path, params, callback, isAsync)

Parameters

Name Type Description
path String

The REST endpoint path of the GET request.

params Object

The entity-specific 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 (string): The scheme ("http" or "https") for accessing Splunk.
- host (string): The host name (the default is "localhost").
- port (integer): The port number (the default is 8089).
- username (string): The Splunk account username, which is used to authenticate the Splunk instance.
- password (string): The password, which is used to authenticate the Splunk instance.
- owner (string): The owner (username) component of the namespace.
- app (string): The app component of the namespace.
- sessionKey (string): The current session token.
- autologin (boolean): true to automatically try to log in again if the session terminates, false if not (true by default).
- 'timeout' (integer): The connection timeout in milliseconds. ('0' by default).
- version (
string_): The version string for Splunk, for example "4.3.2" (the default is "5.0").

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 login has finished: (err, wasSuccessful).

logout

splunkjs.Context.logout

Logs the session out resulting in the removal of all cookies and the session key.

Syntax

logout: function(callback)

Parameters

Name Type Description
callback Function

The function to call when logout has finished: ().

post

splunkjs.Context.post

Performs a POST request.

Syntax

post: function(path, params, callback)

Parameters

Name Type Description
path String

The REST endpoint path of the POST request.

params Object

The entity-specific parameters for this request.

callback Function

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

request

splunkjs.Context.request

Issues an arbitrary HTTP request to the REST endpoint path segment.

Syntax

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

Parameters

Name Type Description
path String

The REST endpoint path segment (with any query parameters already appended and encoded).

method String

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

query Object

The entity-specific parameters for this request.

post Object

A dictionary of POST argument that will get form encoded.

body Object

The body of the request, mutually exclusive with post.

headers Object

Headers 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.

versionCompare

splunkjs.Context.versionCompare

Compares the Splunk server's version to the specified version string. Returns -1 if (this.version < otherVersion), 0 if (this.version == otherVersion), 1 if (this.version > otherVersion).

Syntax

versionCompare: function(otherVersion)

Parameters

Name Type Description
otherVersion String

The other version string, for example "5.0".