added account overview

This commit is contained in:
Cam 2023-10-18 10:11:58 -05:00
parent 1dbab328c5
commit e1f6e1866a
No known key found for this signature in database
GPG Key ID: 367B7C7EBD84A8BD
2 changed files with 19 additions and 1 deletions

View File

@ -1,4 +1,4 @@
from . import environment
from . import access, decor, model, share
from . import access, decor, model, share, overview
monkeypatch = decor.MonkeyPatch

View File

@ -0,0 +1,18 @@
from zrok.environment.root import Root
import urllib3
def Overview(root: Root) -> str:
if not root.IsEnabled():
raise Exception("environment is not enabled; enable with 'zrok enable' first!")
http = urllib3.PoolManager()
apiEndpoint = root.ApiEndpoint().endpoint
try:
response = http.request(
'GET',
apiEndpoint + "/api/v1/overview",
headers={
"X-TOKEN": root.env.Token
})
except Exception as e:
raise Exception("unable to get account overview", e)
return response.data.decode('utf-8')