## Methods

### 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(callback)

#### Parameters

Name | Type | Description
--- | --- | ---
callback | Function | A function to call when the saved search is acknowledged: `(err, savedSearch)`.

#### Examples

     var savedSearch = service.savedSearches().item("MySavedSearch");
     savedSearch.acknowledge(function(err, search) {
         console.log("ACKNOWLEDGED);
     });

#### Source (lib/service.js:1517)

    acknowledge: function(callback) {
        callback = callback || function() {};

        var that = this;
        var req = this.post("acknowledge", {}, function(err) {
            callback(err, that);
        });

        return req;
    },

### 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 callback function.

#### Syntax

dispatch: function(options, callback)

#### 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.
callback | Function | A function to call when the saved search is dispatched: `(err, job, savedSearch)`.

#### Examples

     var savedSearch = service.savedSearches().item("MySavedSearch");
     savedSearch.dispatch({force_dispatch: false}, function(err, job, savedSearch) {
         console.log("Job SID: ", job.sid);
     });

#### Source (lib/service.js:1549)

    dispatch: function(options, callback) {
        if (!callback && utils.isFunction(options)) {
            callback = options;
            options = {};
        }

        callback = callback || function() {};
        options = options || {};

        var that = this;
        var req = this.post("dispatch", options, function(err, response) {
            if (err) {
                callback(err);
                return;
            }

            var sid = response.data.sid;
            var job = new root.Job(that.service, sid, that.namespace);

            callback(null, job, that);
        });

        return req;
    },

### 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(callback)

#### Parameters

Name | Type | Description
--- | --- | ---
callback | Function | A function to call when the history is retrieved: `(err, job, savedSearch)`.

#### Examples

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

#### Source (lib/service.js:1592)

    history: function(callback) {
        callback = callback || function() {};

        var that = this;
        return this.get("history", {}, function(err, response) {
            if (err) {
                callback(err);
                return;
            }

            var jobs = [];
            var data = response.data.entry || [];
            for(var i = 0; i < data.length; i++) {
                var jobData = response.data.entry[i];
                var namespace = utils.namespaceFromProperties(jobData);
                var job = new root.Job(that.service, jobData.name, namespace);

                job._load(jobData);
                jobs.push(job);
            }

            callback(null, jobs, that);
        });
    },

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

#### Source (lib/service.js:1491)

    init: function(service, name, namespace) {
        this.name = name;
        this._super(service, this.path(), namespace);

        this.acknowledge  = utils.bind(this, this.acknowledge);
        this.dispatch     = utils.bind(this, this.dispatch);
        this.history      = utils.bind(this, this.history);
        this.suppressInfo = utils.bind(this, this.suppressInfo);
    },

### path

##### splunkjs.Service.SavedSearch.path

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

#### Syntax

path: function()

#### Source (lib/service.js:1473)

    path: function() {
        return Paths.savedSearches + "/" + encodeURIComponent(this.name);
    },

### suppressInfo

##### splunkjs.Service.SavedSearch.suppressInfo

##### Endpoint: saved/searches/{name}/suppress

Retrieves the suppression state of a saved search.

#### Syntax

suppressInfo: function(callback)

#### Parameters

Name | Type | Description
--- | --- | ---
callback | Function | A function to call when the suppression state is retrieved: `(err, suppressionState, savedSearch)`.

#### Examples

     var savedSearch = service.savedSearches().item("MySavedSearch");
     savedSearch.history(function(err, suppressionState, search) {
         console.log("STATE: ", suppressionState);
     });

#### Source (lib/service.js:1632)

    suppressInfo: function(callback) {
        callback = callback || function() {};

        var that = this;
        return this.get("suppress", {}, function(err, response) {
            callback(err, response.data.entry.content, that);
        });
    },

### 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, callback)

#### 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.
callback | Function | A function to call when the object is updated: `(err, entity)`.

#### Source (lib/service.js:1653)

    update: function(params, callback) {
            params = params || {};

            if (!params.search) {
                var update = this._super;
                var req = this.fetch(function(err, search) {
                    if (err) {
                        callback(err);
                    }
                    else {
                        params.search = search.properties().search;
                        update.call(search, params, function() {
                            if (req.wasAborted) {
                                return; // aborted, so ignore
                            }
                            else {
                                callback.apply(null, arguments);
                            }
                        });
                    }
                });

                return req;
            }
            else {
                return this._super(params, callback);
            }
        }
    });

## Inherited Methods

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

#### Source (lib/service.js:882)

    _load: function(properties) {
        properties = utils.isArray(properties) ? properties[0] : properties;

        // Initialize the properties to
        // empty values
        properties = properties || {
            content: {},
            fields: {},
            acl: {},
            links: {}
        };

        this._super(properties);

        // Take out the entity-specific content
        this._properties = properties.content   || {};
        this._fields     = properties.fields    || this._fields || {};
        this._acl        = properties.acl       || {};
        this._links      = properties.links     || {};
        this._author     = properties.author    || null;
        this._updated    = properties.updated   || null;
        this._published  = properties.published || null;
    },

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

#### Source (lib/service.js:926)

    acl: function() {
        return this._acl;
    },

