Skip to content

0.61.2#17

Merged
tmunzer-AIDE merged 7 commits intomainfrom
0.61.2
Mar 17, 2026
Merged

0.61.2#17
tmunzer-AIDE merged 7 commits intomainfrom
0.61.2

Conversation

@tmunzer-AIDE
Copy link
Collaborator

Version 0.61.2 (March 2026)

Released: March 17, 2026

This release adds automatic reconnection support for WebSocket streams, updates the OpenAPI specification, and includes minor bug fixes.


1. NEW FEATURES

WebSocket Auto-Reconnect

_MistWebsocket now supports automatic reconnection with configurable parameters:

  • auto_reconnect — Enable/disable auto-reconnect (default: False)
  • max_reconnect_attempts — Maximum reconnect attempts before giving up (default: 5)
  • reconnect_backoff — Base backoff delay in seconds, with exponential increase (default: 2.0)

When enabled, the WebSocket automatically reconnects on transient failures using exponential backoff. User-initiated disconnect() calls are respected during reconnection attempts.

ws = mistapi.websockets.sites.DeviceStatsEvents(
    apisession,
    site_ids=["<site_id>"],
    auto_reconnect=True,
    max_reconnect_attempts=5,
    reconnect_backoff=2.0
)
ws.connect(run_in_background=True)

2. API CHANGES (OpenAPI 2602.1.7)

Updated to mist_openapi spec version 2602.1.7.

Insights API

  • getSiteInsightMetrics() — Now uses metrics as a query parameter instead of a path parameter
  • getSiteInsightMetricsForAP() — New function to retrieve insight metrics for a specific AP
  • getSiteInsightMetricsForClient() — Changed metric path parameter to metrics query parameter
  • getSiteInsightMetricsForGateway() — Changed metric path parameter to metrics query parameter

Stats API

  • getOrgStats() — Removed start, end, duration, limit, page query parameters
  • listOrgSiteStats() — Removed start, end, duration query parameters

3. BUG FIXES

  • Fixed ShellSession.recv() to gracefully handle socket timeout reset when the connection is already closed

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR bumps mistapi to v0.61.2, updates the vendored OpenAPI spec to 2602.1.7, and introduces an auto-reconnect option for Mist WebSocket streams, alongside minor fixes and corresponding unit test updates.

Changes:

  • Add optional WebSocket auto-reconnect logic (exponential backoff + max attempts) and update WebSocket unit tests accordingly.
  • Update Insights/Stats API wrappers to match OpenAPI 2602.1.7 endpoint/parameter changes.
  • Bump package version to 0.61.2, update changelog, and include a ShellSession recv() robustness fix.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/mistapi/websockets/__ws_client.py Implements auto-reconnect loop, defers sentinel/callback to loop exit, adds reconnect state tracking.
tests/unit/test_websocket_client.py Updates close/run_forever expectations and adds auto-reconnect test coverage.
src/mistapi/api/v1/sites/insights.py Updates insights metrics endpoints/parameters; adds AP metrics helper.
src/mistapi/api/v1/orgs/stats.py Removes now-unsupported query params from getOrgStats and listOrgSiteStats.
src/mistapi/device_utils/__tools/shell.py Makes recv() timeout reset tolerant of closed connections.
tests/unit/test_shell.py Minor test refactor/formatting updates.
src/mistapi/device_utils/ex.py Import formatting tweak (no functional change).
src/mistapi/device_utils/srx.py Import formatting tweak (no functional change).
src/mistapi/api/v1/sites/sle.py Updates deprecation decorator current_version to 0.61.2.
CHANGELOG.md Adds 0.61.2 release notes covering reconnect + OpenAPI changes + bugfix.
pyproject.toml Version bump to 0.61.2.
src/mistapi/__version.py Version bump to 0.61.2.
uv.lock Lockfile version update for the editable package.
.gitmodules Pins mist_openapi submodule branch to 2602.1.7.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

tmunzer-AIDE and others added 3 commits March 17, 2026 22:59
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR releases mistapi 0.61.2 by adding WebSocket auto-reconnect support across streaming channel classes, updating generated API client functions to match mist_openapi 2602.1.7, and including small robustness fixes/tests.

