#  Copyright (C) 2025
#  ABM, Moscow
#
#  UNPUBLISHED PROPRIETARY MATERIAL.
#  ALL RIGHTS RESERVED.
#
#  Authors: Mike Orlov <m.orlov@abm-jsc.ru>
from dataclasses import dataclass, field
from typing import Any, ClassVar

from http_tools import IncomingRequest

from .parameter_location import ParameterLocation
from .spec_parameter import SpecParameter


@dataclass(frozen=True, slots=True, kw_only=True)
class PathParameter(SpecParameter):
    is_optional: bool = field(init=False, default=False)
    location: ClassVar[ParameterLocation] = ParameterLocation.path

    def _get(self, incoming_request: IncomingRequest) -> Any:
        return incoming_request.path_match_key_to_value[self.name]

    def __repr__(self):
        return f'{self.__class__.__name__}({", ".join(self._get_repr_parts())})'

    __str__ = __repr__
