init

splunkjs.Service.Indexes.init

Constructor for splunkjs.Service.Indexes

Syntax

init: function(service, namespace)

Parameters

Name Type Description
service splunkjs.Service

A service instance

namespace Object

Namespace information (owner, app, sharing)

Return

splunkjs.Service.Indexes. A splunkjs.Service.Indexes instance

create

splunkjs.Service.Indexes.create
Endpoint: data/indexes

Create an index

Create an index with the given name and parameters

Syntax

create: function(name, params, callback)

Parameters

Name Type Description
name String

A name for this index

params Object

A dictionary of properties to create the entity with.

callback Function

A callback with the created entity: (err, createdIndex)

Examples

 var indexes = service.indexes();
 indexes.create("NewIndex", {assureUTF8: true}, function(err, newIndex) {
     console.log("CREATED");
 });

instantiateEntity

splunkjs.Service.Indexes.instantiateEntity

Create a local instance of an entity

Syntax

instantiateEntity: function(props)

Parameters

Name Type Description
props Object

The properties for this entity

Return

splunkjs.Service.Index. A splunkjs.Service.Index instance

path

splunkjs.Service.Indexes.path

REST path for this resource (with no namespace)

Syntax

path: function()

paging

splunkjs.Service.Collection.paging

Retrieve the author information for this collection

Syntax

paging: function()

Return

String. The author for this collection

list

splunkjs.Service.Collection.list

Retrieve a list of all entities in the collection

Return the list of all the entities in this collection.

Syntax

list: function(callback)

Parameters

Name Type Description
callback Function

A callback 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);
 });

fetchOnEntityCreation

splunkjs.Service.Collection.fetchOnEntityCreation

Whether or not to call fetch() after an entity is created. By default we don't fetch the entity, as the endpoint will return (echo) the created entity

item

splunkjs.Service.Collection.item

Get a specific entity.

Return a specific entity given its name 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, app, sharing)

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.
 });

fetch

splunkjs.Service.Collection.fetch

Refresh the resource

This will unconditionally fetch the object from the server and load it up.

Syntax

fetch: function(options, callback)

Parameters

Name Type Description
options Object

Dictionary of collection filtering and pagination options

callback Function

A callback when the object is retrieved: (err, resource)

updated

splunkjs.Service.Collection.updated

Retrieve the updated time for this collection

Syntax

updated: function()

Return

String. The updated time for this collection

state

splunkjs.Service.Resource.state

Retrieve the state for this resource

This will retrieve the current full state for this resource.

Syntax

state: function()

Return

Object. The full state for this resource

properties

splunkjs.Service.Resource.properties

Retrieve the properties for this resource

This will retrieve the current properties for this resource.

Syntax

properties: function()

Return

Object. The properties for this resource

del

splunkjs.Service.Endpoint.del

Perform a relative DELETE request

Perform a relative DELETE request on this 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 at the end of the path

params Object

A dictionary of parameters to add to the query string

callback Function

A callback to be invoked 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"))});

post

splunkjs.Service.Endpoint.post

Perform a relative POST request

Perform a relative POST request on this 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 at the end of the path

params Object

A dictionary of parameters to add to the body

callback Function

A callback to be invoked 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"))});

get

splunkjs.Service.Endpoint.get

Perform a relative GET request

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

Syntax

get: function(relpath, params, callback)

Parameters

Name Type Description
relpath String

A relative path to append at the end of the path

params Object

A dictionary of parameters to add to the query string

callback Function

A callback to be invoked 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"))});