@@ -254,3 +254,51 @@ def get_object_discussions(self):
254254 :rtype: :class:`dataikuapi.discussion.DSSObjectDiscussions`
255255 """
256256 return DSSObjectDiscussions (self .client , self .project_key , "DATASET" , self .dataset_name )
257+
258+ class DSSManagedDatasetCreationHelper (object ):
259+
260+ def __init__ (self , project , dataset_name ):
261+ self .project = project
262+ self .dataset_name = dataset_name
263+ self .creation_settings = { "specificSettings" : {} }
264+
265+ def get_creation_settings ():
266+ return self .creation_settings
267+
268+ def with_store_into (self , connection , type_option_id = None , format_option_id = None ):
269+ """
270+ Sets the connection into which to store the new managed dataset
271+ :param str connection: Name of the connection to store into
272+ :param str type_option_id: If the connection accepts several types of datasets, the type
273+ :param str format_option_id: Optional identifier of a file format option
274+ :return: self
275+ """
276+ self .creation_settings ["connectionId" ] = connection
277+ if type_option_id is not None :
278+ self .creation_settings ["typeOptionId" ] = type_option_id
279+ if format_option_id is not None :
280+ self .creation_settings ["specificSettings" ]["formatOptionId" ] = format_option_id
281+ return self
282+
283+ def with_copy_partitioning_from (self , dataset_ref ):
284+ """
285+ Sets the new managed dataset to use the same partitioning as an existing dataset_name
286+
287+ :param str dataset_ref: Name of the dataset to copy partitioning from
288+ :return: self
289+ """
290+ self ["partitioningOptionId" ] = "copy:%s" % dataset_ref
291+ return self
292+
293+ def create (self ):
294+ """
295+ Executes the creation of the managed dataset according to the selected options
296+
297+ :return: The :class:`DSSDataset` corresponding to the newly created dataset
298+ """
299+ self .project .client ._perform_json ("POST" , "/projects/%s/datasets/managed" % self .project .project_key ,
300+ body = {
301+ "name" : self .dataset_name ,
302+ "creationSettings" : self .creation_settings
303+ })
304+ return DSSDataset (self .project .client , self .project .project_key , self .dataset_name )
0 commit comments