|
1 | 1 | import time, warnings, sys, os.path as osp |
2 | 2 | from .dataset import DSSDataset, DSSDatasetListItem, DSSManagedDatasetCreationHelper |
3 | 3 | from .streaming_endpoint import DSSStreamingEndpoint, DSSStreamingEndpointListItem, DSSManagedStreamingEndpointCreationHelper |
4 | | -from .recipe import DSSRecipe |
| 4 | +from .recipe import DSSRecipeListItem, DSSRecipe |
5 | 5 | from . import recipe |
6 | 6 | from .managedfolder import DSSManagedFolder |
7 | 7 | from .savedmodel import DSSSavedModel |
@@ -990,15 +990,23 @@ def create_scenario(self, scenario_name, type, definition=None): |
990 | 990 | # Recipes |
991 | 991 | ######################################################## |
992 | 992 |
|
993 | | - def list_recipes(self): |
| 993 | + def list_recipes(self, as_type="listitems"): |
994 | 994 | """ |
995 | 995 | List the recipes in this project |
996 | | - |
997 | | - Returns: |
998 | | - the list of the recipes, each one as a JSON object |
| 996 | +
|
| 997 | + :param str as_type: How to return the list. Supported values are "listitems" and "objects". |
| 998 | + :returns: The list of the recipes. If "as_type" is "listitems", each one as a :class:`recipe.DSSRecipeListItem`. |
| 999 | + If "as_type" is "objects", each one as a :class:`recipe.DSSRecipe` |
| 1000 | + :rtype: list |
999 | 1001 | """ |
1000 | | - return self.client._perform_json( |
1001 | | - "GET", "/projects/%s/recipes/" % self.project_key) |
| 1002 | + items = self.client._perform_json("GET", "/projects/%s/recipes/" % self.project_key) |
| 1003 | + if as_type == "listitems" or as_type == "listitem": |
| 1004 | + return [DSSRecipeListItem(self.client, item) for item in items] |
| 1005 | + elif as_type == "objects" or as_type == "object": |
| 1006 | + return [DSSRecipe(self.client, self.project_key, item["name"]) for item in items] |
| 1007 | + else: |
| 1008 | + raise ValueError("Unknown as_type") |
| 1009 | + |
1002 | 1010 |
|
1003 | 1011 | def get_recipe(self, recipe_name): |
1004 | 1012 | """ |
|
0 commit comments