"""Application Model."""

from typing import Optional

from netorca_sdk.v2.base import BaseModel


class Application(BaseModel):
    """Application model."""

    @property
    def name(self) -> Optional[str]:
        """Get application name."""
        return self.data.get('name')

    @property
    def description(self) -> Optional[str]:
        """Get application description."""
        return self.data.get('description')

    @property
    def owner_id(self) -> Optional[int]:
        """Get owner team ID."""
        return self._extract_nested_id(self.data.get('owner'))

    @property
    def owner_name(self) -> Optional[str]:
        """Get owner team name."""
        return self._extract_nested_field(self.data.get('owner'), 'name')

    def __repr__(self) -> str:
        """String representation."""
        return f"Application(id={self.id}, name={self.name!r})"
