# 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 typing import List as PyList, Literal

from fhirschemapy.R4B.base import (
    CodeableConcept,
    Coding,
    ContactPoint,
    Identifier,
    Period,
    Reference,
)
from fhirschemapy.R4B.domain_resource import DomainResource


class Endpoint(DomainResource):
    model_config = ConfigDict(serialize_by_alias=True, extra="forbid")

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

    address: str = Field(alias="address", serialization_alias="address")
    connection_type: Coding = Field(
        alias="connectionType", serialization_alias="connectionType"
    )
    contact: PyList[ContactPoint] | None = Field(
        None, alias="contact", serialization_alias="contact"
    )
    header: PyList[str] | None = Field(
        None, alias="header", serialization_alias="header"
    )
    identifier: PyList[Identifier] | None = Field(
        None, alias="identifier", serialization_alias="identifier"
    )
    managing_organization: Reference | None = Field(
        None, alias="managingOrganization", serialization_alias="managingOrganization"
    )
    name: str | None = Field(None, alias="name", serialization_alias="name")
    payload_mime_type: PyList[str] | None = Field(
        None, alias="payloadMimeType", serialization_alias="payloadMimeType"
    )
    payload_type: PyList[CodeableConcept] = Field(
        alias="payloadType", serialization_alias="payloadType"
    )
    period: Period | None = Field(None, alias="period", serialization_alias="period")
    status: Literal[
        "active", "suspended", "error", "off", "entered-in-error", "test"
    ] = Field(alias="status", serialization_alias="status")

    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) -> Endpoint:
        return cls.model_validate_json(json)
