# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .webhook_subscription_event_type import WebhookSubscriptionEventType
from .webhook_subscription_resource_type import WebhookSubscriptionResourceType


class WebhookSubscription(UncheckedBaseModel):
    object: typing.Literal["webhook_subscription"] = "webhook_subscription"
    id: str = pydantic.Field()
    """
    Unique identifier for the webhook subscription.
    """

    webhook_endpoint_id: typing_extensions.Annotated[str, FieldMetadata(alias="webhookEndpointId")] = pydantic.Field(
        alias="webhookEndpointId"
    )
    """
    The ID of the webhook endpoint this subscription belongs to.
    """

    resource_type: typing_extensions.Annotated[WebhookSubscriptionResourceType, FieldMetadata(alias="resourceType")] = (
        pydantic.Field(alias="resourceType")
    )
    resource_id: typing_extensions.Annotated[str, FieldMetadata(alias="resourceId")] = pydantic.Field(
        alias="resourceId"
    )
    """
    The ID of the resource this subscription is scoped to (e.g., an extractor, classifier, splitter, or workflow).
    """

    enabled_events: typing_extensions.Annotated[
        typing.List[WebhookSubscriptionEventType], FieldMetadata(alias="enabledEvents")
    ] = pydantic.Field(alias="enabledEvents")
    """
    The list of event types this subscription is subscribed to. The valid event types depend on the `resourceType`.
    """

    created_at: typing_extensions.Annotated[dt.datetime, FieldMetadata(alias="createdAt")] = pydantic.Field(
        alias="createdAt"
    )
    """
    The date and time the webhook subscription was created.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
