Enables clients to issue HTTP requests to a Splunk server.

package Splunk

 Methods

Constructs a new context with the specified parameters.

__construct(array $args) 

Parameters

$args

array

{
username: (optional) The username to login with. Defaults to "admin".
password: (optional) The password to login with. Defaults to "changeme".
token: (optional) The authentication token to use. If provided, the username and password are ignored and there is no need to call login(). In the format "Splunk SESSION_KEY".
host: (optional) The hostname of the Splunk server. Defaults to "localhost".
port: (optional) The port of the Splunk server. Defaults to 8089.
scheme: (optional) The scheme to use: either "http" or "https". Defaults to "https".
namespace: (optional) Namespace that all object lookups will occur in by default. Defaults to Splunk_Namespace::createDefault().
http: (optional) An Http object that will be used for performing HTTP requests. This is intended for testing only.
}

Gets the hostname of the Splunk server.

getHost() : string

Returns

stringThe hostname of the Splunk server.

Gets the default namespace for collection and entity operations.

getNamespace() : \Splunk_Namespace

Returns

\Splunk_NamespaceThe default namespace that will be used to perform collection and entity operations when none is explicitly specified.

Gets the port of the Splunk server.

getPort() : string

Returns

stringThe port of the Splunk server.

Gets the scheme to use.

getScheme() : string

Returns

stringThe scheme to use: either "http" or "https".

Gets the token used to authenticate HTTP requests after logging in.

getToken() : string

Returns

stringThe token used to authenticate HTTP requests after logging in.

Sends an HTTP DELETE request to the endpoint at the specified path.

sendDelete(string $path, array $args) : \Splunk_HttpResponse
see \Splunk_Http::delete()

Parameters

$path

string

relative or absolute URL path.

$args

array

(optional) query parameters, merged with {
namespace: (optional) namespace to use, or NULL to use this context's default namespace.
}

Exceptions

\Splunk_IOException

Returns

\Splunk_HttpResponse

Sends an HTTP GET request to the endpoint at the specified path.

sendGet(string $path, array $args) : \Splunk_HttpResponse
see \Splunk_Http::get()

Parameters

$path

string

relative or absolute URL path.

$args

array

(optional) query parameters, merged with {
namespace: (optional) namespace to use, or NULL to use this context's default namespace.
}

Exceptions

\Splunk_IOException

Returns

\Splunk_HttpResponse

Sends an HTTP POST request to the endpoint at the specified path.

sendPost(string $path, array $args) : \Splunk_HttpResponse
see \Splunk_Http::post()

Parameters

$path

string

relative or absolute URL path.

$args

array

(optional) form parameters to send in the request body, merged with {
namespace: (optional) namespace to use, or NULL to use this context's default namespace.
}

Exceptions

\Splunk_IOException

Returns

\Splunk_HttpResponse

Sends an HTTP request to the endpoint at the specified path.

sendRequest(string $method, string $path, array $requestHeaders, string $requestBody, array $args) : \Splunk_HttpResponse
see \Splunk_Http::request()

Parameters

$method

string

the HTTP method (ex: 'GET' or 'POST').

$path

string

relative or absolute URL path.

$requestHeaders

array

(optional) dictionary of header names and values.

$requestBody

string

(optional) content to send in the request.

$args

array

(optional) query parameters, merged with {
namespace: (optional) namespace to use, or NULL to use this context's default namespace.
}

Exceptions

\Splunk_IOException

Returns

\Splunk_HttpResponse

Returns the absolute URL path.

abspath(string $path, \Splunk_Namespace | NULL $namespace) : string

Parameters

$path

string

Relative or absolute URL path.

$namespace

\Splunk_NamespaceNULL

Returns

stringAbsolute URL path.

Returns the standard headers to send on each HTTP request.

getRequestHeaders() 

Sends a simple HTTP request to the endpoint at the specified path.

sendSimpleRequest($method, $path, $args) 

Parameters

$method

$path

$args

Returns the absolute URL.

url(string $path, \Splunk_Namespace | NULL $namespace) : string

Parameters

$path

string

Relative or absolute URL path.

$namespace

\Splunk_NamespaceNULL

Returns

stringAbsolute URL.

 Properties

 

$host 
 

$http 
 

$namespace 
 

$password 
 

$port 
 

$scheme 
 

$token 
 

$username