44from .savedmodel import DSSSavedModel
55from .recipe import DSSRecipe , DSSRecipeDefinitionAndPayload
66from .future import DSSFuture
7+ from .streaming_endpoint import DSSStreamingEndpoint
78import logging , json
89
910class DSSProjectFlow (object ):
@@ -145,6 +146,8 @@ def _to_smart_ref(self, obj):
145146 ot = "SAVED_MODEL"
146147 elif isinstance (obj , DSSRecipe ):
147148 ot = "RECIPE"
149+ elif isinstance (obj , DSSStreamingEndpoint ):
150+ ot = "STREAMING_ENDPOINT"
148151 else :
149152 raise ValueError ("Cannot transform to DSS object ref: %s" % obj )
150153
@@ -286,6 +289,10 @@ def id(self):
286289 def name (self ):
287290 return self ._raw ["name" ]
288291
292+ @property
293+ def color (self ):
294+ return self ._raw ["color" ]
295+
289296 def __repr__ (self ):
290297 return "<dataikuapi.dss.flow.DSSFlowZone (id=%s, name=%s)>" % (self .id , self .name )
291298
@@ -310,6 +317,8 @@ def _to_native_obj(self, zone_item):
310317 return p .get_saved_model (zone_item ["objectId" ])
311318 elif zone_item ["objectType" ] == "RECIPE" :
312319 return p .get_recipe (zone_item ["objectId" ])
320+ elif zone_item ["objectType" ] == "STREAMING_ENDPOINT" :
321+ return p .get_streaming_endpoint (zone_item ["objectId" ])
313322 else :
314323 raise ValueError ("Cannot transform to DSS object: %s" % zone_item )
315324
@@ -323,22 +332,9 @@ def add_item(self, obj):
323332 :param object obj: A :class:`dataikuapi.dss.dataset.DSSDataset`, :class:`dataikuapi.dss.managedfolder.DSSManagedFolder`,
324333 or :class:`dataikuapi.dss.savedmodel.DSSSavedModel` to add to the zone
325334 """
326- self .client ._perform_empty ("POST" , "/projects/%s/flow/zones/%s/items" % (self .flow .project .project_key , self .id ),
335+ self ._raw = self . client ._perform_json ("POST" , "/projects/%s/flow/zones/%s/items" % (self .flow .project .project_key , self .id ),
327336 body = self .flow ._to_smart_ref (obj ))
328337
329- #. TBD: if we make "add to default" work propertly, then we don't need thjis
330- #def remove_item(self, obj):
331- # """
332- # Removes an item to this zone.#
333- #
334- # :param object obj: A :class:`dataikuapi.dss.dataset.DSSDataset`, :class:`dataikuapi.dss.managedfolder.DSSManagedFolder`,
335- # or :class:`dataikuapi.dss.savedmodel.DSSSavedModel` to add to the zone
336- # """
337- # sr = self._to_smart_ref(obj)
338- #
339- # self.client._perform_empty("DELETE", "/projects/%s/flow/zones/%s/items/%s/%s" % (self.flow.project.project_key,
340- # self.id, sr["objectType"], sr["objectId"]))
341-
342338 @property
343339 def items (self ):
344340 """
@@ -356,6 +352,28 @@ def items(self):
356352 """
357353 return [self ._to_native_obj (i ) for i in self ._raw ["items" ]]
358354
355+ def add_shared (self , obj ):
356+ """
357+ Share an item to this zone.
358+
359+ The item will not be automatically unshared from its existing zone.
360+
361+ :param object obj: A :class:`dataikuapi.dss.dataset.DSSDataset`, :class:`dataikuapi.dss.managedfolder.DSSManagedFolder`,
362+ or :class:`dataikuapi.dss.savedmodel.DSSSavedModel` to share to the zone
363+ """
364+ self ._raw = self .client ._perform_json ("POST" , "/projects/%s/flow/zones/%s/shared" % (self .flow .project .project_key , self .id ),
365+ body = self .flow ._to_smart_ref (obj ))
366+
367+ def remove_shared (self , obj ):
368+ """
369+ Remove a shared item from this zone.
370+
371+ :param object obj: A :class:`dataikuapi.dss.dataset.DSSDataset`, :class:`dataikuapi.dss.managedfolder.DSSManagedFolder`,
372+ or :class:`dataikuapi.dss.savedmodel.DSSSavedModel` to share to the zone
373+ """
374+ smartRef = self .flow ._to_smart_ref (obj )
375+ self ._raw = self .client ._perform_json ("DELETE" , "/projects/%s/flow/zones/%s/shared/%s/%s" % (self .flow .project .project_key , self .id , smartRef ['objectType' ], smartRef ['objectId' ]))
376+
359377 @property
360378 def shared (self ):
361379 """
@@ -397,6 +415,14 @@ def name(self):
397415 def name (self , new_name ):
398416 self ._raw ["name" ] = new_name
399417
418+ @property
419+ def color (self ):
420+ return self ._raw ["color" ]
421+
422+ @color .setter
423+ def color (self , new_color ):
424+ self ._raw ["color" ] = new_color
425+
400426 def save (self ):
401427 """Saves the settings of the zone"""
402428 self ._zone .client ._perform_empty ("PUT" , "/projects/%s/flow/zones/%s" % (self ._zone .flow .project .project_key , self ._zone .id ),
0 commit comments