init

splunkjs.Service.Job.init

Constructor for splunkjs.Service.Job

Syntax

init: function(service, sid, namespace)

Parameters

Name Type Description
service splunkjs.Service

A service instance

sid String

The search ID for this search

namespace Object

Namespace information (owner, app, sharing)

Return

splunkjs.Service.Job. A splunkjs.Service.Job instance

preview

splunkjs.Service.Job.preview
Endpoint: search/jobs/{search_id}/results_preview

Get the preview results for a job

Get the preview results for a job with given parameters.

Syntax

preview: function(params, callback)

Parameters

Name Type Description
params Object

Parameters for results preview fetching

callback Function

A callback with when the preview results are fetched: (err, results, job)

Examples

 var job = service.jobs().item("mysid");
 job.preview({count: 10}, function(err, results, job) {
     console.log("Fields: ", results.fields);
 });

unpause

splunkjs.Service.Job.unpause
Endpoint: search/jobs/{search_id}/control

Unpause a search job

Syntax

unpause: function(callback)

Parameters

Name Type Description
callback Function

A callback with this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.unpause(function(err) {
     console.log("JOB UNPAUSED");
 });

searchlog

splunkjs.Service.Job.searchlog
Endpoint: search/jobs/{search_id}/search.log

Get the search log for this job.

Syntax

searchlog: function(callback)

Parameters

Name Type Description
callback Function

A callback with the searchlog and job: (err, searchlog, job)

Examples

 var job = service.jobs().item("mysid");
 job.searchlog(function(err, searchlog, job) {
     console.log(searchlog);
 });

path

splunkjs.Service.Job.path

REST path for this resource (with no namespace)

Syntax

path: function()

setPriority

splunkjs.Service.Job.setPriority
Endpoint: search/jobs/{search_id}/control

Set the job priority

Syntax

setPriority: function(value, callback)

Parameters

Name Type Description
value Number

Value for the new priority

callback Function

A callback with the this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.setPriority(6, function(err, job) {
     console.log("JOB PRIORITY SET");
 });

disablePreview

splunkjs.Service.Job.disablePreview
Endpoint: search/jobs/{search_id}/control

Disable preview for a job

Syntax

disablePreview: function(callback)

Parameters

Name Type Description
callback Function

A callback with the this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.disablePreview(function(err, job) {
     console.log("PREVIEW DISABLED");
 });

events

splunkjs.Service.Job.events
Endpoint: search/jobs/{search_id}/events

Get job events

Get the events for a job with given parameters.

Syntax

events: function(params, callback)

Parameters

Name Type Description
params Object

Parameters for event fetching

callback Function

A callback with when the events are fetched: (err, events, job)

Examples

 var job = service.jobs().item("mysid");
 job.events({count: 10}, function(err, events, job) {
     console.log("Fields: ", events.fields);
 });

touch

splunkjs.Service.Job.touch
Endpoint: search/jobs/{search_id}/control

Touch a job

Syntax

touch: function(callback)

Parameters

Name Type Description
callback Function

A callback with this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.touch(function(err) {
     console.log("JOB TOUCHED");
 });

timeline

splunkjs.Service.Job.timeline
Endpoint: search/jobs/{search_id}/timeline

Get the timeline for this job

Syntax

timeline: function(params, callback)

Parameters

Name Type Description
params Object

Parameters for timeline fetching

callback Function

A callback with with the timeline and this job: (err, timeline, job)

Examples

 var job = service.jobs().item("mysid");
 job.timeline({time_format: "%c"}, function(err, job, timeline) {
     console.log("Timeline: ", timeline);
 });

summary

splunkjs.Service.Job.summary
Endpoint: search/jobs/{search_id}/summmary

Get the summary for this job

Get the job summary for this job with the given parameters

Syntax

summary: function(params, callback)

Parameters

Name Type Description
params Object

Parameters for summary fetching

callback Function

A callback with with the summary and this job: (err, summary, job)

Examples

 var job = service.jobs().item("mysid");
 job.summary({top_count: 5}, function(err, summary, job) {
     console.log("Summary: ", summary);
 });

setTTL

splunkjs.Service.Job.setTTL
Endpoint: search/jobs/{search_id}/control

Set the job TTL

Syntax

setTTL: function(value, callback)

Parameters

