@@ -861,6 +861,58 @@ def __init__(self, name, project):
861861# Per-recipe-type classes: Code recipes
862862#####################################################
863863
864+ class CodeRecipeSettings (DSSRecipeSettings ):
865+ """
866+ Settings of a code recipe. Do not create this directly, use :meth:`DSSRecipe.get_settings`
867+ """
868+ def get_code (self ):
869+ """
870+ Returns the code of the recipe as a string
871+ :rtype string
872+ """
873+ self ._payload_to_str ()
874+ return self .str_payload
875+
876+ def set_code (self , code ):
877+ """
878+ Updates the code of the recipe
879+ :param str code: The new code as a string
880+ """
881+ self .set_payload (code )
882+
883+ def get_code_env_settings (self ):
884+ """
885+ Returns the code env settings for this recipe
886+ :rtype dict
887+ """
888+ rp = self .get_recipe_params ()
889+ if not "envSelection" in rp :
890+ raise ValueError ("This recipe kind does not seem to take a code env selection" )
891+ return rp ["envSelection" ]
892+
893+ def set_code_env (self , code_env = None , inherit = False , use_builtin = False ):
894+ """
895+ Sets the code env to use for this recipe.
896+
897+ Exactly one of `code_env`, `inherit` or `use_builtin` must be passed
898+
899+ :param str code_env: The name of a code env
900+ :param bool inherit: Use the project's default code env
901+ :param bool use_builtin: Use the builtin code env
902+ """
903+ rp = self .get_recipe_params ()
904+ if not "envSelection" in rp :
905+ raise ValueError ("This recipe kind does not seem to take a code env selection" )
906+
907+ if code_env is not None :
908+ rp ["envSelection" ] = {"envMode" : "EXPLICIT_ENV" , "envName" : "code_env" }
909+ elif inherit :
910+ rp ["envSelection" ] = {"envMode" : "INHERIT" }
911+ elif use_builtin :
912+ rp ["envSelection" ] = {"envMode" : "USE_BUILTIN_MODE" }
913+ else :
914+ raise ValueError ("No env setting selected" )
915+
864916class CodeRecipeCreator (DSSRecipeCreator ):
865917 def __init__ (self , name , type , project ):
866918 """
0 commit comments