cancel

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

Cancels a search job.

Syntax

cancel: function (response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 await job.cancel();
 console.log("CANCELLED");

disablePreview

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

Disables preview generation for a search job.

Syntax

disablePreview: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let res = await job.disablePreview();
 console.log("PREVIEW DISABLED");

enablePreview

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

Enables preview generation for a search job.

Syntax

enablePreview: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let res = await job.disablePreview();
 console.log("PREVIEW ENABLED");

events

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

Returns the events of a search job with given parameters.

Syntax

events: function(params, response_timeout)

Parameters

Name Type Description
params Object

The parameters for retrieving events. For a list of available parameters, see the GET search/jobs/{search_id}/events endpoint in the REST API documentation.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let events;
 [events, job] = await job.events({count: 10});
 console.log("Fields: ", events.fields);

finalize

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

Finalizes a search job.

Syntax

finalize: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let res = await job.finalize();
 console.log("JOB FINALIZED");

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

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

A new splunkjs.Service.Job instance.

iterator

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

Returns an iterator over this search job's events or results.

Syntax

iterator: function(type, params)

Parameters

Name Type Description
type String

One of {"events", "preview", "results"}.

params Object

A dictionary of optional parameters:
- pagesize (integer): The number of items to return on each request. Defaults to as many as possible.

path

splunkjs.Service.Job.path

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

Syntax

path: function ()

pause

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

Pauses a search job.

Syntax

pause: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let res = await job.pause();
 console.log("JOB PAUSED");

preview

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

Gets the preview results for a search job with given parameters.

Syntax

preview: function(params, response_timeout)

Parameters

Name Type Description
params Object

The parameters for retrieving preview results. For a list of available parameters, see the GET search/jobs/{search_id}/results_preview endpoint in the REST API documentation.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let results;
 [results, job] = await job.preview({count: 10});
 console.log("Fields: ", results.fields);

results

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

Gets the results for a search job with given parameters.

The response can be undefined if the job is not yet done. To avoid this, use the Job.track() method to wait until the job is complete prior to fetching the results with this method.

Syntax

results: function(params, response_timeout)

Parameters

Name Type Description
params Object

The parameters for retrieving search results. For a list of available parameters, see the GET search/jobs/{search_id}/results endpoint in the REST API documentation.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let results;
 [results, job] = await job.results({count: 10});
 console.log("Fields: ", results.results);

searchlog

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

Gets the search log for this search job.

Syntax

searchlog: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let searchlog;
 [searchlog, job] = await job.searchlog();
 console.log(searchlog);

setPriority

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

Sets the priority for this search job.

Syntax

setPriority: function(value, response_timeout)

Parameters

Name Type Description
value Number

The priority (an integer between 1-10). A higher value means a higher priority.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let res = await job.setPriority(6);
 console.log("JOB PRIORITY SET");

setTTL

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

Sets the time to live (TTL) for the search job, which is the time before the search job expires after it has been completed and is still available.

Syntax

setTTL: function(value, response_timeout)

Parameters

Name Type Description
value Number

The time to live, in seconds.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let res = await job.setTTL(1000);
 console.log("JOB TTL SET");

summary

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

Gets the summary for this search job with the given parameters.

Syntax

summary: function(params, response_timeout)

Parameters

Name Type Description
params Object

The parameters for retrieving the summary. For a list of available parameters, see the GET search/jobs/{search_id}/summary endpoint in the REST API documentation.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let summary;
 [summary, job] = await job.summary({top_count: 5});
 console.log("Summary: ", summary);

timeline

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

Gets the timeline for this search job.

Syntax

timeline: function(params, response_timeout)

Parameters

Name Type Description
params Object

The parameters for retrieving the timeline. For a list of available parameters, see the GET search/jobs/{search_id}/timeline endpoint in the REST API documentation.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let timeline;
 [timeline, job] = await job.timeline({time_format: "%c"});
 console.log("Timeline: ", timeline);

touch

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

Touches a search job, which means extending the expiration time of the search to now plus the time to live (TTL).

Syntax

touch: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 await job.touch();
 console.log("JOB TOUCHED");

track

splunkjs.Service.Job.track

Starts polling the status of this search job, and fires callbacks upon each status change.

Syntax

track: async function(options, callbacks)

Parameters

Name Type Description
options Object

A dictionary of optional parameters:
- period (integer): The number of milliseconds to wait between each poll. Defaults to 500.

callbacks Object,Function

A dictionary of optional callbacks:
- ready: A function (job) invoked when the job's properties first become available.
- progress: A function (job) invoked whenever new job properties are available.
- done: A function (job) invoked if the job completes successfully. No further polling is done.
- failed: A function (job) invoked if the job fails executing on the server. No further polling is done.
- error: A function (err) invoked if an error occurs while polling. No further polling is done.
Or, if a function (job), equivalent to passing it as a done callback.

unpause

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

Resumes a search job.

Syntax

unpause: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let job = service.jobs().item("mysid");
 let res = await job.unpause();
 console.log("JOB UNPAUSED");

_load

splunkjs.Service.Entity._load

Loads the entity and stores the properties.

Syntax

_load: function(properties)

Parameters

Name Type Description
properties Object

The properties for this entity.

acl

splunkjs.Service.Entity.acl

Retrieves the access control list (ACL) information for this entity, which contains the permissions for accessing the entity.

Syntax

acl: function()

Return

Object.

The ACL.

acl_update

splunkjs.Service.Entity.acl_update

Update the access control list (ACL) information for this entity, which contains the permissions for accessing the entity.

Syntax

acl_update: function(options, response_timeout)

Parameters

Name Type Description
options Object

Additional entity-specific arguments (required):
- owner (string): The Splunk username, such as "admin". A value of "nobody" means no specific user (required).
- sharing (string): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system" (required).

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

 let savedSearches = svc.savedSearches({ owner: "owner-name", app: "app-name"});
 let search = await searches.create({ search: "search * | head 1", name: "acl_test" });
 search = await search.acl_update({sharing:"app",owner:"admin","perms.read":"admin"});

author

splunkjs.Service.Entity.author

Retrieves the author information for this entity.

Syntax

author: function()

Return

String.

The author.

createUrl

splunkjs.Service.Endpoint.createUrl

Create the URL for the get and post methods This is to allow v1 fallback if the service was instantiated with v2+ and a relpath v1 was provided

Syntax

createUrl: function (qualifiedPath, relpath)

Parameters

Name Type Description
qualifiedPath String

A fully-qualified relative endpoint path (for example, "/services/search/jobs").

relpath String

A relative path to append to the endpoint path.

Examples

 // Parameters
 v2 example:
     qualifiedPath = "/servicesNS/admin/foo/search/v2/jobs/id5_1649796951725"
     qualifiedPath = "/services/search/v2/jobs/id5_1649796951725"
     relpath = "search/v2/jobs/id5_1649796951725/events"
     relpath = "events"
 // Step 1:
 Specifically for splunkjs.Service.Job method, the service endpoint may be provided
 Retrieve the service prefix and suffix
     servicesNS:
         - servicePrefix = "/servicesNS/admin/foo"
         - serviceSuffix = "foo/v2/jobs/id5_1649796951725"
     services:
         - servicePrefix = "/services"
         - serviceSuffix = "search/v2/jobs/id5_1649796951725"
 // Step 2:
 Retrieve Service API version
 If version can't be detected, default to 1 (v1)
     qualifiedPathVersion = 2
 // Step 3:
 Retrieve relpath version
 If version can't be detected, default to 1 (v1)
     relpath = "search/v2/jobs/id5_1649796951725/events"
       => relPathVersion = 2
 Check if relpath is a one segment relative path, if so, set to -1
     relpath = "events"
       => relPathVersion = -1
 // Step 4:
 Create the URL based on set criteria
     url = "/servicesNS/admin/foo/search/v2/jobs/id5_1649796951725/events"
     url = "/services/search/v2/jobs/id5_1649796951725/events"

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, response_timeout)

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.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

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

