# WARNING: This file is autogenerated by FHIR Schema Codegen.
# https://github.com/fhir-schema/fhir-schema-codegen
# Any manual changes made to this file may be overwritten.

from __future__ import annotations
from pydantic import ConfigDict, Field

from fhirschemapy.R4B.base import Reference
from fhirschemapy.R4B.resource import Resource


class Binary(Resource):
    model_config = ConfigDict(serialize_by_alias=True, extra="forbid")

    resource_type: str = Field(
        default="Binary",
        alias="resourceType",
        serialization_alias="resourceType",
        frozen=True,
        pattern="Binary",
    )

    content_type: str = Field(alias="contentType", serialization_alias="contentType")
    data: str | None = Field(None, alias="data", serialization_alias="data")
    security_context: Reference | None = Field(
        None, alias="securityContext", serialization_alias="securityContext"
    )

    def to_json(self, indent: int | None = None) -> str:
        return self.model_dump_json(
            exclude_unset=True, exclude_none=True, indent=indent
        )

    @classmethod
    def from_json(cls, json: str) -> Binary:
        return cls.model_validate_json(json)