Name Type Description
value Number

Value for the new priority

callback Function

A callback with the this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.setTTL(1000, function(err, job) {
     console.log("JOB TTL SET");
 });

finalize

splunkjs.Service.Job.finalize
Endpoint: search/jobs/{search_id}/control

Finalize a search job

Syntax

finalize: function(callback)

Parameters

Name Type Description
callback Function

A callback with the this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.finalize(function(err, job) {
     console.log("JOB FINALIZED");
 });

enablePreview

splunkjs.Service.Job.enablePreview
Endpoint: search/jobs/{search_id}/control

Enable preview for a job

Syntax

enablePreview: function(callback)

Parameters

Name Type Description
callback Function

A callback with the this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.disablePreview(function(err, job) {
     console.log("PREVIEW ENABLED");
 });

results

splunkjs.Service.Job.results
Endpoint: search/jobs/{search_id}/results

Get job results

Get the results for a job with given parameters.

Syntax

results: function(params, callback)

Parameters

Name Type Description
params Object

Parameters for results fetching

callback Function

A callback with when the results are fetched: (err, results, job)

Examples

 var job = service.jobs().item("mysid");
 job.results({count: 10}, function(err, results, job) {
     console.log("Fields: ", results.results);
 });

cancel

splunkjs.Service.Job.cancel
Endpoint: search/jobs/{search_id}/control

Cancel a search job

Syntax

cancel: function(callback)

Parameters

Name Type Description
callback Function

A callback when the search is done: (err)

Examples

 var job = service.jobs().item("mysid");
 job.cancel(function(err) {
     console.log("CANCELLED");
 });

pause

splunkjs.Service.Job.pause
Endpoint: search/jobs/{search_id}/control

Pause a search job

Syntax

pause: function(callback)

Parameters

Name Type Description
callback Function

A callback with the this job: (err, job)

Examples

 var job = service.jobs().item("mysid");
 job.pause(function(err, job) {
     console.log("JOB PAUSED");
 });

updated

splunkjs.Service.Entity.updated

Retrieve the updated time for this entity

Syntax

updated: function()

Return

String. The updated time for this entity

reload

splunkjs.Service.Entity.reload

Reload the entity

This will reload the entity on the server.

Syntax

reload: function(callback)

Parameters

Name Type Description
callback Function

A callback when the object is reloaded: (err, entity)

fetch

splunkjs.Service.Entity.fetch

Refresh the resource

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

Syntax

fetch: function(options, callback)

Parameters

Name Type Description
options Object

Optional dictionary of collection filtering and pagination options

callback Function

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

fetchOnUpdate

splunkjs.Service.Entity.fetchOnUpdate

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

fields

splunkjs.Service.Entity.fields

Retrieve the fields information for this entity

Syntax

fields: function()

Return

Object. The fields for this entity

enable

splunkjs.Service.Entity.enable

Enable the entity

This will enable the entity on the server.

Syntax

enable: function(callback)

Parameters

Name Type Description
callback Function

A callback when the object is enabled: (err, entity)

disable

splunkjs.Service.Entity.disable

Disable the entity

This will disable the entity on the server.

Syntax

disable: function(callback)

Parameters

Name Type Description
callback Function

A callback when the object is disabled: (err, entity)

update

splunkjs.Service.Entity.update

Update the entity

This will update the entity on the server.

Syntax

update: function(props, callback)

Parameters

Name Type Description
props Object

Properties to be updated the object with.

callback Function

A callback when the object is updated: (err, entity)

remove

splunkjs.Service.Entity.remove

Delete the entity

This will tell the server to delete this entity.

Syntax

remove: function(callback)

Parameters

Name Type Description
callback Function

A callback when the object is deleted: (err)

acl

splunkjs.Service.Entity.acl

Retrieve the ACL information for this entity

Syntax

acl: function()

Return

Object. The ACL for this entity

published

splunkjs.Service.Entity.published

Retrieve the published time for this entity

Syntax

published: function()

Return

String. The published time for this entity

_load

splunkjs.Service.Entity._load

Load the resource, also storing the properties.

Syntax

_load: function(properties)

Parameters

Name Type Description
properties Object

The properties for this resource

author

splunkjs.Service.Entity.author

Retrieve the author information for this entity

Syntax

author: function()

Return

String. The author for this entity

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