"""ServiceConfig Model."""

from typing import Optional

from netorca_sdk.v2.base import BaseModel


class ServiceConfig(BaseModel):
    """Service Config model."""

    @property
    def service_id(self) -> Optional[int]:
        """Get associated service ID."""
        return self._extract_nested_id(self.data.get('service'))

    @property
    def version(self) -> Optional[int]:
        """Get config version."""
        return self.data.get('version')

    @property
    def config(self) -> Optional[dict]:
        """Get configuration data."""
        return self.data.get('config')

    def __repr__(self) -> str:
        """String representation."""
        return f"ServiceConfig(id={self.id}, version={self.version})"
