# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Union, Optional
from datetime import datetime
from typing_extensions import TypeAlias

from pydantic import Field as FieldInfo

from .._models import BaseModel
from .any_type import AnyType
from .input_type import InputType

__all__ = [
    "TransformationListResponse",
    "Transformation",
    "TransformationTransformedContent",
    "TransformationTransformedContentOutput",
]


class TransformationTransformedContentOutput(BaseModel):
    output: Optional[List[Optional[AnyType]]] = None


TransformationTransformedContent: TypeAlias = Union[
    TransformationTransformedContentOutput, List[object], str, float, bool, object
]


class Transformation(BaseModel):
    created_at: datetime = FieldInfo(alias="createdAt")
    """Timestamp indicating when the transformation was created."""

    input_type: InputType = FieldInfo(alias="inputType")
    """The input type of the content you're sending for transformation."""

    item_offset: int = FieldInfo(alias="itemOffset")
    """
    For CSV transformations, this offset represents starting row of the CSV for
    which you want to fetch transformations for. For PDF transformations, this
    offset represents the starting page of the PDF that the transformation pertains
    to. For pipelines that have `independentDocumentProcessingEnabled` set to
    `true`. Note that this is zero-indexed.
    """

    pipeline_id: str = FieldInfo(alias="pipelineID")
    """ID of pipeline that transformed the original input data."""

    reference_id: str = FieldInfo(alias="referenceID")
    """The unique ID you use internally to refer to this data point."""

    transformation_id: str = FieldInfo(alias="transformationID")
    """Unique ID generated by bem following Segment's KSUID conventions."""

    transformed_content: TransformationTransformedContent = FieldInfo(alias="transformedContent")
    """The transformed content as an object, in the schema defined by the pipeline."""

    invalid_properties: Optional[List[str]] = FieldInfo(alias="invalidProperties", default=None)
    """
    Highlights any fields missing from transforming the original input data that are
    marked as `required` in the respective output schema for the pipeline.
    """

    last_publish_error_at: Optional[str] = FieldInfo(alias="lastPublishErrorAt", default=None)
    """
    Last timestamp indicating when the transform was published via webhook and
    received a non-200 response. Set to `null` if on a subsequent retry if the
    webhook service receives a 200 response.
    """

    published_at: Optional[datetime] = FieldInfo(alias="publishedAt", default=None)
    """
    Timestamp indicating when the transform was published via webhook and received a
    successful 200 response. Value is `null` if the transformation hasn't been sent.
    """


class TransformationListResponse(BaseModel):
    total_count: Optional[int] = FieldInfo(alias="totalCount", default=None)
    """The total number of results available."""

    transformations: Optional[List[Transformation]] = None
    """An array of objects containing the transformations."""
