init

splunkjs.Service.Resource.init

Constructor for splunkjs.Service.Resource

Syntax

init: function(service, path, namespace)

Parameters

Name Type Description
service splunkjs.Service

A service instance

path String

A relative endpoint path (e.g. 'search/jobs')

namespace Object

Namespace information for this resource (owner, app, sharing)

Return

splunkjs.Service.Resource. A splunkjs.Service.Resource instance

state

splunkjs.Service.Resource.state

Retrieve the state for this resource

This will retrieve the current full state for this resource.

Syntax

state: function()

Return

Object. The full state for this resource

properties

splunkjs.Service.Resource.properties

Retrieve the properties for this resource

This will retrieve the current properties for this resource.

Syntax

properties: function()

Return

Object. The properties for this resource

fetch

splunkjs.Service.Resource.fetch

Refresh the resource

This will fetch the object from the server and load it up.

Syntax

fetch: function(callback)

Parameters

Name Type Description
callback Function

A callback when the object is retrieved: (err, resource)

_load

splunkjs.Service.Resource._load

Load the resource, also storing the properties.

Syntax

_load: function(properties)

Parameters

Name Type Description
properties Object

The properties for this resource

path

splunkjs.Service.Resource.path

REST path for this resource (with no namespace)

Syntax

path: function()

del

splunkjs.Service.Endpoint.del

Perform a relative DELETE request

Perform a relative DELETE request on this 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 at the end of the path

params Object

A dictionary of parameters to add to the query string

callback Function

A callback to be invoked 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"))});

post

splunkjs.Service.Endpoint.post

Perform a relative POST request

Perform a relative POST request on this 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 at the end of the path

params Object

A dictionary of parameters to add to the body

callback Function

A callback to be invoked 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"))});

get

splunkjs.Service.Endpoint.get

Perform a relative GET request

Perform a relative GET request on this 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 at the end of the path

params Object

A dictionary of parameters to add to the query string

callback Function

A callback to be invoked 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"))});