Performs a relative DELETE request on an endpoint's path, combined with the parameters and a relative path if specified.
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
);
}
});
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
);
},
Constructor for splunkjs.Service.Endpoint
.
Name | Type | Description |
---|---|---|
service | splunkjs.Service | A |
qualifiedPath | String | A fully-qualified relative endpoint path (for example, "/services/search/jobs"). |
A new splunkjs.Service.Endpoint
instance.
init: function(service, qualifiedPath) {
if (!service) {
throw new Error("Passed in a null Service.");
}
if (!qualifiedPath) {
throw new Error("Passed in an empty path.");
}
this.service = service;
this.qualifiedPath = qualifiedPath;
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.get = utils.bind(this, this.get);
this.post = utils.bind(this, this.post);
this.del = utils.bind(this, this.del);
},
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
);
},