Acknowledges the suppression of the alerts from a saved search and resumes alerting.
Acknowledges the suppression of the alerts from a saved search and resumes alerting.
Name | Type | Description |
---|---|---|
callback | Function | A function to call when the saved search is acknowledged: |
var savedSearch = service.savedSearches().item("MySavedSearch");
savedSearch.acknowledge(function(err, search) {
console.log("ACKNOWLEDGED");
});
acknowledge: function(callback) {
callback = callback || function() {};
var that = this;
var req = this.post("acknowledge", {}, function(err) {
callback(err, that);
});
return req;
},
Gets the count of triggered alerts for this savedSearch, defaulting to 0 when undefined.
The count of triggered alerts.
var savedSearch = service.savedSearches().item("MySavedSearch");
var alertCount = savedSearch.alertCount();
alertCount: function() {
return parseInt(this.properties().triggered_alert_count, 10) || 0;
},
Dispatches a saved search, which creates a search job and returns a splunkjs.Service.Job
instance in the callback function.
Name | Type | Description |
---|---|---|
options | Object | The options for dispatching this saved search: |
callback | Function | A function to call when the saved search is dispatched: |
var savedSearch = service.savedSearches().item("MySavedSearch");
savedSearch.dispatch({force_dispatch: false}, function(err, job, savedSearch) {
console.log("Job SID: ", job.sid);
});
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;
},
Gets the splunkjs.Service.FiredAlertGroup
for firedAlerts associated with this saved search.
An AlertGroup object with the
same name as this SavedSearch object.
var alerts = service.firedAlertGroups().item("MySavedSearch");
firedAlertGroup: function() {
return new root.FiredAlertGroup(this.service, this.name);
},
Retrieves the job history for a saved search, which is a list of splunkjs.Service.Job
instances.
Name | Type | Description |
---|---|---|
options | Object | Options for retrieving history. For a full list, see the Pagination and Filtering options in the REST API documentation. |
callback | Function | A function to call when the history is retrieved: |
var savedSearch = service.savedSearches().item("MySavedSearch");
savedSearch.history({count: 10}, function(err, jobs, search) {
for(var i = 0; i < jobs.length; i++) {
console.log("Job", i, ":", jobs[i].sid);
}
});
history: function(options, callback) {
if (!callback && utils.isFunction(options)) {
callback = options;
options = {};
}
callback = callback || function() {};
options = options || {};
var that = this;
return this.get("history", options, 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);
});
},
Constructor for splunkjs.Service.SavedSearch
.
Name | Type | Description |
---|---|---|
service | splunkjs.Service | A |
name | String | The name for the new saved search. |
namespace | Object | Namespace information: |
A new splunkjs.Service.SavedSearch
instance.
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);
},
Retrieves the REST endpoint path for this resource (with no namespace).
path: function() {
return Paths.savedSearches + "/" + encodeURIComponent(this.name);
},
Retrieves the suppression state of a saved search.
Name | Type | Description |
---|---|---|
callback | Function | A function to call when the suppression state is retrieved: |
var savedSearch = service.savedSearches().item("MySavedSearch");
savedSearch.history(function(err, suppressionState, search) {
console.log("STATE: ", suppressionState);
});
suppressInfo: function(callback) {
callback = callback || function() {};
var that = this;
return this.get("suppress", {}, function(err, response) {
callback(err, response.data.entry.content, that);
});
},
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.
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: |
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);
}
}
});
Loads the entity and stores the properties.
Name | Type | Description |
---|---|---|
properties | Object | The properties for this entity. |
_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;
},
Retrieves the access control list (ACL) information for this entity, which contains the permissions for accessing the entity.
The ACL.
acl: function() {
return this._acl;
},
Retrieves the author information for this entity.
The author.
author: function() {
return this._author;
},
Performs a relative DELETE request on an endpoint's path, combined with the parameters and a relative path if specified.
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: |
// 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"))});
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
);
}
});
Disables the entity on the server.
Name | Type | Description |
---|---|---|
callback | Function | A function to call when the object is disabled: |
disable: function(callback) {
callback = callback || function() {};
var that = this;
this.post("disable", {}, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, that);
}
});
},
Enables the entity on the server.
Name | Type | Description |
---|---|---|
callback | Function | A function to call when the object is enabled: |
enable: function(callback) {
callback = callback || function() {};
var that = this;
this.post("enable", {}, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, that);
}
});
},
Refreshes the entity by fetching the object from the server and loading it.
Name | Type | Description |
---|---|---|
options | Object | An optional dictionary of collection filtering and pagination options: |
callback | Function | A function to call when the object is retrieved: |
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);
}
});
},
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.
fetchOnUpdate: false,
Retrieves the fields information for this entity, indicating which fields are wildcards, required, and optional.
The fields information.
fields: function() {
return this._fields;
},
Performs a relative GET request on an endpoint's path, combined with the parameters and a relative path if specified.
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: |
// 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"))});
get: function(relpath, params, callback, isAsync) {
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,
isAsync
);
},
Retrieves the links information for this entity, which is the URI of the entity relative to the management port of a Splunk instance.
The links information.
links: function() {
return this._links;
},
Performs a relative POST request on an endpoint's path, combined with the parameters and a relative path if specified.
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: |
// 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"))});
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
);
},
Retrieves the current properties for this resource.
The properties.
properties: function() {
return this._properties;
},
Retrieves the published time for this entity.
The published time.
published: function() {
return this._published;
},
Reloads the entity on the server.
Name | Type | Description |
---|---|---|
callback | Function | A function to call when the object is reloaded: |
reload: function(callback) {
callback = callback || function() {};
var that = this;
this.post("_reload", {}, function(err, response) {
if (err) {
callback(err);
}
else {
callback(null, that);
}
});
}
});
Deletes the entity from the server.
Name | Type | Description |
---|---|---|
callback | Function | A function to call when the object is deleted: |
remove: function(callback) {
callback = callback || function() {};
var that = this;
return this.del("", {}, function(err) {
callback(err);
});
},
Retrieves the current full state (properties and metadata) of this resource.
The current full state of this resource.
state: function() {
return this._state;
}
});
Retrieves the updated time for this entity.
The updated time.
updated: function() {
return this._updated;
},