@@ -313,7 +313,7 @@ def updateExtensions(self, extensions_ids: list)->object:
313313
314314 def setEnvironments (self , environments_list : list , dev_name : str = None )-> None :
315315 """
316- Save the different environments ids available.
316+ Save the different environments ids available in a config variable.
317317 It is required to use the library class.
318318 Arguments :
319319 environments_list : REQUIRED : list of environment retrieved by the getEnvironments method
@@ -340,14 +340,29 @@ def _setEnvironment(self, obj: dict,verbose:bool=False)->None:
340340 res = new_env
341341 return res
342342
343+ def setEnvironment (self , env_id : str ,verbose :bool = False )-> None :
344+ """
345+ Set the environment of the library.
346+ Arguments:
347+ env_id : REQUIRED : The environment id you want to set.
348+ """
349+ obj = {
350+ "data" : {
351+ "id" : env_id ,
352+ "type" : "environments"
353+ }
354+ }
355+ res = self ._setEnvironment (obj ,verbose = verbose )
356+ return res
357+
343358 def _removeEnvironment (self )-> None :
344359 """
345360 Remove environment
346361 """
347362 path = f'/libraries/{ self .id } /relationships/environment'
348363 new_env = self .connector .getData (self .endpoint + path )
349364 return new_env
350-
365+
351366 def updateLibrary (self ,empty :bool = False )-> dict :
352367 """
353368 Update the library
@@ -383,12 +398,14 @@ def updateLibrary(self,empty:bool=False)->dict:
383398 return res
384399
385400
386- def build (self ,verbose :bool = False )-> dict :
401+ def build (self ,timesleep : int = 20 , verbose :bool = False )-> dict :
387402 """
388403 Build the library.
389404 Part of the code takes care of assigning the right environement before building the library.
390405 Returns the build when it is completed (succeed or not).
391- It will check every 15 seconds for the build status, making sure it is not "pending".
406+ Arguments:
407+ timesleep : OPTIONAL : How many seconds to wait between each check of the build status. Default to 20 seconds.
408+ It will check every 20 seconds for the build status, making sure it is not "pending".
392409 """
393410 if self .build_required == False and self .state != 'approved' :
394411 return 'build is not required'
@@ -430,7 +447,7 @@ def build(self,verbose:bool=False)->dict:
430447 build_status = build ['data' ]['attributes' ]['status' ]
431448 while build_status == 'pending' :
432449 print ('pending...' )
433- time .sleep (20 )
450+ time .sleep (timesleep )
434451 # return the json directly
435452 build = self .connector .getData (
436453 config .endpoints ['global' ]+ '/builds/' + str (build_id ))
0 commit comments