Skip to content

Commit 3f6b612

Browse files
authored
refactor Privileges initialization to handle _Privilege instances dir… (#25)
* refactor Privileges initialization to handle _Privilege instances directly * 0.61.5
1 parent 652cf60 commit 3f6b612

9 files changed

Lines changed: 48 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
# CHANGELOG
2+
## Version 0.61.5 (April 2026)
3+
4+
**Released**: April 22, 2026
5+
6+
This release fixes a bug in the `Privileges` class initialization.
7+
8+
---
9+
10+
### BUG FIXES
11+
12+
#### **Privileges Initialization**
13+
Fixed `Privileges.__init__()` to correctly handle lists containing `_Privilege` instances in addition to dicts. Previously, passing already-instantiated `_Privilege` objects would cause initialization errors.
14+
15+
---
16+
217
## Version 0.61.4 (April 2026)
318

419
**Released**: April 1, 2026

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "mistapi"
7-
version = "0.61.4"
7+
version = "0.61.5"
88
authors = [{ name = "Thomas Munzer", email = "tmunzer@juniper.net" }]
99
description = "Python package to simplify the Mist System APIs usage"
1010
keywords = ["Mist", "Juniper", "API"]

src/mistapi/__models/privilege.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ def get(self, key: str, default: Any | None = None) -> Any:
4747

4848

4949
class Privileges:
50-
def __init__(self, privileges: list[dict]) -> None:
50+
def __init__(self, privileges: list[dict | _Privilege]) -> None:
5151
self.privileges: list[_Privilege] = []
5252
for privilege in privileges:
53-
self.privileges.append(_Privilege(privilege))
53+
if isinstance(privilege, _Privilege):
54+
self.privileges.append(privilege)
55+
else:
56+
self.privileges.append(_Privilege(privilege))
5457

5558
def __iter__(self) -> Iterator[_Privilege]:
5659
"""Return an iterator over the privileges."""

src/mistapi/__version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.61.4"
1+
__version__ = "0.61.5"
22
__author__ = "Thomas Munzer <tmunzer@juniper.net>"

src/mistapi/api/v1/orgs/secintelprofiles.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
from mistapi.__api_response import APIResponse as _APIResponse
1515

1616

17-
def listOrgSecIntelProfiles(mist_session: _APISession, org_id: str) -> _APIResponse:
17+
def listOrgSecIntelProfiles(
18+
mist_session: _APISession,
19+
org_id: str,
20+
limit: int | None = None,
21+
page: int | None = None,
22+
) -> _APIResponse:
1823
"""
1924
API doc: https://www.juniper.net/documentation/us/en/software/mist/api/http/api/orgs/secintel-profiles/list-org-sec-intel-profiles
2025
@@ -27,6 +32,11 @@ def listOrgSecIntelProfiles(mist_session: _APISession, org_id: str) -> _APIRespo
2732
-----------
2833
org_id : str
2934
35+
QUERY PARAMS
36+
------------
37+
limit : int, default: 100
38+
page : int, default: 1
39+
3040
RETURN
3141
-----------
3242
mistapi.APIResponse
@@ -35,6 +45,10 @@ def listOrgSecIntelProfiles(mist_session: _APISession, org_id: str) -> _APIRespo
3545

3646
uri = f"/api/v1/orgs/{org_id}/secintelprofiles"
3747
query_params: dict[str, str] = {}
48+
if limit:
49+
query_params["limit"] = str(limit)
50+
if page:
51+
query_params["page"] = str(page)
3852
resp = mist_session.mist_get(uri=uri, query=query_params)
3953
return resp
4054

src/mistapi/api/v1/sites/sle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@deprecation.deprecated(
1919
deprecated_in="0.59.2",
2020
removed_in="0.65.0",
21-
current_version="0.61.4",
21+
current_version="0.61.5",
2222
details="function replaced with getSiteSleClassifierSummaryTrend",
2323
)
2424
def getSiteSleClassifierDetails(
@@ -690,7 +690,7 @@ def listSiteSleImpactedWirelessClients(
690690
@deprecation.deprecated(
691691
deprecated_in="0.59.2",
692692
removed_in="0.65.0",
693-
current_version="0.61.4",
693+
current_version="0.61.5",
694694
details="function replaced with getSiteSleSummaryTrend",
695695
)
696696
def getSiteSleSummary(

tests/unit/test_websocket_client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,9 @@ def test_zero_max_reconnect_backoff_raises(self, mock_session) -> None:
738738
_MistWebsocket(mock_session, channels=["/ch"], max_reconnect_backoff=0)
739739

740740
def test_max_reconnect_backoff_none_allowed(self, mock_session) -> None:
741-
client = _MistWebsocket(mock_session, channels=["/ch"], max_reconnect_backoff=None)
741+
client = _MistWebsocket(
742+
mock_session, channels=["/ch"], max_reconnect_backoff=None
743+
)
742744
assert client._max_reconnect_backoff is None
743745

744746

@@ -1058,10 +1060,12 @@ def fake_run_forever(**kwargs):
10581060
# Without the cap, later delays would grow via exponential backoff
10591061
# (e.g., 0.01, 0.02, 0.04, 0.08, 0.16). Verify the cap was actually
10601062
# needed by checking that at least one uncapped delay would exceed it.
1061-
uncapped = [0.01 * (2 ** i) for i in range(len(observed_delays))]
1063+
uncapped = [0.01 * (2**i) for i in range(len(observed_delays))]
10621064
assert any(d > cap for d in uncapped), "cap was never exercised"
10631065

1064-
def test_delay_uncapped_when_max_reconnect_backoff_is_none(self, mock_session) -> None:
1066+
def test_delay_uncapped_when_max_reconnect_backoff_is_none(
1067+
self, mock_session
1068+
) -> None:
10651069
"""Without max_reconnect_backoff, delays grow without bound."""
10661070
client = self._make_client(
10671071
mock_session,

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)