Skip to content

break_preset_link

Service for breaking preset scenario links.

BreakPresetLinkRunner

Bases: BaseRunner[Dict[str, Any]]

Runner for breaking the preset link on a scenario.

This sets the preset_scenario_id to nil, making the scenario independent from its parent preset scenario.

PUT /api/v3/scenarios/{scenario_id}

Functions
run staticmethod
run(client, scenario, **kwargs)

Break the preset link for a scenario.

This makes the scenario independent by removing its connection to the preset scenario it was copied from.

Parameters:

Name Type Description Default
client BaseClient

The HTTP client to use

required
scenario Union[Any, int]

The scenario object (must have an 'id' attribute) or scenario ID

required
**kwargs Any

Additional arguments passed to the request

{}
Example usage

result = BreakPresetLinkRunner.run( client=client, scenario=scenario_obj )

Or with scenario ID:

result = BreakPresetLinkRunner.run( client=client, scenario=123456 )

Source code in src/pyetm/services/scenario_runners/break_preset_link.py
@staticmethod
def run(
    client: BaseClient, scenario: Union[Any, int], **kwargs: Any
) -> ServiceResult[Dict[str, Any]]:
    """
    Break the preset link for a scenario.

    This makes the scenario independent by removing its connection to the
    preset scenario it was copied from.

    Args:
        client: The HTTP client to use
        scenario: The scenario object (must have an 'id' attribute) or scenario ID
        **kwargs: Additional arguments passed to the request

    Example usage:
        result = BreakPresetLinkRunner.run(
            client=client,
            scenario=scenario_obj
        )

        # Or with scenario ID:
        result = BreakPresetLinkRunner.run(
            client=client,
            scenario=123456
        )
    """
    # Extract scenario ID
    scenario_id = scenario if isinstance(scenario, int) else scenario.id

    # Build payload to break the preset link
    payload = {"scenario": {"preset_scenario_id": None}}

    return BreakPresetLinkRunner._make_request(
        client=client,
        method="put",
        path=f"/scenarios/{scenario_id}",
        payload=payload,
    )