From 146dc0e41a8695ba53cee2b15b810c1b442ea39d Mon Sep 17 00:00:00 2001 From: Abstra Bot Date: Wed, 26 Apr 2023 20:15:37 +0000 Subject: [PATCH] Update abstra-cli --- abstra_cli/apis/files.py | 4 ++++ abstra_cli/apis/main.py | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/abstra_cli/apis/files.py b/abstra_cli/apis/files.py index bc76d31..68083c5 100644 --- a/abstra_cli/apis/files.py +++ b/abstra_cli/apis/files.py @@ -23,3 +23,7 @@ def list_workspace_files(): def delete_file(filepath): return api_main.hf_api_runner("DELETE", "file", {"filepath": filepath}) + + +def delete_folder(path): + return api_main.hf_api_runner("DELETE", "folder", {"path": path}) diff --git a/abstra_cli/apis/main.py b/abstra_cli/apis/main.py index eba39d7..dfb57d9 100644 --- a/abstra_cli/apis/main.py +++ b/abstra_cli/apis/main.py @@ -3,7 +3,6 @@ import urllib.request import urllib.response -from .public import get_info_from_token import abstra_cli.credentials as credentials @@ -14,9 +13,19 @@ def get_auth_info(): api_token = credentials.get_credentials() - if not api_token: - return None, None, None - workspace_id, author_id = get_info_from_token(api_token) + headers = credentials.get_auth_headers(api_token) + response = requests.get(f"https://auth.abstra.cloud/abstra-cloud", headers=headers) + response_json = response.json() + if response_json is None: + return api_token, None, None + + author_id = response_json.get("author_id") + workspaces = response_json.get("workspaces", [{}]) + + workspace_id = None + if len(workspaces) != 0: + workspace_id = workspaces[0].get("id") + return api_token, workspace_id, author_id