create

splunkjs.Service.Configurations.create
Endpoint: properties

Creates a configuration file.

Syntax

create: function(filename, callback)

Parameters

Name Type Description
filename String

A name for this configuration file.

callback Function

A function to call with the new configuration file: (err, createdFile).

Examples

 var configurations = service.configurations();
 configurations.create("myprops", function(err, newFile) {
     console.log("CREATED");
 });

createAsync

splunkjs.Service.Configurations.createAsync
Endpoint: properties

Creates/Updates a configuration file and stanza.

Syntax

createAsync: async function (filename, stanzaName, keyValueMap, callback)

Parameters

Name Type Description
filename String

A name for this configuration file to be created/updated.

stanzaName String

A name for the stanza to be created/updated.

keyValueMap String

A key-value map of properties to be put under the stanza.

callback Function

A function to call with the new configuration file.

fetchOnEntityCreation

splunkjs.Service.Configurations.fetchOnEntityCreation

Indicates whether to call fetch after an entity has been created. By default, the entity is not fetched because the endpoint returns (echoes) the new entity.

getConfFile

splunkjs.Service.Configurations.getConfFile
Endpoint: properties

Fetch a configuration file.

Syntax

getConfFile: async function(filename)

Parameters

Name Type Description
file String

A name for configuration file.

Return

file,.

if exists or null

getStanza

splunkjs.Service.Configurations.getStanza
Endpoint: properties

Fetch a configuration stanza.

Syntax

getStanza: async function(file, stanza)

Parameters

Name Type Description
file String

A configuration file.

stanza String

A configuration stanza.

Return

stanza,.

if exists or null

init

splunkjs.Service.Configurations.init

Constructor for splunkjs.Service.Configurations.

Syntax

init: function(service, namespace)

Parameters

Name Type Description
service splunkjs.Service

A Service instance.

namespace Object

Namespace information:
- owner (string): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- app (string): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- sharing (string): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".

Return

splunkjs.Service.Configurations.

A new splunkjs.Service.Configurations instance.

instantiateEntity

splunkjs.Service.Configurations.instantiateEntity

Creates a local instance of a configuration file.

Syntax

instantiateEntity: function(props)

Parameters

Name Type Description
props Object

The properties for this configuration file.

Return

splunkjs.Service.ConfigurationFile.

A new splunkjs.Service.ConfigurationFile instance.

path

splunkjs.Service.Configurations.path

Retrieves the REST endpoint path for this resource (with no namespace).

Syntax

path: function()

del

splunkjs.Service.Endpoint.del

Performs a relative DELETE request on an endpoint's path, combined with the parameters and a relative path if specified.

Syntax

del: function(relpath, params, callback)

Parameters

Name Type Description
relpath String

A relative path to append to the endpoint path.

params Object

A dictionary of entity-specific parameters to add to the query string.

callback Function

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

Examples

 // Will make a request to {service.prefix}/search/jobs/123456
 var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
 endpoint.delete("", {}, function() { console.log("DELETED"))});

fetch

splunkjs.Service.Collection.fetch

Refreshes the resource by fetching the object from the server and loading it.

Syntax

fetch: function(options, callback)

Parameters

Name Type Description
options Object

A dictionary of collection filtering and pagination options:
- count (integer): The maximum number of items to return.
- offset (integer): The offset of the first item to return.
- search (string): The search query to filter responses.
- sort_dir (string): The direction to sort returned items: “asc” or “desc”.
- sort_key (string): The field to use for sorting (optional).
- sort_mode (string): The collating sequence for sorting returned items: “auto”, “alpha”, “alpha_case”, or “num”.

callback Function

A function to call when the object is retrieved: (err, resource).

fetchAsync

splunkjs.Service.Collection.fetchAsync

It's an asynchronous version of fetch(options, callback) function.

Refreshes the resource by fetching the object from the server and loading it.

Syntax

fetchAsync: async function(options)

Parameters

Name Type Description
options Object

A dictionary of collection filtering and pagination options:
- count (integer): The maximum number of items to return.
- offset (integer): The offset of the first item to return.
- search (string): The search query to filter responses.
- sort_dir (string): The direction to sort returned items: “asc” or “desc”.
- sort_key (string): The field to use for sorting (optional).
- sort_mode (string): The collating sequence for sorting returned items: “auto”, “alpha”, “alpha_case”, or “num”.

get

splunkjs.Service.Endpoint.get

Performs a relative GET request on an endpoint's path, combined with the parameters and a relative path if specified.

Syntax

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

Parameters

Name Type Description
relpath String

A relative path to append to the endpoint path.

params Object

A dictionary of entity-specific parameters to add to the query string.

callback Function

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

Examples

 // Will make a request to {service.prefix}/search/jobs/123456/results?offset=1
 var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
 endpoint.get("results", {offset: 1}, function() { console.log("DONE"))});

item

splunkjs.Service.Collection.item

Returns a specific entity from the collection.

Syntax

item: function(id, namespace)

Parameters

Name Type Description
id String

The name of the entity to retrieve.

namespace Object

Namespace information:
- owner (string): The Splunk username, such as "admin". A value of "nobody" means no specific user. The wildcard value "-", is not acceptable when searching for an entity.
- app (string): The app context for this resource (such as "search"). The wildcard value "-" is unacceptable when searching for an entity.
- sharing (string): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".

Examples

 var apps = service.apps();
 apps.fetch(function(err, apps) {
     var app = apps.item("search");
     console.log("Search App Found: " + !!app);
     // `app` is an Application object.
 });

list

splunkjs.Service.Collection.list

Retrieves a list of all entities in the collection.

Syntax

list: function(callback)

Parameters

Name Type Description
callback Function

A function to call with the list of entities: (err, list).

Examples

 var apps = service.apps();
 apps.fetch(function(err, apps) {
     var appList = apps.list();
     console.log(appList.length);
 });

paging

splunkjs.Service.Collection.paging

Retrieves the author information for this collection.

Syntax

paging: function()

Return

String.

The author.

post

splunkjs.Service.Endpoint.post

Performs a relative POST request on an endpoint's path, combined with the parameters and a relative path if specified.

Syntax

post: function(relpath, params, callback)

Parameters

Name Type Description
relpath String

A relative path to append to the endpoint path.

params Object

A dictionary of entity-specific parameters to add to the body.

callback Function

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

Examples

 // Will make a request to {service.prefix}/search/jobs/123456/control
 var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
 endpoint.post("control", {action: "cancel"}, function() { console.log("CANCELLED"))});

properties

splunkjs.Service.Resource.properties

Retrieves the current properties for this resource.

Syntax

properties: function()

Return

Object.

The properties.

state

splunkjs.Service.Resource.state

Retrieves the current full state (properties and metadata) of this resource.

Syntax

state: function()

Return

Object.

The current full state of this resource.

updated

splunkjs.Service.Collection.updated

Retrieves the updated time for this collection.

Syntax

updated: function()

Return

String.

The updated time.