# Copyright (c) CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to legal@cloudzero.com

from aws_lambda_powertools.event_handler.router import APIGatewayRouter


class WebApiRouter(APIGatewayRouter):
    """
    CloudZero Web API router for handling internal web API routes.

    Extends AWS PowerTools APIGatewayRouter with CloudZero-specific functionality
    for internal web API endpoints. Automatically prefixes all routes with the
    organization path pattern '/organizations/<organizationId>'.
    """

    _base_route: str

    def __init__(self, base_route: str = ''):
        """
        Initialize the Web API router.

        Args:
            base_route: Additional route path to append after the organization prefix.
                       Will be prefixed with '/' if it doesn't start with one.
                       Final route pattern: /organizations/<organizationId>{base_route}
        """
        super().__init__()
        if base_route and not base_route.startswith('/'):
            base_route = f'/{base_route}'
        self._base_route = f'/organizations/<organizationId>{base_route}'

    @property
    def base_route(self) -> str:
        """
        Get the complete base route path for this router.

        Returns:
            str: The full route path including organization prefix: /organizations/<organizationId>{base_route}
        """
        return self._base_route
