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

from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime
from typing import Any, Dict, List, Optional
from workos._types import _raise_deserialize_error
from workos._types import _format_datetime, _parse_datetime


@dataclass(slots=True)
class AuditLogExportCreation:
    """Audit Log Export Creation model."""

    organization_id: str
    """The unique ID of the Organization."""
    range_start: datetime
    """ISO-8601 value for start of the export range."""
    range_end: datetime
    """ISO-8601 value for end of the export range."""
    actions: Optional[List[str]] = None
    """List of actions to filter against."""
    actors: Optional[List[str]] = None
    """Deprecated. Use `actor_names` instead.

    .. deprecated:: This field is deprecated."""
    actor_names: Optional[List[str]] = None
    """List of actor names to filter against."""
    actor_ids: Optional[List[str]] = None
    """List of actor IDs to filter against."""
    targets: Optional[List[str]] = None
    """List of target types to filter against."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "AuditLogExportCreation":
        """Deserialize from a dictionary."""
        try:
            return cls(
                organization_id=data["organization_id"],
                range_start=_parse_datetime(data["range_start"]),
                range_end=_parse_datetime(data["range_end"]),
                actions=data.get("actions"),
                actors=data.get("actors"),
                actor_names=data.get("actor_names"),
                actor_ids=data.get("actor_ids"),
                targets=data.get("targets"),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AuditLogExportCreation", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["organization_id"] = self.organization_id
        result["range_start"] = _format_datetime(self.range_start)
        result["range_end"] = _format_datetime(self.range_end)
        if self.actions is not None:
            result["actions"] = self.actions
        if self.actors is not None:
            result["actors"] = self.actors
        if self.actor_names is not None:
            result["actor_names"] = self.actor_names
        if self.actor_ids is not None:
            result["actor_ids"] = self.actor_ids
        if self.targets is not None:
            result["targets"] = self.targets
        return result
