Skip to content

Commit b3a6429

Browse files
committed
Use modern API style for usage summary
1 parent 735bdca commit b3a6429

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

dataikuapi/dss/admin.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,3 +1207,43 @@ def get_raw(self):
12071207
Gets the whole status as a raw dictionary.
12081208
"""
12091209
return self.status
1210+
1211+
class DSSGlobalUsageSummary(object):
1212+
"""
1213+
The summary of the usage of the DSS instance.
1214+
Do not create this directly, use :meth:`dataikuapi.dss.DSSClient.get_global_usage_summary`
1215+
"""
1216+
def __init__(self, data):
1217+
self.data = data
1218+
1219+
@property
1220+
def raw(self):
1221+
return self.data
1222+
1223+
@property
1224+
def projects_count(self):
1225+
return self.data["projects"]
1226+
1227+
@property
1228+
def total_datasets_count(self):
1229+
return self.data["datasets"]["all"]
1230+
1231+
@property
1232+
def total_recipes_count(self):
1233+
return self.data["recipes"]["all"]
1234+
1235+
@property
1236+
def total_jupyter_notebooks_count(self):
1237+
return self.data["notebooks"]["nbJupyterNotebooks"]
1238+
1239+
@property
1240+
def total_sql_notebooks_count(self):
1241+
return self.data["notebooks"]["nbSqlNotebooks"]
1242+
1243+
@property
1244+
def total_scenarios_count(self):
1245+
return self.data["scenarios"]["all"]
1246+
1247+
@property
1248+
def total_active_with_trigger_scenarios_count(self):
1249+
return self.data["scenarios"]["activeWithTriggers"]

dataikuapi/dssclient.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .dss.project import DSSProject
1111
from .dss.app import DSSApp
1212
from .dss.plugin import DSSPlugin
13-
from .dss.admin import DSSUser, DSSOwnUser, DSSGroup, DSSConnection, DSSGeneralSettings, DSSCodeEnv, DSSGlobalApiKey, DSSCluster
13+
from .dss.admin import DSSUser, DSSOwnUser, DSSGroup, DSSConnection, DSSGeneralSettings, DSSCodeEnv, DSSGlobalApiKey, DSSCluster, DSSGlobalUsageSummary
1414
from .dss.meaning import DSSMeaning
1515
from .dss.sqlquery import DSSSQLQuery
1616
from .dss.discussion import DSSObjectDiscussions
@@ -763,12 +763,12 @@ def log_custom_audit(self, custom_type, custom_params=None):
763763

764764
def get_global_usage_summary(self, with_per_project=False):
765765
"""
766-
Summarize the contents of the instance
767-
766+
Gets a summary of the global usage of this DSS instance (number of projects, datasets, ...)
768767
:returns: a summary object
769768
"""
770-
return self._perform_json(
769+
data = self._perform_json(
771770
"GET", "/admin/monitoring/global-usage-summary", params={'withPerProject':with_per_project})
771+
return DSSGlobalUsageSummary(data)
772772

773773
########################################################
774774
# Variables

0 commit comments

Comments
 (0)