splunklib.binding
This module contains a low-level binding interface to the Splunk REST API.
This module is designed to enable client-side interaction with the Splunk
REST API at the level of HTTP requests and responses, and it provides simple
helpers for things like Splunk authentication and the use of Splunk namespaces.
This module is specifically designed to be lightweight and faithful to the
underlying Splunk REST API. If you want a friendlier interface to the Splunk
REST API, consider using the splunklib.client module.
-
splunklib.binding.connect(**kwargs)
Establishes an authenticated context with the host.
Parameters: |
- host – The host name (the default is localhost).
- port – The port number (the default is 8089).
- scheme – The scheme for accessing the service (the default is
https).
- owner – The owner namespace (optional).
- app – The app context (optional).
- token – The current session token (optional). Session tokens can be
shared across multiple service instances.
- username – The Splunk account username, which is used to
authenticate the Splunk instance.
- password – The password, which is used to authenticate the Splunk
instance.
|
Returns: | An initialized Context instance.
|
-
class splunklib.binding.Context(handler=None, **kwargs)
This class provides a binding context to a corresponding Splunk service
that can be used to issue HTTP requests.
A context also captures an optional namespace context consisting of an
optional owner name (or “-” wildcard) and optional app name (or “-”
wildcard). To use the Context class, the instance must be
authenticated by presenting credentials using the login() method
or by constructing the instance using the connect() function, which
both creates and authenticates the instance.
Parameters: |
- host – The host name (the default is localhost).
- port – The port number (the default is 8089).
- scheme – The scheme for accessing the service (the default is
https).
- owner – The owner namespace (optional).
- app – The app context (optional).
- token – The current session token (optional). Session tokens can be
shared across multiple service instances.
- username – The Splunk account username, which is used to
authenticate the Splunk instance.
- password – The password, which is used to authenticate the Splunk
instance.
- handler – The HTTP request handler (optional).
|
-
connect()
Returns an open connection (socket) to the service.
-
delete(path, **kwargs)
Issues a DELETE request to a REST endpoint you specify.
Parameters: |
- path – The resource path (REST endpoint).
- kwargs – Request arguments (optional).
|
-
fullpath(path, **kwargs)
Returns a full REST endpoint using an endpoint path or path fragment,
then adds namespace segments by either using any namespace arguments
that are provided or the context namespace values.
Parameters: |
- path – The resource path (REST endpoint), possibly a fragment.
- kwargs – Namespace arguments to use for completing the path:
sharing, owner, and app (optional).
|
-
get(path, **kwargs)
Issues a GET request to a REST endpoint you specify.
Parameters: |
- path – The resource path (REST endpoint).
- kwargs – Query arguments (optional).
|
-
login()
Issues a Splunk login request using the context’s credentials and
stores the session token for use on subsequent requests.
-
logout()
Forgets the current session token.
-
post(path, **kwargs)
Issues a POST request to a REST endpoint you specify.
Parameters: |
- path – The resource path (REST endpoint).
- kwargs – Form arguments (optional).
|
-
request(path, message)
Issues an HTTP request message to a REST endpoint you specify.
Parameters: |
- path – The resource path (REST endpoint).
- request – The request message.
|
-
url(path)
Converts a REST endpoint (from a path or path fragment) into a
complete URL.
Parameters: | path – The resource path (REST endpoint) to convert to a full
URL. |
-
splunklib.binding.handler(key_file=None, cert_file=None, timeout=None)
Returns an instance of the default HTTP request handler that uses
the argument values you provide.
Parameters: |
- key_file – The key file (optional).
- cert_file – The cert file (optional).
- timeout – The request time-out period (optional).
|
-
class splunklib.binding.HTTPError(response)
This class is raised for HTTP responses that return an error.
-
args
-
message