You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor device utility functions to use WebSocketWrapper for asynchronous operations
- Updated clear_sessions, clear_mac_table, and clear_learned_mac functions to utilize WebSocketWrapper for handling API calls and WebSocket events.
- Enhanced logging for debugging purposes in various functions including ping, traceroute, and OSPF commands.
- Removed synchronous trigger handling and replaced it with asynchronous WebSocket handling across multiple device utility functions.
- Updated version number in uv.lock to 0.61.1.
All API functions in `mistapi.api.v1` are synchronous by default. To use them in an `asyncio` context (e.g., FastAPI, aiohttp, or any async application) without blocking the event loop, use `mistapi.arun()`.
503
+
504
+
`arun()` wraps any sync mistapi function in `asyncio.to_thread()`, running the blocking HTTP request in a thread pool while the event loop continues. No changes are needed to the existing API functions.
Device utility functions are already non-blocking and return a `UtilResponse` that supports `await`. You can mix `arun()` for API calls and `await` for device utilities:
The package provides a WebSocket client for real-time event streaming from the Mist API (`wss://{host}/api-ws/v1/stream`). Authentication is handled automatically using the same session credentials (API token or login/password).
@@ -533,7 +614,7 @@ ws.connect()
533
614
|-------|---------|-------------|
534
615
|`mistapi.websockets.orgs.InsightsEvents`|`/orgs/{org_id}/insights/summary`| Real-time insights events for an organization |
535
616
|`mistapi.websockets.orgs.MxEdgesStatsEvents`|`/orgs/{org_id}/stats/mxedges`| Real-time MX edges stats for an organization |
536
-
|`mistapi.websockets.orgs.MxEdgesUpgradesEvents`|`/orgs/{org_id}/mxedges`| Real-time MX edges upgrades events for an organization |
617
+
|`mistapi.websockets.orgs.MxEdgesEvents`|`/orgs/{org_id}/mxedges`| Real-time MX edges events for an organization |
537
618
538
619
#### Site Channels
539
620
@@ -542,7 +623,7 @@ ws.connect()
542
623
|`mistapi.websockets.sites.ClientsStatsEvents`|`/sites/{site_id}/stats/clients`| Real-time clients stats for a site |
543
624
|`mistapi.websockets.sites.DeviceCmdEvents`|`/sites/{site_id}/devices/{device_id}/cmd`| Real-time device command events for a site |
544
625
|`mistapi.websockets.sites.DeviceStatsEvents`|`/sites/{site_id}/stats/devices`| Real-time device stats for a site |
545
-
|`mistapi.websockets.sites.DeviceUpgradesEvents`|`/sites/{site_id}/devices`| Real-time device upgrades events for a site |
626
+
|`mistapi.websockets.sites.DeviceEvents`|`/sites/{site_id}/devices`| Real-time device events for a site |
546
627
|`mistapi.websockets.sites.MxEdgesStatsEvents`|`/sites/{site_id}/stats/mxedges`| Real-time MX edges stats for a site |
547
628
|`mistapi.websockets.sites.PcapEvents`|`/sites/{site_id}/pcap`| Real-time PCAP events for a site |
0 commit comments