from dataclasses import dataclass, field
from typing import Dict, Optional

from ._BaseModel import BaseModel
from ._ServerVariableModel import ServerVariableModel


@dataclass
class ServerModel(BaseModel):
    url: str
    description: str
    variables: Optional[Dict[str, ServerVariableModel]] = field(default_factory=dict)

    def add_variable(self, variable_name: str, variable: ServerVariableModel):
        self.variables[variable_name] = variable
