_load

splunkjs.Service.Resource._load

Loads the resource and stores the properties.

Syntax

_load: function(properties)

Parameters

Name Type Description
properties Object

The properties for this resource.

fetch

splunkjs.Service.Resource.fetch

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

Syntax

fetch: function()

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 (for example, "search/jobs").

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

A new splunkjs.Service.Resource instance.

path

splunkjs.Service.Resource.path

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

Syntax

path: function()

properties

splunkjs.Service.Resource.properties

Retrieves the current properties for this resource.

Syntax

properties: function()

Return

Object.

The properties.

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.

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

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