1- import json
1+ import json , warnings
22
33from requests import Session
44from requests import exceptions
1010from .dss .project import DSSProject
1111from .dss .app import DSSApp
1212from .dss .plugin import DSSPlugin
13- from .dss .admin import DSSUser , DSSOwnUser , DSSGroup , DSSConnection , DSSGeneralSettings , DSSCodeEnv , DSSGlobalApiKey , DSSCluster , DSSGlobalUsageSummary
13+ from .dss .admin import DSSUser , DSSOwnUser , DSSGroup , DSSConnection , DSSGeneralSettings , DSSCodeEnv , DSSGlobalApiKey , DSSCluster , DSSGlobalUsageSummary , DSSInstanceVariables
1414from .dss .meaning import DSSMeaning
1515from .dss .sqlquery import DSSSQLQuery
1616from .dss .discussion import DSSObjectDiscussions
@@ -48,7 +48,7 @@ def __init__(self, host, api_key=None, internal_ticket = None, extra_headers = N
4848 ########################################################
4949 # Futures
5050 ########################################################
51-
51+
5252 def list_futures (self , as_objects = False , all_users = False ):
5353 """
5454 List the currently-running long tasks (a.k.a futures)
@@ -775,18 +775,27 @@ def get_global_usage_summary(self, with_per_project=False):
775775 ########################################################
776776
777777 def get_variables (self ):
778+ """
779+ Deprecated. Use :meth:`get_global_variables`
780+ """
781+ warnings .warn ("get_variables is deprecated, please use get_global_variables" , DeprecationWarning )
782+ return self .get_global_variables ()
783+
784+ def get_global_variables (self ):
778785 """
779786 Get the DSS instance's variables, as a Python dictionary
780787
781788 This call requires an API key with admin rights
782-
783- :returns: a Python dictionary of the instance-level variables
789+
790+ :returns: A :class:`dataikuapi.dss.admin.DSSInstanceVariables` handle
784791 """
785- return self ._perform_json (
786- "GET" , "/admin/ variables/" )
792+ variables = self ._perform_json ("GET" , "/admin/variables/" )
793+ return DSSInstanceVariables ( self , variables )
787794
788795 def set_variables (self , variables ):
789796 """
797+ Deprecated. Use :meth:`get_global_variables` and :meth:`dataikuapi.dss.admin.DSSInstanceVariables.save`
798+
790799 Updates the DSS instance's variables
791800
792801 This call requires an API key with admin rights
@@ -797,8 +806,24 @@ def set_variables(self, variables):
797806 :param dict variables: the new dictionary of all variables of the instance
798807
799808 """
800- return self ._perform_empty (
801- "PUT" , "/admin/variables/" , body = variables )
809+ warnings .warn ("set_variables is deprecated, please use get_global_variables().save()" , DeprecationWarning )
810+ return DSSInstanceVariables (self , variables ).save ()
811+
812+ def get_resolved_variables (self , project_key = None , typed = False ):
813+ """
814+ Get a dictionary of resolved variables of the project.
815+
816+ :param str project_key: the project key, defaults to the current project if any
817+ :param bool typed: if True, the variable values will be typed in the returned dict, defaults to False
818+ :returns: a dictionary with instance and project variables merged
819+ """
820+ import dataiku
821+ return self ._perform_json (
822+ "GET" ,
823+ "/projects/%s/variables-resolved" % (dataiku .default_project_key () if project_key is None else project_key ),
824+ params = {
825+ "typed" : "true" if typed else "false"
826+ })
802827
803828
804829 ########################################################
@@ -960,7 +985,7 @@ def get_auth_info_from_browser_headers(self, headers_dict, with_secrets=False):
960985 """
961986 return self ._perform_json ("POST" , "/auth/info-from-browser-headers" ,
962987 params = {"withSecrets" : with_secrets }, body = headers_dict )
963-
988+
964989 def get_ticket_from_browser_headers (self , headers_dict ):
965990 """
966991 Returns a ticket for the DSS user authenticated by the dictionary of
0 commit comments