"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from enum import Enum
from pydantic import model_serializer
from que_media.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from typing_extensions import NotRequired, TypedDict


class Assurance(str, Enum):
    r"""The level of assurance provided by the signing process."""

    SERVER_MEASURED = "server_measured"
    CLIENT_HASH = "client_hash"


class Alg(str, Enum):
    r"""The cryptographic algorithm used for signing."""

    ES256 = "ES256"
    PS256 = "PS256"
    ED25519 = "Ed25519"


class EvidenceTypedDict(TypedDict):
    r"""Cryptographic evidence about the signature that was applied."""

    signer: str
    r"""Identifier for the signing entity/key used."""
    alg: Alg
    r"""The cryptographic algorithm used for signing."""


class Evidence(BaseModel):
    r"""Cryptographic evidence about the signature that was applied."""

    signer: str
    r"""Identifier for the signing entity/key used."""

    alg: Alg
    r"""The cryptographic algorithm used for signing."""


class SignResponseTypedDict(TypedDict):
    r"""The result of a successful signing operation. The signed asset is stored in S3 and the manifest is cryptographically embedded."""

    assurance: Assurance
    r"""The level of assurance provided by the signing process."""
    evidence: EvidenceTypedDict
    r"""Cryptographic evidence about the signature that was applied."""
    asset_s3_uri: NotRequired[Nullable[str]]
    r"""S3 URI of the signed asset. The signed asset is automatically uploaded to S3 with the embedded C2PA manifest."""


class SignResponse(BaseModel):
    r"""The result of a successful signing operation. The signed asset is stored in S3 and the manifest is cryptographically embedded."""

    assurance: Assurance
    r"""The level of assurance provided by the signing process."""

    evidence: Evidence
    r"""Cryptographic evidence about the signature that was applied."""

    asset_s3_uri: OptionalNullable[str] = UNSET
    r"""S3 URI of the signed asset. The signed asset is automatically uploaded to S3 with the embedded C2PA manifest."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["asset_s3_uri"]
        nullable_fields = ["asset_s3_uri"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
