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

from __future__ import annotations

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

from .object_metadata import ObjectMetadata


@dataclass(slots=True)
class ObjectWithoutValue:
    """An encrypted object's metadata (value excluded)."""

    id: str
    """Unique identifier of the object."""
    metadata: "ObjectMetadata"
    name: str
    """Unique name of the object."""

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

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["id"] = self.id
        result["metadata"] = self.metadata.to_dict()
        result["name"] = self.name
        return result
