from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Union
from datetime import datetime
import dataclasses

@dataclass
class ManagementOrganizationTeamsProjectsSetOutputProjectsProject:
    object: str
    id: str
    status: str
    slug: str
    name: str
    organization_id: str
    created_at: datetime
    updated_at: datetime
@dataclass
class ManagementOrganizationTeamsProjectsSetOutputProjectsRolesRole:
    object: str
    id: str
    organization_id: str
    name: str
    slug: str
    permissions: List[str]
    created_at: datetime
    updated_at: datetime
    description: Optional[str] = None
@dataclass
class ManagementOrganizationTeamsProjectsSetOutputProjectsRoles:
    id: str
    role: ManagementOrganizationTeamsProjectsSetOutputProjectsRolesRole
    created_at: datetime
    updated_at: datetime
@dataclass
class ManagementOrganizationTeamsProjectsSetOutputProjects:
    id: str
    created_at: datetime
    updated_at: datetime
    project: ManagementOrganizationTeamsProjectsSetOutputProjectsProject
    roles: List[ManagementOrganizationTeamsProjectsSetOutputProjectsRoles]
@dataclass
class ManagementOrganizationTeamsProjectsSetOutput:
    object: str
    id: str
    organization_id: str
    name: str
    slug: str
    projects: List[ManagementOrganizationTeamsProjectsSetOutputProjects]
    created_at: datetime
    updated_at: datetime
    description: Optional[str] = None


class mapManagementOrganizationTeamsProjectsSetOutputProjectsProject:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationTeamsProjectsSetOutputProjectsProject:
        return ManagementOrganizationTeamsProjectsSetOutputProjectsProject(
        object=data.get('object'),
        id=data.get('id'),
        status=data.get('status'),
        slug=data.get('slug'),
        name=data.get('name'),
        organization_id=data.get('organization_id'),
        created_at=datetime.fromisoformat(data.get('created_at')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at')) if data.get('updated_at') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationTeamsProjectsSetOutputProjectsProject, Dict[str, Any], None]) -> Optional[Dict[str, Any]]:
        if value is None:
            return None
        if isinstance(value, dict):
            return value
        return dataclasses.asdict(value)

class mapManagementOrganizationTeamsProjectsSetOutputProjectsRolesRole:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationTeamsProjectsSetOutputProjectsRolesRole:
        return ManagementOrganizationTeamsProjectsSetOutputProjectsRolesRole(
        object=data.get('object'),
        id=data.get('id'),
        organization_id=data.get('organization_id'),
        name=data.get('name'),
        slug=data.get('slug'),
        description=data.get('description'),
        permissions=data.get('permissions', []),
        created_at=datetime.fromisoformat(data.get('created_at')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at')) if data.get('updated_at') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationTeamsProjectsSetOutputProjectsRolesRole, Dict[str, Any], None]) -> Optional[Dict[str, Any]]:
        if value is None:
            return None
        if isinstance(value, dict):
            return value
        return dataclasses.asdict(value)

class mapManagementOrganizationTeamsProjectsSetOutputProjectsRoles:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationTeamsProjectsSetOutputProjectsRoles:
        return ManagementOrganizationTeamsProjectsSetOutputProjectsRoles(
        id=data.get('id'),
        role=mapManagementOrganizationTeamsProjectsSetOutputProjectsRolesRole.from_dict(data.get('role')) if data.get('role') else None,
        created_at=datetime.fromisoformat(data.get('created_at')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at')) if data.get('updated_at') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationTeamsProjectsSetOutputProjectsRoles, Dict[str, Any], None]) -> Optional[Dict[str, Any]]:
        if value is None:
            return None
        if isinstance(value, dict):
            return value
        return dataclasses.asdict(value)

class mapManagementOrganizationTeamsProjectsSetOutputProjects:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationTeamsProjectsSetOutputProjects:
        return ManagementOrganizationTeamsProjectsSetOutputProjects(
        id=data.get('id'),
        created_at=datetime.fromisoformat(data.get('created_at')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at')) if data.get('updated_at') else None,
        project=mapManagementOrganizationTeamsProjectsSetOutputProjectsProject.from_dict(data.get('project')) if data.get('project') else None,
        roles=[mapManagementOrganizationTeamsProjectsSetOutputProjectsRoles.from_dict(item) for item in data.get('roles', []) if item]
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationTeamsProjectsSetOutputProjects, Dict[str, Any], None]) -> Optional[Dict[str, Any]]:
        if value is None:
            return None
        if isinstance(value, dict):
            return value
        return dataclasses.asdict(value)

class mapManagementOrganizationTeamsProjectsSetOutput:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationTeamsProjectsSetOutput:
        return ManagementOrganizationTeamsProjectsSetOutput(
        object=data.get('object'),
        id=data.get('id'),
        organization_id=data.get('organization_id'),
        name=data.get('name'),
        slug=data.get('slug'),
        description=data.get('description'),
        projects=[mapManagementOrganizationTeamsProjectsSetOutputProjects.from_dict(item) for item in data.get('projects', []) if item],
        created_at=datetime.fromisoformat(data.get('created_at')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at')) if data.get('updated_at') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationTeamsProjectsSetOutput, Dict[str, Any], None]) -> Optional[Dict[str, Any]]:
        if value is None:
            return None
        if isinstance(value, dict):
            return value
        # assume dataclass for generated models
        return dataclasses.asdict(value)

@dataclass
class ManagementOrganizationTeamsProjectsSetBody:
    project_id: str
    team_role_ids: List[str]


class mapManagementOrganizationTeamsProjectsSetBody:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationTeamsProjectsSetBody:
        return ManagementOrganizationTeamsProjectsSetBody(
        project_id=data.get('project_id'),
        team_role_ids=data.get('team_role_ids', [])
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationTeamsProjectsSetBody, Dict[str, Any], None]) -> Optional[Dict[str, Any]]:
        if value is None:
            return None
        if isinstance(value, dict):
            return value
        # assume dataclass for generated models
        return dataclasses.asdict(value)
