# 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 AuditLogsRetention:
    """Audit Logs Retention model."""

    retention_period_in_days: Optional[int]
    """The number of days Audit Log events will be retained before being permanently deleted. Valid values are 30 and 365."""

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

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