## Methods

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

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

    _load: function(properties) {
        this._properties = properties || {};
        this._state = properties || {};
    },

### fetch

##### splunkjs.Service.Resource.fetch

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

#### Syntax

fetch: function(callback)

#### Parameters

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

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

    fetch: function(callback) {
        throw new Error("MUST BE OVERRIDDEN");
    },

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

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

    init: function(service, path, namespace) {
        var fullpath = service.fullpath(path, namespace);

        this._super(service, fullpath);
        this.namespace = namespace;
        this._properties = {};
        this._state = {};

        // We perform the bindings so that every function works
        // properly when it is passed as a callback.
        this._load       = utils.bind(this, this._load);
        this.fetch       = utils.bind(this, this.fetch);
        this.properties  = utils.bind(this, this.properties);
        this.state       = utils.bind(this, this.state);
        this.path        = utils.bind(this, this.path);
    },

### path

##### splunkjs.Service.Resource.path

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

#### Syntax

path: function()

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

    path: function() {
        throw new Error("MUST BE OVERRIDDEN");
    },

### 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;
    },

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

## Inherited Methods

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

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

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