# This file is auto-generated by oagen. Do not edit.

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Dict, Optional
from workos._types import _raise_deserialize_error


@dataclass(slots=True)
class CreateGroup:
    """Create Group model."""

    name: str
    """The name of the Group."""
    description: Optional[str] = None
    """An optional description of the Group."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "CreateGroup":
        """Deserialize from a dictionary."""
        try:
            return cls(
                name=data["name"],
                description=data.get("description"),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("CreateGroup", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["name"] = self.name
        if self.description is not None:
            result["description"] = self.description
        else:
            result["description"] = None
        return result