Changes:

  • Add configurable WebSocket auto-reconnect (backoff + max attempts) to _MistWebsocket and expose parameters across channel wrappers/docs.
  • Update Insights/Stats API functions to reflect OpenAPI spec changes (notably metrics now as a query param in several endpoints; remove some deprecated query params).
  • Improve shell WebSocket robustness and refresh unit tests + versioning/changelog metadata.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
uv.lock Bumps local package version to 0.61.2 in lockfile.
pyproject.toml Project version bump to 0.61.2.
src/mistapi/__version.py Library version bump to 0.61.2.
CHANGELOG.md Adds 0.61.2 release notes (auto-reconnect + OpenAPI update + fixes).
.gitmodules Pins mist_openapi submodule branch to 2602.1.7.
README.md Documents new WebSocket connection parameters and example usage.
src/mistapi/websockets/__ws_client.py Implements auto-reconnect loop, tracks last close info, and adjusts sentinel/on_close behavior.
src/mistapi/websockets/sites.py Exposes auto-reconnect params on site channel classes.
src/mistapi/websockets/orgs.py Exposes auto-reconnect params on org channel classes.
src/mistapi/websockets/location.py Exposes auto-reconnect params on location channel classes.
src/mistapi/websockets/session.py Exposes auto-reconnect params on SessionWithUrl.
tests/unit/test_websocket_client.py Updates tests for new close/sentinel semantics and adds auto-reconnect coverage.
tests/unit/test_shell.py Minor test formatting refactor (with-statement parentheses).
src/mistapi/device_utils/__tools/shell.py Makes recv() timeout restoration resilient to closed sockets.
src/mistapi/device_utils/ex.py Import formatting change for create_shell_session.
src/mistapi/device_utils/srx.py Import formatting change for create_shell_session.
src/mistapi/api/v1/sites/insights.py Updates Insights endpoints (new AP metrics function; metrics query param changes).
src/mistapi/api/v1/orgs/stats.py Removes no-longer-supported query params from getOrgStats and listOrgSiteStats.
src/mistapi/api/v1/sites/sle.py Updates deprecation metadata current_version to 0.61.2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR bumps mistapi to v0.61.2, adds auto-reconnect support to the WebSocket client and channel wrappers, and updates generated API bindings/docs in line with the updated OpenAPI submodule.

Changes:

  • Add configurable WebSocket auto-reconnect (exponential backoff) and update unit tests accordingly.
  • Update OpenAPI-driven API functions (Insights + Org Stats) and bump the mist_openapi submodule branch.
  • Improve ShellSession connection robustness / SSL options and update docs + versioning files.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
uv.lock Bumps locked package version to 0.61.2.
tests/unit/test_websocket_client.py Updates close-handling expectations and adds auto-reconnect tests.
tests/unit/test_shell.py Test formatting adjustments for context manager patching.
src/mistapi/websockets/sites.py Plumbs auto-reconnect params through site WebSocket channel classes + doc/example updates.
src/mistapi/websockets/session.py Plumbs auto-reconnect params through SessionWithUrl + doc/example updates.
src/mistapi/websockets/orgs.py Plumbs auto-reconnect params through org WebSocket channel classes + doc/example updates.
src/mistapi/websockets/location.py Plumbs auto-reconnect params through location WebSocket channel classes + doc/example updates.
src/mistapi/websockets/__ws_client.py Implements reconnect loop, close-state tracking, and safer SSL options.
src/mistapi/device_utils/srx.py Import formatting change for shell session factory alias.
src/mistapi/device_utils/ex.py Import formatting change for shell session factory alias.
src/mistapi/device_utils/__tools/shell.py Adds check_hostname=False when verify disabled; improves connect/recv robustness.
src/mistapi/api/v1/sites/sle.py Updates deprecation decorator current_version to 0.61.2.
src/mistapi/api/v1/sites/insights.py Adds AP insights metrics function and changes metrics selection from path to query param.
src/mistapi/api/v1/orgs/stats.py Removes several query params from getOrgStats / listOrgSiteStats signatures and request building.
src/mistapi/__version.py Bumps library version to 0.61.2.
README.md Documents new WebSocket reconnect parameters with an updated example.
pyproject.toml Bumps project version to 0.61.2.
CHANGELOG.md Adds 0.61.2 release notes including auto-reconnect and API changes.
.gitmodules Pins mist_openapi submodule branch to 2602.1.7.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@tmunzer-AIDE tmunzer-AIDE requested a review from Copilot March 17, 2026 22:49
@tmunzer-AIDE tmunzer-AIDE merged commit ef665a2 into main Mar 17, 2026
9 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR bumps mistapi to 0.61.2 and introduces WebSocket auto-reconnect support, along with OpenAPI-driven API surface updates and a set of reliability/thread-safety fixes across HTTP, WebSocket, and device utility components.

