utils.rcclient.entities.scenario
Module that defines the Scenario class, which represents a scenario in the system.
Classes: - Scenario: A class representing a scenario, with methods to create,
retrieve, update, and delete scenarios.
Variable: A nested class representing a scenario variable.
Module Contents
Classes
A class representing a scenario object that contains various properties |
Attributes
- utils.rcclient.entities.scenario.logger
- class utils.rcclient.entities.scenario.Scenario
A class representing a scenario object that contains various properties such as its name, project ID, description, variables, shared variables, segment IDs, and segments. It also includes several methods to interact with the ScenarioService and manage the scenario object.
- name
The name of the scenario.
- Type:
str
- project_id
The ID of the project the scenario belongs to. Defaults to None.
- Type:
str, optional
- _id
The ID of the scenario. Defaults to None.
- Type:
str, optional
- description
A description of the scenario. Defaults to None.
- Type:
str, optional
- variables
A list of variables associated with the scenario. Defaults to an empty list.
- Type:
List[Scenario.Variable], optional
A dictionary of shared variables associated with the scenario. Defaults to an empty dictionary.
- Type:
Dict[str, str], optional
- segment_ids
A list of segment IDs associated with the scenario. Defaults to an empty list.
- Type:
List[str], optional
- segments
A list of segment objects associated with the scenario. Defaults to an empty list.
- Type:
List[Segment], optional
- scenario_service
The service used to interact with the scenarios.
- Type:
ClassVar[ScenarioService]
- from_(res_dto)
Constructs a scenario object from a ScenarioResponseDto object.
- get(_id)
Retrieves a scenario object by ID.
- find(project_id, name=None, experiment_id=None)
Retrieves a list of scenarios that match the given criteria.
- save()
Saves the scenario object.
- delete()
Deletes the scenario object.
- add_segments(segments)
Adds the given segments to the scenario.
- class Variable
A class representing a variable associated with a scenario.
- variable_name
The name of the variable.
- Type:
str
- variable_value
The value of the variable.
- Type:
str
- recipe_name
The name of the recipe the variable belongs to. Defaults to None.
- Type:
str, optional
- transform_name
The name of the transform the variable belongs to. Defaults to None.
- Type:
str, optional
- variable_name: str
- variable_value: str
- recipe_name: str
- transform_name: str
- classmethod from_(res_dto: utils.rcclient.dtos.response_dtos.ScenarioResponseDto.VariableResponseDto) Scenario
- Constructs a Variable object from a
ScenarioResponseDto.VariableResponseDto object.
- Parameters:
res_dto (ScenarioResponseDto.VariableResponseDto) – The DTO object containing the variable data.
- Returns:
The constructed Variable object.
- Return type:
- classmethod from_recipe(recipe: utils.rcclient.entities.recipe.Recipe)
Constructs a list of Variable objects from a recipe object.
- Parameters:
recipe (Recipe) – The recipe object to extract variables from.
- Returns:
The list
- Return type:
List[Scenario.Variable]
- name: str
- project_id: str
- _id: str
- description: str
- shared_variables: Dict[str, str]
- segment_ids: List[str]
- segments: List[utils.rcclient.entities.segment.Segment]
- scenario_service: ClassVar[utils.rcclient.services.scenario_service.ScenarioService]
- classmethod from_(res_dto: utils.rcclient.dtos.response_dtos.ScenarioResponseDto) Scenario
Create a new Scenario instance from a ScenarioResponseDto object.
- Parameters:
res_dto – A ScenarioResponseDto object containing the information about the scenario.
- Returns:
- A new Scenario instance with the information from the
ScenarioResponseDto object.
- classmethod get(_id: str) Scenario
Retrieves a scenario by its ID using a scenario service.
- Parameters:
_id (str) – The ID of the scenario to retrieve.
- Returns:
The retrieved scenario.
- Return type:
- Raises:
ValueError – If the scenario with the given ID could not be found.
- classmethod find(project_id: str, name: str = None, experiment_id: str = None) List[Scenario]
Find scenarios that match the given parameters.
- Parameters:
project_id – The ID of the project to search in.
name – The name of the scenarios to search for (optional).
experiment_id – The ID of the experiment to search in (optional).
- Returns:
A list of Scenario objects that match the search criteria.
- save() Scenario
- Saves the current Scenario object in the database and returns the saved
object.
- Returns:
The saved Scenario object.
- Return type:
- delete() None
Deletes the current scenario and logs the success.
- Raises:
An Exception if deletion fails. –
- add_segments(segments: List[utils.rcclient.entities.segment.Segment]) None
Adds the provided list of segments to the current Scenario object’s segment_ids attribute, excluding segments with None _id attributes.
- Parameters:
segments (List[Segment]) – A list of Segment objects to be added to the current Scenario object’s segments.
- Returns:
None