File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727from requests .exceptions import HTTPError
2828
2929from mistapi .__api_response import APIResponse
30- from mistapi .__api_session import _apitoken_sanitizer
3130from mistapi .__logger import logger
3231from 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+
3552class APIRequest :
3653 """
3754 Class handling API Request to the Mist Cloud
Original file line number Diff line number Diff line change 2323from dotenv import load_dotenv
2424from requests import Session
2525
26- from mistapi .__api_request import APIRequest
26+ from mistapi .__api_request import APIRequest , _apitoken_sanitizer
2727from mistapi .__api_response import APIResponse
2828from mistapi .__logger import console as CONSOLE
2929from 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 :]} "
You can’t perform that action at this time.
0 commit comments