acknowledge

splunkjs.Service.SavedSearch.acknowledge
Endpoint: saved/searches/{name}/acknowledge

Acknowledges the suppression of the alerts from a saved search and resumes alerting.

Syntax

acknowledge: 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 savedSearch = service.savedSearches().item("MySavedSearch");
 let search = await savedSearch.acknowledge();
 console.log("ACKNOWLEDGED");

alertCount

splunkjs.Service.SavedSearch.alertCount

Gets the count of triggered alerts for this savedSearch, defaulting to 0 when undefined.

Syntax

alertCount: function()

Return

Number.

The count of triggered alerts.

Examples

 let savedSearch = service.savedSearches().item("MySavedSearch");
 let alertCount = savedSearch.alertCount();

dispatch

splunkjs.Service.SavedSearch.dispatch
Endpoint: saved/searches/{name}/dispatch

Dispatches a saved search, which creates a search job and returns a splunkjs.Service.Job instance in the response array.

Syntax

dispatch: function(options, response_timeout)

Parameters

Name Type Description
options Object

The options for dispatching this saved search:
- dispatch.now (string): The time that is used to dispatch the search as though the specified time were the current time.
- dispatch.* (string): Overwrites the value of the search field specified in *.
- trigger_actions (boolean): Indicates whether to trigger alert actions.
- force_dispatch (boolean): Indicates whether to start a new search if another instance of this search is already running.

response_timeout Number

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

Examples

 let savedSearch = service.savedSearches().item("MySavedSearch");
 let [job, savedSearch] = await savedSearch.dispatch({force_dispatch: false});
 console.log("Job SID: ", job.sid);

firedAlertGroup

splunkjs.Service.SavedSearch.firedAlertGroup

Gets the splunkjs.Service.FiredAlertGroup for firedAlerts associated with this saved search.

Syntax

firedAlertGroup: function()

Return

splunkjs.Service.FiredAlertGroup.

An AlertGroup object with the
same name as this SavedSearch object.

Examples

 let alerts = service.firedAlertGroups().item("MySavedSearch");

history

splunkjs.Service.SavedSearch.history
Endpoint: saved/searches/{name}/history

Retrieves the job history for a saved search, which is a list of splunkjs.Service.Job instances.

Syntax

history: function(options, response_timeout)

Parameters

Name Type Description
options Object

Options for retrieving history. For a full list, see the Pagination and Filtering options in the REST API documentation.

response_timeout Number

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

Examples

 let savedSearch = service.savedSearches().item("MySavedSearch");
 let [jobs, search] = await savedSearch.history({count: 10});
 for(let i = 0; i < jobs.length; i++) {
     console.log("Job", i, ":", jobs[i].sid);
 }

init

splunkjs.Service.SavedSearch.init

Constructor for splunkjs.Service.SavedSearch.

Syntax

init: function(service, name, namespace)

Parameters

Name Type Description
service splunkjs.Service

A Service instance.

name String

The name for the new saved search.

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

A new splunkjs.Service.SavedSearch instance.

path

splunkjs.Service.SavedSearch.path

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

Syntax

path: function()

suppressInfo

splunkjs.Service.SavedSearch.suppressInfo
Endpoint: saved/searches/{name}/suppress

Retrieves the suppression state of a saved search.

Syntax

suppressInfo: 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 savedSearch = service.savedSearches().item("MySavedSearch");
 let [suppressionState, search] = await savedSearch.history();
 console.log("STATE: ", suppressionState);

update

splunkjs.Service.SavedSearch.update

Updates the saved search on the server.

Note: The search query is required, even when it isn't being modified. If you don't provide it, this method will fetch the search string from the server or from the local cache.

Syntax

update: function(params, response_timeout)

Parameters

Name Type Description
props Object

The properties to update the saved search with. For a list of available parameters, see Saved search parameters on Splunk Developer Portal.

response_timeout Number

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

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

updated

splunkjs.Service.Entity.updated

Retrieves the updated time for this entity.

Syntax

updated: function()

Return

String.

The updated time.