update clear

This commit is contained in:
Diogo Sousa
2023-02-01 10:32:05 +00:00
parent 2bce7b5da5
commit 61abf795c3
2 changed files with 15 additions and 6 deletions

View File

@@ -160,7 +160,7 @@ class AccountController(BaseController):
)
if i.lower() in ["y", "yes"]:
console.print("")
Hub.clear_user_configs(auth_header=User.get_auth_header())
Hub.clear_user_configs()
else:
console.print("\nAborted.", style="info")

View File

@@ -176,7 +176,12 @@ def fetch_user_configs(
def patch_user_configs(
key: str, value: str, type_: str, base_url: str = BASE_URL, timeout: int = TIMEOUT
key: str,
value: str,
type_: str,
auth_header: str,
base_url: str = BASE_URL,
timeout: int = TIMEOUT,
) -> Optional[requests.Response]:
"""Patch user configurations to the server.
@@ -188,6 +193,8 @@ def patch_user_configs(
The value to patch.
type_ : str
The type of the patch, either "keys" or "settings".
auth_header : str
The authorization header.
base_url : str
The base url, by default BASE_URL
timeout : int
@@ -208,7 +215,7 @@ def patch_user_configs(
try:
response = requests.patch(
url=base_url + "terminal/user-json",
headers={"Authorization": User.get_auth_header()},
headers={"Authorization": auth_header},
json=data,
timeout=timeout,
)
@@ -229,16 +236,16 @@ def patch_user_configs(
def clear_user_configs(
auth_header: str, base_url: str = BASE_URL, timeout: int = TIMEOUT
base_url: str = BASE_URL, auth_header: Optional[str] = None, timeout: int = TIMEOUT
) -> Optional[requests.Response]:
"""Clear user configurations to the server.
Parameters
----------
auth_header : str
The authorization header.
base_url : str
The base url, by default BASE_URL
auth_header : Optional[str]
The authorization header, by default None
timeout : int
The timeout, by default TIMEOUT
@@ -247,6 +254,8 @@ def clear_user_configs(
Optional[requests.Response]
The response from the put request.
"""
auth_header = User.get_auth_header() if auth_header is None else auth_header
data: Dict[str, dict] = {"features_keys": {}, "features_settings": {}}
try: