Secure Network Analytics
wingpy.cisco.sna.CiscoSNA
¶
CiscoSNA(
*,
base_url: str | None = None,
username: str | None = None,
password: str | None = None,
tenant_name: str | None = None,
verify: SSLContext | bool = True,
timeout: int = 10,
retries: int = 3
)
Bases: RestApiBaseClass
Interact with the Cisco Secure Network Analytics 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
|
tenant_name
|
str | None
|
The name of the tenant to query. Overrides the environment variable If neither the parameter or environment variable are set, the first or only available tenant is used. |
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 CiscoSNA
sna = CiscoSNA(
base_url="https://sna.example.com",
username="example_username",
password="example_password",
)
tags = sna.get_all("/sw-reporting/v1/tenants/{tenantId}/customHosts/tags")
print(f"Retrieved {len(tags)} tags")
Source code in src/wingpy/cisco/sna.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
get
¶
get(
path: str,
*,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> 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 |
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 |
|---|---|
ResponseMapping | ResponseSequence
|
The |
Source code in src/wingpy/cisco/sna.py
get_all
¶
get_all(
path: str,
*,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> list
Secure Network Analytics does not use pagination.
Response data is placed in the data element by the API.
Some list-data is nested further by the API In those cases the actual list is extracted and returned.
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 |
|---|---|
list[dict]
|
A list-version of returned data. |
Source code in src/wingpy/cisco/sna.py
post
¶
post(
path: str,
*,
data: str | dict | list | None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> 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
|
str | dict | list | None
|
Request payload as JSON string or Python list/dict object. |
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 |
|---|---|
ResponseMapping | ResponseSequence
|
The |
Source code in src/wingpy/cisco/sna.py
put
¶
put(
path: str,
*,
data: str | dict | list | None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> ResponseMapping | ResponseSequence
Send an HTTP PUT request to the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
data
|
str | dict | list | None
|
Request payload as JSON string or Python list/dict object. |
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 |
|---|---|
ResponseMapping | ResponseSequence
|
The |
Source code in src/wingpy/cisco/sna.py
patch
¶
HTTP PATCH is not supported by Cisco Secure Network Analytics
Raises:
| Type | Description |
|---|---|
UnsupportedMethodError
|
|
Source code in src/wingpy/cisco/sna.py
delete
¶
delete(
path: str,
*,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> 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 |
|---|---|
ResponseMapping | ResponseSequence
|
The |
Source code in src/wingpy/cisco/sna.py
wait_for
¶
Provides easy access to the result of job generating APIs. These start asycronous jobs in the background where status can be queried periodically. When the job is done a new URL path is returned or passed to another callable.
Examples:
By default a URL path for the final result is returned. You can then use get or get_all with it.
query = {
"startDateTime": "2026-08-11T08:00:00Z",
"endDateTime": "2026-08-11T08:00:00Z",
}
flow_result_path = sna.wait_for(
sna.post,
"/sw-reporting/v2/tenants/{tenantId}/flows/queries",
data=query,
)
flows = sna.get_all(flow_result_path)
Using the on_complete hook automatically runs that function with the returned path:
query = {
"startTime": "2026-08-11T08:00:00.000",
"endTime": "2026-08-11T09:00:00.000",
}
top_hosts = sna.wait_for(
sna.post,
"/sw-reporting/v1/tenants/{tenantId}/flow-reports/top-hosts/queries",
data=query,
on_complete=sna.get_all,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The initial method that creates the job. |
required |
path
|
str
|
The API endpoint path to send the request to. |
required |
on_complete
|
Callable
|
A method to call with the job result URL path after waiting for it to become ready. |
None
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
**kwargs |
Any keyword parameters passed on to the func, ie. headers, params, ... |
Returns:
| Type | Description |
|---|---|
str
|
URL path for accessing the final result. |
Any
|
Result from on_complete Callable passed through. |
Source code in src/wingpy/cisco/sna.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
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 Cisco Secure Network Analytics API.
1 connection will be used for general synchronous requests.
9 connections will be used for parallel asynchronous requests.
RETRY_RESPONSES
¶
No explicit retry reponses are defined for Cisco Secure Network Analytics.
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.
{tenantId} is automatically resolved based on the tenant_name passed to the constructor.