Divided util into it's own module. Struggling with class variables and using them across many functions...

This commit is contained in:
Norm Rasmussen
2024-09-01 08:16:39 -04:00
parent e49d3d0a01
commit 10cb3e54d0
7 changed files with 95 additions and 35 deletions

View File

@ -17,7 +17,7 @@ Notes:
"""
import json
import Calls
from utils import calls, apikeys
JSONDOC = "./api_docs.json"
BASEURL = "https://api.northpass.com/v2/migration"
@ -125,11 +125,14 @@ def get_all_projects():
"""
project_ids = []
url = f"{BASEURL}/projects"
ret = Calls.get(url)
ret = calls.get(url)
for items in ret["data"]:
project_ids.append(items['id'])
print(f"{ items['attributes']['name'] } -- { items['id'] }")
if ret["data"] == "":
for items in ret["data"]:
project_ids.append(items['id'])
print(f"{ items['attributes']['name'] } -- { items['id'] }")
else:
print("Looks like there are no projects created!")
return project_ids
@ -140,7 +143,7 @@ def delete_all_projects():
project_ids = get_all_projects()
for proj in project_ids:
url = f"{BASEURL}/projects/{proj}"
Calls.delete(url)
calls.delete(url)
def get_specific_project():
"""
@ -148,7 +151,7 @@ def get_specific_project():
"""
proj_id = "13aa7aed-3fb5-4488-9185-3befd0c1ae86"
url = f"{BASEURL}/projects/{proj_id}"
Calls.get(url)
calls.get(url)
if __name__ == "__main__":