Changes:

  • Add auto-reconnect (exponential backoff) to _MistWebsocket and plumb new parameters through WebSocket channel classes + docs/tests.
  • Update API wrappers to match OpenAPI 2602.1.7 (notably Insights + Org Stats signature/URL changes) and bump versioning/changelog.
  • Improve robustness in HTTP/session handling (CSRF cookie retrieval, pagination “next” URL building, request counter locking) and ShellSession websocket handling.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
uv.lock Updates locked version to 0.61.2.
pyproject.toml Bumps package version to 0.61.2.
src/mistapi/__version.py Bumps runtime version constant to 0.61.2.
CHANGELOG.md Adds 0.61.2 release notes (auto-reconnect + OpenAPI updates + fixes).
.gitmodules Pins mist_openapi submodule branch to 2602.1.7.
README.md Documents new WebSocket connection parameters (auto-reconnect settings).
src/mistapi/websockets/__ws_client.py Implements auto-reconnect loop, new lifecycle state, SSL options tweak, and close-handling changes.
src/mistapi/websockets/sites.py Threads auto-reconnect parameters through site-level websocket channel classes + doc updates.
src/mistapi/websockets/orgs.py Threads auto-reconnect parameters through org-level websocket channel classes + doc updates.
src/mistapi/websockets/session.py Threads auto-reconnect parameters through SessionWithUrl + fixes example casing.
src/mistapi/websockets/location.py Renames map_idmap_ids and threads auto-reconnect params through location channel classes.
tests/unit/test_websocket_client.py Updates SSL option assertions, close semantics tests, and adds auto-reconnect test coverage.
tests/conftest.py Broadens env var isolation for test determinism.
tests/unit/test_shell.py Refactors tests for formatting/structure (no behavioral change).
src/mistapi/device_utils/__tools/shell.py Improves SSL options + connection lifecycle safety and makes recv timeout-reset more resilient.
src/mistapi/device_utils/__tools/bgp.py Updates docstring to include timeout param documentation.
src/mistapi/device_utils/ex.py Re-exports traceroute tooling/types for EX utilities.
src/mistapi/device_utils/srx.py Re-exports traceroute tooling/types + route protocol for SRX utilities.
src/mistapi/device_utils/ssr.py Re-exports traceroute tooling/types + route protocol for SSR utilities.
src/mistapi/api/v1/sites/insights.py Updates Insights endpoints/params (metrics now query param) and adds AP metrics helper.
src/mistapi/api/v1/orgs/stats.py Removes unsupported query params from getOrgStats / listOrgSiteStats to match spec.
src/mistapi/api/v1/sites/sle.py Updates deprecation decorator current_version to 0.61.2.
src/mistapi/__api_session.py Hardens privilege parsing, fixes login retry recursion, and makes CSRF cookie handling safer.
src/mistapi/__api_response.py Uses regex-based page param replacement to build next links more safely.
src/mistapi/__api_request.py Protects request counter increment with the existing token lock.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

"""
if not self._connected.wait(timeout=10):
if self._auto_reconnect:
while not self._connected.is_set() and not self._user_disconnect.is_set():
Comment on lines +909 to +912
def disconnect_when_ready():
entered_backoff.wait() # deterministic: wait until backoff starts
client.disconnect()

Comment on lines +34 to +35
ping_timeout : int, default 10
Time in seconds to wait for a ping response before considering the connection dead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants