Skip to content

Catalyst SD-WAN vManage

wingpy.cisco.vmanage.CiscoVmanage

CiscoVmanage(
    *,
    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 SD-WAN vManage API.

Parameters:

Name Type Description Default
base_url str | None

Base URL of the API including https://. Must end with /dataservice

Overrides the environment variable WINGPY_VMANAGE_BASE_URL.

None
username str | None

Username for API authentication.

Overrides the environment variable WINGPY_VMANAGE_USERNAME.

None
password str | None

Password for API authentication.

Overrides the environment variable WINGPY_VMANAGE_PASSWORD.

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 CiscoVmanage
vmanage = CiscoVmanage(
    base_url="https://sandbox-sdwan-2.cisco.com/dataservice",
    username="example_username",
    password="example_password",
)
vmanage.get("/")

Raises:

Type Description
ValueError

When base_url, username or password is missing

ValueError

When base_url does not end with /dataservice

Source code in src/wingpy/cisco/vmanage.py
def __init__(
    self,
    *,
    base_url: str | None = None,
    username: str | None = None,
    password: str | None = None,
    verify: SSLContext | bool = True,
    timeout: int = 10,
    retries: int = 3,
):
    # Allow parameters to be passed directly or fallback to environment variables
    self.vmanage_url = base_url or os.getenv("WINGPY_VMANAGE_BASE_URL")
    """
    The base URL for the Cisco SD-WAN vManage API.

    If not provided, it will be read from the environment variable `WINGPY_VMANAGE_BASE_URL`.
    """

    self.username = username or os.getenv("WINGPY_VMANAGE_USERNAME")
    """
    The username for authentication.
    If not provided, it will be read from the environment variable `WINGPY_VMANAGE_USERNAME`.
    """

    self.password = password or os.getenv("WINGPY_VMANAGE_PASSWORD")
    """
    The password for authentication.
    If not provided, it will be read from the environment variable `WINGPY_VMANAGE_PASSWORD`.
    """

    self.xsrftoken = None
    """
    The XSRF token for the Cisco SD-WAN vManage API.
    """

    if not self.username or not self.password:
        raise ValueError(
            "Username and password must be provided either as argument or environment variable"
        )

    if not self.vmanage_url:
        raise ValueError(
            "Cisco SD-WAN vManage base_url must be provided either as argument or environment variable"
        )
    elif not self.vmanage_url.endswith("/dataservice"):
        raise ValueError("Cisco SD-WAN vManage base_url must end with /dataservice")

    self.version: Version = Version("0.0")
    """
    The version of the Cisco SD-WAN vManage API.
    """

    super().__init__(
        base_url=self.vmanage_url,
        auth_lifetime=1800,
        auth_refresh_percentage=0.9,
        verify=verify,
        headers={
            "Content-Type": "application/json",
            "Accept": "application/json",
        },
        timeout=timeout,
        retries=retries,
    )

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 ?key=value pairs in the URL.

None
path_params dict | None

Replace placeholders like {siteId} in the URL path with actual values.

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 httpx.Response object from the request.

Source code in src/wingpy/cisco/vmanage.py
def get(
    self,
    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
    ----------
    path : str
        The API endpoint path to send the request to.

    params : dict | None, default=None
        URL query parameters to include in the request. will be added as `?key=value` pairs in the URL.

    path_params : dict | None, default=None
        Replace placeholders like `{siteId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    Returns
    -------
    httpx.Response
        The [`httpx.Response`](https://www.python-httpx.org/api/#response) object from the request.
    """

    response = self.request(
        "GET",
        path,
        data=None,
        params=params,
        path_params=path_params,
        headers=headers,
        timeout=timeout,
        is_auth_endpoint=False,
        auth=None,
    )
    return response

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.

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 ?key=value pairs in the URL.

None
path_params dict | None

Replace placeholders like {objectId} in the URL path with actual values.

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 data key in the Cisco SD-WAN vManage API JSON responses.

Raises:

Type Description
UnexpectedPayloadError

When a repsonse doesn't match any of the pagination methods (scroll based or limit/offset based) or the fallback root list or data key can't be found.

Source code in src/wingpy/cisco/vmanage.py
def get_all(
    self,
    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.

    Parameters
    ----------
    path : str
        The API endpoint path to send the request to.

    params : dict | None, default=None
        URL query parameters to include in the request. will be added as `?key=value` pairs in the URL.

    path_params : dict | None, default=None
        Replace placeholders like `{objectId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    page_size : int, default=500
        The number of items to retrieve per page.

    Returns
    -------
    list[dict]
        A concatenated list of returned dictionaries from all pages.

        Similar to the `data` key in the Cisco SD-WAN vManage API JSON responses.

    Raises
    ------
    UnexpectedPayloadError
        When a repsonse doesn't match any of the pagination methods
        (scroll based or limit/offset based)
        or the fallback root list or `data` key can't be found.
    """

    logger.debug(f"Retrieving all pages from {path}")

    if path.endswith("/page"):
        # Queries on a "stats database" uses scollId flavor pagination
        result = self.get_all_statistics(
            path,
            params=params,
            path_params=path_params,
            headers=headers,
            timeout=timeout,
            page_size=page_size,
        )

    elif path.startswith("/template"):
        # Queries on a "configuration database" uses offset/limit flavor pagiantion
        result = self.get_all_configuration(
            path,
            params=params,
            path_params=path_params,
            headers=headers,
            timeout=timeout,
            page_size=page_size,
        )

    else:
        only_page = self.get(
            path,
            params=params,
            path_params=path_params,
            headers=headers,
            timeout=timeout,
        )
        page_data = only_page.json()
        if isinstance(page_data, list):
            result = page_data
        elif "data" in page_data:
            result = page_data["data"]
        else:
            error = UnexpectedPayloadError(
                f"Unable to find appropriate items in JSON payload with keys: {list(page_data.keys())}",
                response=only_page,
            )
            log_exception(error)
            raise error

    return result

get_all_statistics

get_all_statistics(
    path: str,
    *,
    params: dict | None = None,
    path_params: dict | None = None,
    headers: dict | None = None,
    timeout: int | None = None,
    page_size: int = 10000
)

Retrieves all pages of data from a GET endpoint related to the statistics database. Pagination is based on scrollId.

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 ?key=value pairs in the URL.

None
path_params dict | None

Replace placeholders like {objectId} in the URL path with actual values.

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.

10000

Returns:

Type Description
list[dict]

A concatenated list of returned dictionaries from all pages.

Similar to the data key in the Cisco SD-WAN vManage API JSON responses.

Source code in src/wingpy/cisco/vmanage.py
def get_all_statistics(
    self,
    path: str,
    *,
    params: dict | None = None,
    path_params: dict | None = None,
    headers: dict | None = None,
    timeout: int | None = None,
    page_size: int = 10000,
):
    """
    Retrieves all pages of data from a `GET` endpoint related to the statistics database.
    Pagination is based on scrollId.

    Parameters
    ----------
    path : str
        The API endpoint path to send the request to.

    params : dict | None, default=None
        URL query parameters to include in the request. will be added as `?key=value` pairs in the URL.

    path_params : dict | None, default=None
        Replace placeholders like `{objectId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    page_size : int, default=10000
        The number of items to retrieve per page.

    Returns
    -------
    list[dict]
        A concatenated list of returned dictionaries from all pages.

        Similar to the `data` key in the Cisco SD-WAN vManage API JSON responses.
    """
    if isinstance(params, dict):
        params = params.copy()
    else:
        params = {}

    params["count"] = page_size

    result = []
    more_pages = True

    while more_pages:
        page = self.get(
            path,
            params=params,
            path_params=path_params,
            headers=headers,
            timeout=timeout,
        )

        page_data = page.json()
        result += page_data.get("data", [])
        more_pages = page_data["pageInfo"]["hasMoreData"]
        params["scrollId"] = page_data.get("pageInfo", {}).get("scrollId")

    return result

get_all_configuration

get_all_configuration(
    path: str,
    *,
    params: dict | None = None,
    path_params: dict | None = None,
    headers: dict | None = None,
    timeout: int | None = None,
    page_size: int = 50
)

Retrieves all pages of data from a GET endpoint related to the configuration database. Pagination is based on limit/offset.

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 ?key=value pairs in the URL.

None
path_params dict | None

Replace placeholders like {objectId} in the URL path with actual values.

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 data key in the Cisco SD-WAN vManage API JSON responses.

Source code in src/wingpy/cisco/vmanage.py
def get_all_configuration(
    self,
    path: str,
    *,
    params: dict | None = None,
    path_params: dict | None = None,
    headers: dict | None = None,
    timeout: int | None = None,
    page_size: int = 50,
):
    """
    Retrieves all pages of data from a `GET` endpoint related to the configuration database.
    Pagination is based on limit/offset.

    Parameters
    ----------
    path : str
        The API endpoint path to send the request to.

    params : dict | None, default=None
        URL query parameters to include in the request. will be added as `?key=value` pairs in the URL.

    path_params : dict | None, default=None
        Replace placeholders like `{objectId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    page_size : int, default=500
        The number of items to retrieve per page.

    Returns
    -------
    list[dict]
        A concatenated list of returned dictionaries from all pages.

        Similar to the `data` key in the Cisco SD-WAN vManage API JSON responses.
    """
    result = []
    offset = 1

    while True:
        page = self.get_page_configuration(
            path,
            params=params,
            path_params=path_params,
            offset=offset,
            limit=page_size,
            headers=headers,
            timeout=timeout,
        )
        offset += page_size
        if "data" not in page.json():
            error = UnexpectedPayloadError(
                "No data found in payload",
                response=page,
            )
            log_exception(error)
            raise error

        page_reponse = page.json()["data"]
        result += page_reponse

        if len(page_reponse) < page_size:
            logger.trace("Exiting pagination loop.")
            break

    logger.debug(f"Received {len(result)} items from {path}")

    return result

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 {siteId} in the URL path with actual values.

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 httpx.Response object from the request.

Source code in src/wingpy/cisco/vmanage.py
def post(
    self,
    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
    ----------
    path : str
        The API endpoint path to send the request to.

    data : str | dict | list | None
        Request payload as JSON string or Python list/dict object.

    path_params : dict | None, default=None
        Replace placeholders like `{siteId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    Returns
    -------
    httpx.Response
        The [`httpx.Response`](https://www.python-httpx.org/api/#response) object from the request.
    """

    response = self.request(
        "POST",
        path,
        data=data,
        params=None,
        path_params=path_params,
        headers=headers,
        timeout=timeout,
        is_auth_endpoint=False,
        auth=None,
    )

    return response

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 {siteId} in the URL path with actual values.

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 httpx.Response object from the request.

Source code in src/wingpy/cisco/vmanage.py
def put(
    self,
    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
    ----------
    path : str
        The API endpoint path to send the request to.

    data : str | dict | list
        Request payload as JSON string or Python list/dict object.

    path_params : dict | None, default=None
        Replace placeholders like `{siteId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    Returns
    -------
    httpx.Response
        The [`httpx.Response`](https://www.python-httpx.org/api/#response) object from the request.
    """

    response = self.request(
        "PUT",
        path,
        data=data,
        params=None,
        path_params=path_params,
        headers=headers,
        timeout=timeout,
        is_auth_endpoint=False,
        auth=None,
    )

    return response

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 {siteId} in the URL path with actual values.

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 httpx.Response object from the request.

Source code in src/wingpy/cisco/vmanage.py
def delete(
    self,
    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
    ----------
    path : str
        The API endpoint path to send the request to.

    path_params : dict | None, default=None
        Replace placeholders like `{siteId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    Returns
    -------
    httpx.Response
        The [`httpx.Response`](https://www.python-httpx.org/api/#response) object from the request.
    """

    response = self.request(
        "DELETE",
        path,
        data=None,
        params=None,
        path_params=path_params,
        headers=headers,
        timeout=timeout,
        is_auth_endpoint=False,
        auth=None,
    )

    return response

get_page_configuration

get_page_configuration(
    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 related to the configuration database. Uses offset/limit based pagination.

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. First item is offset 1.

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 ?key=value pairs in the URL.

None
path_params dict | None

Replace placeholders like {objectId} in the URL path with actual values.

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 httpx.Response object from the request.

Source code in src/wingpy/cisco/vmanage.py
def get_page_configuration(
    self,
    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 related to the configuration database.
    Uses offset/limit based pagination.

    Parameters
    ----------
    path : str
        The API endpoint path to send the request to.

    offset : int
        Index of first items of the page. First item is offset 1.

    limit : int
        The number of items to retrieve per page.

    params : dict | None, default=None
        URL query parameters to include in the request. will be added as `?key=value` pairs in the URL.

    path_params : dict | None, default=None
        Replace placeholders like `{objectId}` in the URL path with actual values.

        Will be combined with [self.path_params](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.path_params) before sending request.

    headers : dict | None, default=None
        HTTP headers to be sent with the request.

        Will be combined with [self.headers](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.headers) before sending request.

    timeout : int | None, default=None
        Override the standard timeout timer [self.timeout](https://wingpy.automation.wingmen.dk/api/vmanage/#wingpy.cisco.vManage.CiscoVmanage.timeout) for a single request.

    Returns
    -------
    httx.Response
        The [`httpx.Response`](https://www.python-httpx.org/api/#response) object from the request.
    """

    if isinstance(params, dict):
        params = params.copy()
    else:
        params = {}

    # Prepare params for the first page of data
    params["offset"] = offset
    params["limit"] = limit

    rsp = self.get(
        path,
        params=params,
        path_params=path_params,
        headers=headers,
        timeout=timeout,
    )

    page = (offset // limit) + 1

    page_reponse = rsp.json()["data"]
    if len(page_reponse) > 0:
        logger.debug(f"Successfully retrieved page {page} from {path}.")
    else:
        logger.debug(f"Page {page} returned no items.")

    return rsp

authenticate

authenticate() -> None

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
def authenticate(self) -> None:
    """
    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.
    """

    # Authenticate
    logger.debug("Authenticating and recording token lifetime")
    auth_response = self._authenticate()

    # Record the time of authentication
    self.auth_timestamp = arrow.utcnow()

    self._after_auth(auth_response=auth_response)

tasks

tasks: TaskRunner = TaskRunner(max_workers=max_workers)

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.

is_authenticated

is_authenticated

Check if the client is authenticated.

timeout

timeout: int = timeout

The timeout in seconds for each request to the API server.

MAX_CONNECTIONS

MAX_CONNECTIONS = 10

The maximum number of concurrent connections opened to the Cisco SD-WAN vManage.

1 connection will be used for general synchronous requests.

9 connections will be used for parallel asynchronous requests.

RETRY_RESPONSES

RETRY_RESPONSES = []

No explicit retry reponses are defined for Cisco SD-WAN vManage.

headers

headers: dict = headers or {}

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

path_params: dict = {}

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.