Skip to content

Commit 3bd569b

Browse files
committed
fix circular import
1 parent 8b91070 commit 3bd569b

2 files changed

Lines changed: 19 additions & 20 deletions

File tree

src/mistapi/__api_request.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,28 @@
2727
from requests.exceptions import HTTPError
2828

2929
from mistapi.__api_response import APIResponse
30-
from mistapi.__api_session import _apitoken_sanitizer
3130
from mistapi.__logger import logger
3231
from mistapi.__models.privilege import Privileges
3332

3433

34+
def _apitoken_sanitizer(apitoken: str) -> str:
35+
"""
36+
Return a substring of the API token to be used in the logs, to avoid
37+
logging the full token value.
38+
39+
PARAMS
40+
-----------
41+
apitoken : str
42+
API token value
43+
44+
RETURN
45+
-----------
46+
str
47+
Substring of the API token to be used in the logs
48+
"""
49+
return f"{apitoken[:4]}...{apitoken[-4:]}"
50+
51+
3552
class APIRequest:
3653
"""
3754
Class handling API Request to the Mist Cloud

src/mistapi/__api_session.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from dotenv import load_dotenv
2424
from requests import Session
2525

26-
from mistapi.__api_request import APIRequest
26+
from mistapi.__api_request import APIRequest, _apitoken_sanitizer
2727
from mistapi.__api_response import APIResponse
2828
from mistapi.__logger import console as CONSOLE
2929
from mistapi.__logger import logger as LOGGER
@@ -1222,21 +1222,3 @@ def get_privilege_by_org_id(self, org_id: str):
12221222
"msp_logo_url": resp.data.get("logo_url"),
12231223
}
12241224
return {}
1225-
1226-
1227-
def _apitoken_sanitizer(apitoken: str) -> str:
1228-
"""
1229-
Return a substring of the API token to be used in the logs, to avoid
1230-
logging the full token value.
1231-
1232-
PARAMS
1233-
-----------
1234-
apitoken : str
1235-
API token value
1236-
1237-
RETURN
1238-
-----------
1239-
str
1240-
Substring of the API token to be used in the logs
1241-
"""
1242-
return f"{apitoken[:4]}...{apitoken[-4:]}"

0 commit comments

Comments
 (0)