@@ -814,6 +814,31 @@ def remove_plugin_credential(self, plugin_id, param_set_id, preset_id, param_nam
814
814
del self .settings ["credentials" ][name ]
815
815
816
816
817
+ class DSSUserPreferences (object ):
818
+ """
819
+ Preferences for a DSS user.
820
+
821
+ .. important::
822
+
823
+ Do not instantiate directly, use :meth:`DSSUserSettings.preferences` instead.
824
+ """
825
+ def __init__ (self , preferences ):
826
+ self .preferences = preferences
827
+
828
+ @property
829
+ def ui_language (self ):
830
+ """
831
+ Get or set the language used in the Web User Interface for this user. Valid values are "en" (English) and "ja" (Japanese)
832
+
833
+ :rtype: str
834
+ """
835
+ return self .preferences ['uiLanguage' ]
836
+
837
+ @ui_language .setter
838
+ def ui_language (self , new_value ):
839
+ self .preferences ["uiLanguage" ] = new_value
840
+
841
+
817
842
class DSSUserSettings (DSSUserSettingsBase ):
818
843
"""
819
844
Settings for a DSS user.
@@ -866,6 +891,16 @@ def creation_date(self):
866
891
timestamp = self .settings ["creationDate" ] if "creationDate" in self .settings else None
867
892
return _timestamp_ms_to_zoned_datetime (timestamp )
868
893
894
+ @property
895
+ def preferences (self ):
896
+ """
897
+ Get the preferences for this user
898
+
899
+ :return: user preferences
900
+ :rtype: :class:`DSSUserPreferences`
901
+ """
902
+ return DSSUserPreferences (self .settings ["preferences" ])
903
+
869
904
def save (self ):
870
905
"""
871
906
Saves the settings
@@ -1460,7 +1495,7 @@ def set_jupyter_support(self, active):
1460
1495
raise Exception ('Env update failed : %s' % (json .dumps (resp .get ('messages' , {}).get ('messages' , {}))))
1461
1496
return resp
1462
1497
1463
- def update_packages (self , force_rebuild_env = False ):
1498
+ def update_packages (self , force_rebuild_env = False , version = None ):
1464
1499
"""
1465
1500
Update the code env packages so that it matches its spec
1466
1501
@@ -1469,6 +1504,7 @@ def update_packages(self, force_rebuild_env=False):
1469
1504
This call requires an API key with `Create code envs` or `Manage all code envs` permission
1470
1505
1471
1506
:param boolean force_rebuild_env: whether to rebuild the code env from scratch
1507
+ :param boolean version: version to rebuild (applies only to version code envs on automation nodes)
1472
1508
1473
1509
:return: list of messages collected during the operation. Fields are:
1474
1510
@@ -1480,7 +1516,7 @@ def update_packages(self, force_rebuild_env=False):
1480
1516
"""
1481
1517
resp = self .client ._perform_json (
1482
1518
"POST" , "/admin/code-envs/%s/%s/packages" % (self .env_lang , self .env_name ),
1483
- params = {"forceRebuildEnv" : force_rebuild_env })
1519
+ params = {"forceRebuildEnv" : force_rebuild_env , "versionToUpdate" : version })
1484
1520
if resp is None :
1485
1521
raise Exception ('Env update returned no data' )
1486
1522
if resp .get ('messages' , {}).get ('error' , False ):
@@ -2690,3 +2726,40 @@ def save(self):
2690
2726
"""
2691
2727
self .client ._perform_empty ("PUT" , "/admin/code-studios/%s" % (self .template_id ), body = self .settings )
2692
2728
2729
+ class DSSLLMCostLimitingCounters (object ):
2730
+ """
2731
+ The LLM cost limiting counters of the instance
2732
+ """
2733
+ def __init__ (self , data ):
2734
+ self ._data = data
2735
+
2736
+ def get_raw (self ):
2737
+ """
2738
+ Gets counters as a raw dictionary.
2739
+
2740
+ :return: a dictionary containing raw counters
2741
+ :rtype: dict
2742
+ """
2743
+ return self ._data
2744
+
2745
+ @property
2746
+ def counters (self ):
2747
+ """
2748
+ Get the list of counters
2749
+
2750
+ :return: a list of counters
2751
+ :rtype: list
2752
+ """
2753
+ return self ._data ['counters' ]
2754
+
2755
+ def get_counter (self , id ):
2756
+ """
2757
+ Retrieve the counters from a quota id
2758
+
2759
+ :param id identifier of the quota to retrieve
2760
+
2761
+ :return: a dictionary containing the counter
2762
+ :rtype: dict
2763
+ """
2764
+ return next ((counter for counter in self .counters if counter ["id" ] == id ), None )
2765
+
0 commit comments