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

from __future__ import annotations
from .secretprovider import SecretProvider
from .secrettype import SecretType
from .status import Status
from .usertype import UserType
from flexprice_py.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict


class DtoSecretResponseTypedDict(TypedDict):
    created_at: NotRequired[str]
    display_id: NotRequired[str]
    expires_at: NotRequired[str]
    id: NotRequired[str]
    last_used_at: NotRequired[str]
    name: NotRequired[str]
    provider: NotRequired[SecretProvider]
    roles: NotRequired[List[str]]
    r"""RBAC roles"""
    status: NotRequired[Status]
    type: NotRequired[SecretType]
    updated_at: NotRequired[str]
    user_type: NotRequired[UserType]


class DtoSecretResponse(BaseModel):
    created_at: Optional[str] = None

    display_id: Optional[str] = None

    expires_at: Optional[str] = None

    id: Optional[str] = None

    last_used_at: Optional[str] = None

    name: Optional[str] = None

    provider: Optional[SecretProvider] = None

    roles: Optional[List[str]] = None
    r"""RBAC roles"""

    status: Optional[Status] = None

    type: Optional[SecretType] = None

    updated_at: Optional[str] = None

    user_type: Optional[UserType] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "created_at",
                "display_id",
                "expires_at",
                "id",
                "last_used_at",
                "name",
                "provider",
                "roles",
                "status",
                "type",
                "updated_at",
                "user_type",
            ]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m