### author

##### splunkjs.Service.Entity.author

Retrieves the author information for this entity.

#### Syntax

author: function()

#### Return

String.

The author.

#### Source (lib/service.js:949)

    author: function() {
        return this._author;
    },

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

#### Source (lib/service.js:695)

    del: function(relpath, params, callback) {
            var url = this.qualifiedPath;
            // If we have a relative path, we will append it with a preceding
            // slash.
            if (relpath) {
                url = url + "/" + relpath;
            }
            return this.service.del(
                url,
                params,
                callback
            );
        }
    });

### disable

##### splunkjs.Service.Entity.disable

Disables the entity on the server.

#### Syntax

disable: function(callback)

#### Parameters

Name | Type | Description
--- | --- | ---
callback | Function | A function to call when the object is disabled: `(err, entity)`.

#### Source (lib/service.js:1076)

    disable: function(callback) {
        callback = callback || function() {};

        var that = this;
        this.post("disable", {}, function(err, response) {
            if (err) {
                callback(err);
            }
            else {
                callback(null, that);
            }
        });
    },

### enable

##### splunkjs.Service.Entity.enable

Enables the entity on the server.

#### Syntax

enable: function(callback)

#### Parameters

Name | Type | Description
--- | --- | ---
callback | Function | A function to call when the object is enabled: `(err, entity)`.

#### Source (lib/service.js:1098)

    enable: function(callback) {
        callback = callback || function() {};

        var that = this;
        this.post("enable", {}, function(err, response) {
            if (err) {
                callback(err);
            }
            else {
                callback(null, that);
            }
        });
    },

### fetch

##### splunkjs.Service.Entity.fetch

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

#### Syntax

fetch: function(options, callback)

#### 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”.
callback | Function | A function to call when the object is retrieved: `(err, resource)`.

#### Source (lib/service.js:990)

    fetch: function(options, callback) {
        if (!callback && utils.isFunction(options)) {
            callback = options;
            options = {};
        }
        callback = callback || function() {};

        options = options || {};

        var that = this;
        return this.get("", options, function(err, response) {
            if (err) {
                callback(err);
            }
            else {
                that._load(response.data ? response.data.entry : null);
                callback(null, that);
            }
        });
    },

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

#### Source (lib/service.js:832)

    fetchOnUpdate: false,

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

#### Source (lib/service.js:914)

    fields: function() {
        return this._fields;
    },

### 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)

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

#### Source (lib/service.js:631)

    get: function(relpath, params, callback) {
        var url = this.qualifiedPath;
        // If we have a relative path, we will append it with a preceding
        // slash.
        if (relpath) {
            url = url + "/" + relpath;
        }
        return this.service.get(
            url,
            params,
            callback
        );
    },

### links

##### splunkjs.Service.Entity.links

Retrieves the links information for this entity, which is the URI of the entity relative to the management port of a Splunk instance.

#### Syntax

links: function()

#### Return

Object.

The links information.

#### Source (lib/service.js:938)

    links: function() {
        return this._links;
    },

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

#### Source (lib/service.js:663)

    post: function(relpath, params, callback) {
        var url = this.qualifiedPath;
        // If we have a relative path, we will append it with a preceding
        // slash.
        if (relpath) {
            url = url + "/" + relpath;
        }
        return this.service.post(
            url,
            params,
            callback
        );
    },

### properties

##### splunkjs.Service.Resource.properties

Retrieves the current properties for this resource.

#### Syntax

properties: function()

#### Return

Object.

The properties.

#### Source (lib/service.js:797)

    properties: function() {
        return this._properties;
    },

### published

##### splunkjs.Service.Entity.published

Retrieves the published time for this entity.

#### Syntax

published: function()

#### Return

String.

The published time.

#### Source (lib/service.js:971)

    published: function() {
        return this._published;
    },

### reload

##### splunkjs.Service.Entity.reload

Reloads the entity on the server.

#### Syntax

reload: function(callback)

#### Parameters

Name | Type | Description
--- | --- | ---
callback | Function | A function to call when the object is reloaded: `(err, entity)`.

#### Source (lib/service.js:1120)

    reload: function(callback) {
            callback = callback || function() {};

            var that = this;
            this.post("_reload", {}, function(err, response) {
                if (err) {
                    callback(err);
                }
                else {
                    callback(null, that);
                }
            });
        }
    });

### remove

##### splunkjs.Service.Entity.remove

Deletes the entity from the server.

#### Syntax

remove: function(callback)

#### Parameters

Name | Type | Description
--- | --- | ---
callback | Function | A function to call when the object is deleted: `(err)`.

#### Source (lib/service.js:1019)

    remove: function(callback) {
        callback = callback || function() {};

        var that = this;
        return this.del("", {}, function(err) {
            callback(err);
        });
    },

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

#### Source (lib/service.js:808)

    state: function() {
            return this._state;
        }
    });

### updated

##### splunkjs.Service.Entity.updated

Retrieves the updated time for this entity.

#### Syntax

updated: function()

#### Return

String.

The updated time.

#### Source (lib/service.js:960)

    updated: function() {
        return this._updated;
    },