api.scenarios
api.scenarios
Functions
Name | Description |
---|---|
create_scenario | Create a new scenario object. |
delete_scenario | Delete a scenario from the database. |
edit_scenario | Edit a scenario object in the database. |
get_scenario | Get a scenario from the database by name. |
get_scenarios | Get all scenarios from the database. |
run_scenario | Run a scenario. |
save_scenario | Save the scenario to the database. |
create_scenario
api.scenarios.create_scenario(attrs)
Create a new scenario object.
Parameters
Name | Type | Description | Default |
---|---|---|---|
attrs | dict[str, Any] | The attributes of the scenario object to create. Should adhere to the ScenarioModel schema. | required |
Returns
Name | Type | Description |
---|---|---|
IScenario | The scenario object created from the attributes. |
Raises
Name | Type | Description |
---|---|---|
ValueError | If the attributes do not adhere to the ScenarioModel schema. |
delete_scenario
api.scenarios.delete_scenario(name)
Delete a scenario from the database.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the scenario to delete. | required |
Raises
Name | Type | Description |
---|---|---|
ValueError | If the scenario does not exist. |
edit_scenario
api.scenarios.edit_scenario(scenario)
Edit a scenario object in the database.
Parameters
Name | Type | Description | Default |
---|---|---|---|
scenario | IScenario | The scenario object to edit. | required |
Raises
Name | Type | Description |
---|---|---|
ValueError | If the scenario object does not exist. |
get_scenario
api.scenarios.get_scenario(name)
Get a scenario from the database by name.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the scenario to retrieve. | required |
Returns
Name | Type | Description |
---|---|---|
IScenario | The scenario object with the given name. |
Raises
Name | Type | Description |
---|---|---|
ValueError | If the scenario with the given name does not exist. |
get_scenarios
api.scenarios.get_scenarios()
Get all scenarios from the database.
Returns
Name | Type | Description |
---|---|---|
dict[str, Any] | A dictionary containing all scenarios. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’. Each value is a list of the corresponding attribute for each scenario. |
run_scenario
api.scenarios.run_scenario(name)
Run a scenario.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name | Union[str, list[str]] | The name(s) of the scenario to run. | required |
Raises
Name | Type | Description |
---|---|---|
ValueError | If the scenario does not exist. |
save_scenario
api.scenarios.save_scenario(scenario)
Save the scenario to the database.
Parameters
Name | Type | Description | Default |
---|---|---|---|
scenario | IScenario | The scenario to save. | required |
Returns
Name | Type | Description |
---|---|---|
bool | Whether the scenario was saved successfully. | |
str | The error message if the scenario was not saved successfully. |