Catalyst Center
wingpy.cisco.catalystcenter.CiscoCatalystCenter
¶
CiscoCatalystCenter(
*,
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 Cisco Catalyst Center 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 CiscoCatalystCenter
catalyst = CiscoCatalystCenter(
base_url="https://sandboxdnac2.cisco.com",
username="example_username",
password="example_password",
)
catalyst.get("/dna/intent/api/v1/network-device")
Source code in src/wingpy/cisco/catalystcenter.py
get
¶
get(
path: str,
*,
params: dict | None = None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
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 |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/catalystcenter.py
get_all
¶
get_all(
path: str,
*,
params: dict | None = None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None,
page_size: int = 500
) -> list
Retrieves all pages of data from a GET
endpoint using maximum concurrency.
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
|
page_size
|
int
|
The number of items to retrieve per page. |
500
|
Returns:
Type | Description |
---|---|
list[dict]
|
A concatenated list of returned dictionaries from all pages. Similar to the |
Source code in src/wingpy/cisco/catalystcenter.py
post
¶
post(
path: str,
*,
data: str | dict | list | None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
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 |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/catalystcenter.py
put
¶
put(
path: str,
*,
data: str | dict | list | None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
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
|
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 |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/catalystcenter.py
delete
¶
delete(
path: str,
*,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
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 |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/catalystcenter.py
get_page
¶
get_page(
path: str,
offset: int,
limit: int,
*,
params: dict | None = None,
path_params: dict | None = None,
headers: dict | None = None,
timeout: int | None = None
) -> httpx.Response
Retrieves a specific page of data from a GET
endpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The API endpoint path to send the request to. |
required |
offset
|
int
|
Index of first items of the page. |
required |
limit
|
int
|
The number of items to retrieve per page. |
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 |
---|---|
Response
|
The |
Source code in src/wingpy/cisco/catalystcenter.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
instance-attribute
¶
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.
timeout
instance-attribute
¶
The timeout in seconds for each request to the API server.
MAX_CONNECTIONS
class-attribute
instance-attribute
¶
The maximum number of concurrent connections opened to the Catalyst Center.
1 connection will be used for general synchronous requests.
6 connections will be used for parallel asynchronous requests.
RETRY_RESPONSES
class-attribute
instance-attribute
¶
No explicit retry reponses are defined for Cisco Catalyst Center.
headers
instance-attribute
¶
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
instance-attribute
¶
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.