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

@dataclass
class ManagementOrganizationMembersListOutputItemsPolicies:
    object: str
    id: str
    type: str
    name: str
    slug: str
@dataclass
class ManagementOrganizationMembersListOutputItemsActorTeams:
    id: str
    name: str
    slug: str
    assignment_id: str
    created_at: datetime
    updated_at: datetime
@dataclass
class ManagementOrganizationMembersListOutputItemsActor:
    object: str
    id: str
    type: str
    organization_id: str
    name: str
    image_url: str
    teams: List[ManagementOrganizationMembersListOutputItemsActorTeams]
    created_at: datetime
    updated_at: datetime
    email: Optional[str] = None
@dataclass
class ManagementOrganizationMembersListOutputItems:
    object: str
    id: str
    status: str
    role: str
    user_id: str
    organization_id: str
    actor_id: str
    policies: List[ManagementOrganizationMembersListOutputItemsPolicies]
    last_active_at: datetime
    created_at: datetime
    updated_at: datetime
    deleted_at: datetime
    actor: ManagementOrganizationMembersListOutputItemsActor
@dataclass
class ManagementOrganizationMembersListOutputPagination:
    has_more_before: bool
    has_more_after: bool
@dataclass
class ManagementOrganizationMembersListOutput:
    items: List[ManagementOrganizationMembersListOutputItems]
    pagination: ManagementOrganizationMembersListOutputPagination


class mapManagementOrganizationMembersListOutputItemsPolicies:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationMembersListOutputItemsPolicies:
        return ManagementOrganizationMembersListOutputItemsPolicies(
        object=data.get('object'),
        id=data.get('id'),
        type=data.get('type'),
        name=data.get('name'),
        slug=data.get('slug')
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationMembersListOutputItemsPolicies, 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 mapManagementOrganizationMembersListOutputItemsActorTeams:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationMembersListOutputItemsActorTeams:
        return ManagementOrganizationMembersListOutputItemsActorTeams(
        id=data.get('id'),
        name=data.get('name'),
        slug=data.get('slug'),
        assignment_id=data.get('assignment_id'),
        created_at=datetime.fromisoformat(data.get('created_at').replace('Z', '+00:00')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at').replace('Z', '+00:00')) if data.get('updated_at') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationMembersListOutputItemsActorTeams, 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 mapManagementOrganizationMembersListOutputItemsActor:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationMembersListOutputItemsActor:
        return ManagementOrganizationMembersListOutputItemsActor(
        object=data.get('object'),
        id=data.get('id'),
        type=data.get('type'),
        organization_id=data.get('organization_id'),
        name=data.get('name'),
        email=data.get('email'),
        image_url=data.get('image_url'),
        teams=[mapManagementOrganizationMembersListOutputItemsActorTeams.from_dict(item) for item in data.get('teams', []) if item],
        created_at=datetime.fromisoformat(data.get('created_at').replace('Z', '+00:00')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at').replace('Z', '+00:00')) if data.get('updated_at') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationMembersListOutputItemsActor, 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 mapManagementOrganizationMembersListOutputItems:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationMembersListOutputItems:
        return ManagementOrganizationMembersListOutputItems(
        object=data.get('object'),
        id=data.get('id'),
        status=data.get('status'),
        role=data.get('role'),
        user_id=data.get('user_id'),
        organization_id=data.get('organization_id'),
        actor_id=data.get('actor_id'),
        policies=[mapManagementOrganizationMembersListOutputItemsPolicies.from_dict(item) for item in data.get('policies', []) if item],
        last_active_at=datetime.fromisoformat(data.get('last_active_at').replace('Z', '+00:00')) if data.get('last_active_at') else None,
        created_at=datetime.fromisoformat(data.get('created_at').replace('Z', '+00:00')) if data.get('created_at') else None,
        updated_at=datetime.fromisoformat(data.get('updated_at').replace('Z', '+00:00')) if data.get('updated_at') else None,
        deleted_at=datetime.fromisoformat(data.get('deleted_at').replace('Z', '+00:00')) if data.get('deleted_at') else None,
        actor=mapManagementOrganizationMembersListOutputItemsActor.from_dict(data.get('actor')) if data.get('actor') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationMembersListOutputItems, 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 mapManagementOrganizationMembersListOutputPagination:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationMembersListOutputPagination:
        return ManagementOrganizationMembersListOutputPagination(
        has_more_before=data.get('has_more_before'),
        has_more_after=data.get('has_more_after')
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationMembersListOutputPagination, 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 mapManagementOrganizationMembersListOutput:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationMembersListOutput:
        return ManagementOrganizationMembersListOutput(
        items=[mapManagementOrganizationMembersListOutputItems.from_dict(item) for item in data.get('items', []) if item],
        pagination=mapManagementOrganizationMembersListOutputPagination.from_dict(data.get('pagination')) if data.get('pagination') else None
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationMembersListOutput, 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 ManagementOrganizationMembersListQuery:
    limit: Optional[float] = None
    after: Optional[str] = None
    before: Optional[str] = None
    cursor: Optional[str] = None
    order: Optional[str] = None
    team_id: Optional[Union[str, List[str]]] = None


class mapManagementOrganizationMembersListQuery:
    @staticmethod
    def from_dict(data: Dict[str, Any]) -> ManagementOrganizationMembersListQuery:
        return ManagementOrganizationMembersListQuery(
        limit=data.get('limit'),
        after=data.get('after'),
        before=data.get('before'),
        cursor=data.get('cursor'),
        order=data.get('order'),
        team_id=data.get('team_id')
        )

    @staticmethod
    def to_dict(value: Union[ManagementOrganizationMembersListQuery, 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)

