|
6 | 6 | from .managedfolder import DSSManagedFolder |
7 | 7 | from .savedmodel import DSSSavedModel |
8 | 8 | from .job import DSSJob, DSSJobWaiter |
| 9 | +from .scenario import DSSScenario, DSSScenarioListItem |
9 | 10 | from .continuousactivity import DSSContinuousActivity |
10 | | -from .scenario import DSSScenario |
11 | 11 | from .apiservice import DSSAPIService |
12 | 12 | from .future import DSSFuture |
13 | 13 | from .notebook import DSSNotebook |
@@ -907,18 +907,22 @@ def preload_bundle(self, bundle_id): |
907 | 907 | # Scenarios |
908 | 908 | ######################################################## |
909 | 909 |
|
910 | | - def list_scenarios(self): |
| 910 | + def list_scenarios(self, as_type="listitems"): |
911 | 911 | """ |
912 | 912 | List the scenarios in this project. |
913 | 913 |
|
914 | | - This method returns a list of Python dictionaries. Each dictionary represents |
915 | | - a scenario. Each dictionary contains at least a "id" field, that you can then pass |
916 | | - to the :meth:`get_scenario` |
917 | | -
|
918 | | - :returns: the list of scenarios, each one as a Python dictionary |
| 914 | + :param str as_type: How to return the list. Supported values are "listitems" and "objects". |
| 915 | + :returns: The list of the datasets. If "rtype" is "listitems", each one as a :class:`scenario.DSSScenarioListItem`. |
| 916 | + If "rtype" is "objects", each one as a :class:`scenario.DSSScenario` |
| 917 | + :rtype: list |
919 | 918 | """ |
920 | | - return self.client._perform_json( |
921 | | - "GET", "/projects/%s/scenarios/" % self.project_key) |
| 919 | + items = self.client._perform_json("GET", "/projects/%s/scenarios/" % self.project_key) |
| 920 | + if as_type == "listitems": |
| 921 | + return [DSSScenarioListItem(self.client, item) for item in items] |
| 922 | + elif as_type == "objects": |
| 923 | + return [DSSScenario(self.client, self.project_key, item["id"]) for item in items] |
| 924 | + else: |
| 925 | + raise ValueError("Unknown as_type") |
922 | 926 |
|
923 | 927 | def get_scenario(self, scenario_id): |
924 | 928 | """ |
|
0 commit comments