Skip to content

fetch_user_scenarios

fetch_user_scenarios

Service for fetching user scenarios (ETEngine sessions).

Classes

FetchUserScenariosRunner

Bases: BaseRunner[List[Dict[str, Any]]]

Runner for fetching all scenarios belonging to the authenticated user.

GET /api/v3/scenarios

Supports pagination via query parameters: - page: Page number (1-indexed) - if provided, fetches only that page - per_page: Results per page (default 25)

When page is not provided, automatically fetches all pages.

Functions
run staticmethod
run(client, page=None, per_page=None, **kwargs)

Fetch scenarios for the authenticated user.

Parameters:

Name Type Description Default
client BaseClient

HTTP client with authentication

required
page Optional[int]

Optional page number. If provided, fetches only that page. If None, fetches all pages automatically.

None
per_page Optional[int]

Optional number of results per page

None
**kwargs Any

Additional query parameters

{}

Returns:

Type Description
ServiceResult[List[Dict[str, Any]]]

ServiceResult with list of scenario data dictionaries

Source code in src/pyetm/services/scenario_runners/fetch_user_scenarios.py
@staticmethod
def run(
    client: BaseClient,
    page: Optional[int] = None,
    per_page: Optional[int] = None,
    **kwargs: Any,
) -> ServiceResult[List[Dict[str, Any]]]:
    """
    Fetch scenarios for the authenticated user.

    Args:
        client: HTTP client with authentication
        page: Optional page number. If provided, fetches only that page.
              If None, fetches all pages automatically.
        per_page: Optional number of results per page
        **kwargs: Additional query parameters

    Returns:
        ServiceResult with list of scenario data dictionaries
    """
    # If page is explicitly provided, fetch only that page
    if page is not None:
        return FetchUserScenariosRunner._fetch_single_page(
            client, page, per_page, kwargs
        )

    # Otherwise, fetch all pages automatically
    return FetchUserScenariosRunner._fetch_all_pages(client, per_page, kwargs)