Splunk Enterprise¶
Detailed API reference for the wingpy.cisco.splunkenterprise.SplunkEnterprise class, which provides methods to interact with Splunk Enterprise using REST API.
Look for inline examples and code snippets to help you understand how to use each method, and get information about parameters, return values and exceptions.
wingpy.cisco.splunkenterprise.SplunkEnterprise
¶
SplunkEnterprise(
*,
base_url: str | None = None,
username: str | None = None,
password: str | None = None,
verify: SSLContext | bool = True,
timeout: int = 10,
retries: int = 3
)
Bases: RestApiBaseClass
Interact with the Splunk Enterprise API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str | None
|
Base URL of the API including Overrides the environment variable |
None
|
username
|
str | None
|
Username for API authentication. Overrides the environment variable |
None
|
password
|
str | None
|
Password for API authentication. Overrides the environment variable |
None
|
verify
|
bool | SSLContext
|
Boolean values will enable or disable the default SSL verification. Use an ssl.SSLContext to specify custom Certificate Authority. |
True
|
timeout
|
int
|
Number of seconds to wait for HTTP responses before raising httpx.TimeoutException exception. |
10
|
retries
|
int
|
Number of failed HTTP attempts allowed before raising httpx.HTTPStatusError exception. |
3
|
Examples:
from wingpy import SplunkEnterprise
splunk = SplunkEnterprise(
base_url="",
username="example_username",
password="example_password", # pragma: allowlist secret
)
splunk.get("/")
Source code in src/wingpy/cisco/splunkenterprise.py
get
¶
get(
path: str,
*,
params: dict | None = None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> (
XMLResponseMapping | ResponseMapping | ResponseSequence
)
Send an HTTP GET request to the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
params
|
dict | None
|
URL query parameters to include in the request. will be added as |
None
|
path_params
|
dict | None
|
Replace placeholders like Will be combined with self.path_params before sending request. |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with self.headers before sending request. |
None
|
timeout
|
int | None
|
Override the standard timeout timer self.timeout for a single request. |
None
|
Returns:
| Type | Description |
|---|---|
XMLResponseMapping | ResponseMapping | ResponseSequence
|
The |
Source code in src/wingpy/cisco/splunkenterprise.py
get_all
¶
get_all(
path: str,
*,
params: dict | None = None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> list
Retrieves all entries from a GET endpoint by setting the count parameter to
0 and handling the asynchronous response if results are not immediately available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
params
|
dict | None
|
URL query parameters to include in the request. will be added as |
None
|
path_params
|
dict | None
|
Replace placeholders like Will be combined with self.path_params before sending request. |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with self.headers before sending request. |
None
|
timeout
|
int | None
|
Override the standard timeout timer self.timeout for a single request. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
A concatenated list of returned dictionaries from all pages. Similar to the |
Source code in src/wingpy/cisco/splunkenterprise.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
post
¶
post(
path: str,
*,
data: dict | None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> (
XMLResponseMapping | ResponseMapping | ResponseSequence
)
Send an HTTP POST request to the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
data
|
dict | None
|
Request parameters as a Python dictionary object. Will be encoded for |
None
|
path_params
|
dict | None
|
Replace placeholders like Will be combined with self.path_params before sending request. |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with self.headers before sending request. |
None
|
timeout
|
int | None
|
Override the standard timeout timer self.timeout for a single request. |
None
|
Returns:
| Type | Description |
|---|---|
XMLResponseMapping | ResponseMapping | ResponseSequence
|
The |
Source code in src/wingpy/cisco/splunkenterprise.py
put
¶
HTTP PUT is not supported by Splunk Enterprise API
Raises:
| Type | Description |
|---|---|
UnsupportedMethodError
|
|
Source code in src/wingpy/cisco/splunkenterprise.py
patch
¶
HTTP PATCH is not supported by Splunk Enterprise API
Raises:
| Type | Description |
|---|---|
UnsupportedMethodError
|
|
Source code in src/wingpy/cisco/splunkenterprise.py
delete
¶
delete(
path: str,
*,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> (
XMLResponseMapping | ResponseMapping | ResponseSequence
)
Send an HTTP DELETE request to the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
path_params
|
dict | None
|
Replace placeholders like Will be combined with self.path_params before sending request. |
None
|
headers
|
dict | None
|
HTTP headers to be sent with the request. Will be combined with self.headers before sending request. |
None
|
timeout
|
int | None
|
Override the standard timeout timer self.timeout for a single request. |
None
|
Returns:
| Type | Description |
|---|---|
XMLResponseMapping | ResponseMapping | ResponseSequence
|
The |
Source code in src/wingpy/cisco/splunkenterprise.py
authenticate
¶
Executes the API-specific authentication process and records timestamps for session tracking.
Notes
Authentication will automatically be carried out just-in-time.
Only call this method directly if you need to authenticate proactively, outside of normal request flow.
Source code in src/wingpy/base.py
tasks
¶
Manages concurrent requests to the API server.
The number of concurrent requests is limited by the MAX_CONNECTIONS property:
- 1 connection is reserved for the main thread used for authentication and synchronous requests.
- The remaining connections are used for concurrent requests.
See Also
wingpy.scheduling.TaskRunner
Schedule and run asynchronous tasks in parallel.
MAX_CONNECTIONS
¶
The maximum number of concurrent connections opened to the Splunk Enterprise.
1 connection will be used for general synchronous requests.
6 connections will be used for parallel asynchronous requests.
headers
¶
A dictionary of HTTP headers to be sent with each request.
These headers will be merged with any headers dict passed to an individual request.
path_params
¶
A dictionary of path parameters to be used in the API path of each request.
These parameters will be merged with any path_params dict passed to the request.