disable

splunkjs.Service.Entity.disable

Disables the entity on the server.

Syntax

disable: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

enable

splunkjs.Service.Entity.enable

Enables the entity on the server.

Syntax

enable: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

fetch

splunkjs.Service.Entity.fetch

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

Syntax

fetch: function(options, response_timeout)

Parameters

Name Type Description
options Object

An optional 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”.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

fetchOnUpdate

splunkjs.Service.Entity.fetchOnUpdate

A static property that indicates whether to call fetch after an update to get the updated entity. By default, the entity is not fetched because the endpoint returns (echoes) the updated entity.

fields

splunkjs.Service.Entity.fields

Retrieves the fields information for this entity, indicating which fields are wildcards, required, and optional.

Syntax

fields: function()

Return

Object.

The fields information.

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, response_timeout, 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.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

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

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, response_timeout)

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.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

Examples

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

properties

splunkjs.Service.Resource.properties

Retrieves the current properties for this resource.

Syntax

properties: function()

Return

Object.

The properties.

published

splunkjs.Service.Entity.published

Retrieves the published time for this entity.

Syntax

published: function()

Return

String.

The published time.

reload

splunkjs.Service.Entity.reload

Reloads the entity on the server.

Syntax

reload: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

remove

splunkjs.Service.Entity.remove

Deletes the entity from the server.

Syntax

remove: function(response_timeout)

Parameters

Name Type Description
response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

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.

update

splunkjs.Service.Entity.update

Updates the entity on the server.

Syntax

update: function(props, response_timeout)

Parameters

Name Type Description
props Object

The properties to update the object with.

response_timeout Number

A timeout period for aborting a request in milisecs (0 means no timeout).

updated

splunkjs.Service.Entity.updated

Retrieves the updated time for this entity.

Syntax

updated: function()

Return

String.

The updated time.