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

from __future__ import annotations
from censys_platform.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict


class ExtendedKeyUsageTypedDict(TypedDict):
    any: NotRequired[bool]
    apple_code_signing: NotRequired[bool]
    apple_code_signing_development: NotRequired[bool]
    apple_code_signing_third_party: NotRequired[bool]
    apple_crypto_development_env: NotRequired[bool]
    apple_crypto_env: NotRequired[bool]
    apple_crypto_maintenance_env: NotRequired[bool]
    apple_crypto_production_env: NotRequired[bool]
    apple_crypto_qos: NotRequired[bool]
    apple_crypto_test_env: NotRequired[bool]
    apple_crypto_tier0_qos: NotRequired[bool]
    apple_crypto_tier1_qos: NotRequired[bool]
    apple_crypto_tier2_qos: NotRequired[bool]
    apple_crypto_tier3_qos: NotRequired[bool]
    apple_ichat_encryption: NotRequired[bool]
    apple_ichat_signing: NotRequired[bool]
    apple_resource_signing: NotRequired[bool]
    apple_software_update_signing: NotRequired[bool]
    apple_system_identity: NotRequired[bool]
    client_auth: NotRequired[bool]
    code_signing: NotRequired[bool]
    dvcs: NotRequired[bool]
    eap_over_lan: NotRequired[bool]
    eap_over_ppp: NotRequired[bool]
    email_protection: NotRequired[bool]
    ipsec_end_system: NotRequired[bool]
    ipsec_intermediate_system_usage: NotRequired[bool]
    ipsec_tunnel: NotRequired[bool]
    ipsec_user: NotRequired[bool]
    microsoft_ca_exchange: NotRequired[bool]
    microsoft_cert_trust_list_signing: NotRequired[bool]
    microsoft_csp_signature: NotRequired[bool]
    microsoft_document_signing: NotRequired[bool]
    microsoft_drm: NotRequired[bool]
    microsoft_drm_individualization: NotRequired[bool]
    microsoft_efs_recovery: NotRequired[bool]
    microsoft_embedded_nt_crypto: NotRequired[bool]
    microsoft_encrypted_file_system: NotRequired[bool]
    microsoft_enrollment_agent: NotRequired[bool]
    microsoft_kernel_mode_code_signing: NotRequired[bool]
    microsoft_key_recovery_21: NotRequired[bool]
    microsoft_key_recovery_3: NotRequired[bool]
    microsoft_license_server: NotRequired[bool]
    microsoft_licenses: NotRequired[bool]
    microsoft_lifetime_signing: NotRequired[bool]
    microsoft_mobile_device_software: NotRequired[bool]
    microsoft_nt5_crypto: NotRequired[bool]
    microsoft_oem_whql_crypto: NotRequired[bool]
    microsoft_qualified_subordinate: NotRequired[bool]
    microsoft_root_list_signer: NotRequired[bool]
    microsoft_server_gated_crypto: NotRequired[bool]
    microsoft_sgc_serialized: NotRequired[bool]
    microsoft_smart_display: NotRequired[bool]
    microsoft_smartcard_logon: NotRequired[bool]
    microsoft_system_health: NotRequired[bool]
    microsoft_system_health_loophole: NotRequired[bool]
    microsoft_timestamp_signing: NotRequired[bool]
    microsoft_whql_crypto: NotRequired[bool]
    netscape_server_gated_crypto: NotRequired[bool]
    ocsp_signing: NotRequired[bool]
    sbgp_cert_aa_service_auth: NotRequired[bool]
    server_auth: NotRequired[bool]
    time_stamping: NotRequired[bool]
    unknown: NotRequired[Nullable[List[str]]]


class ExtendedKeyUsage(BaseModel):
    any: Optional[bool] = None

    apple_code_signing: Optional[bool] = None

    apple_code_signing_development: Optional[bool] = None

    apple_code_signing_third_party: Optional[bool] = None

    apple_crypto_development_env: Optional[bool] = None

    apple_crypto_env: Optional[bool] = None

    apple_crypto_maintenance_env: Optional[bool] = None

    apple_crypto_production_env: Optional[bool] = None

    apple_crypto_qos: Optional[bool] = None

    apple_crypto_test_env: Optional[bool] = None

    apple_crypto_tier0_qos: Optional[bool] = None

    apple_crypto_tier1_qos: Optional[bool] = None

    apple_crypto_tier2_qos: Optional[bool] = None

    apple_crypto_tier3_qos: Optional[bool] = None

    apple_ichat_encryption: Optional[bool] = None

    apple_ichat_signing: Optional[bool] = None

    apple_resource_signing: Optional[bool] = None

    apple_software_update_signing: Optional[bool] = None

    apple_system_identity: Optional[bool] = None

    client_auth: Optional[bool] = None

    code_signing: Optional[bool] = None

    dvcs: Optional[bool] = None

    eap_over_lan: Optional[bool] = None

    eap_over_ppp: Optional[bool] = None

    email_protection: Optional[bool] = None

    ipsec_end_system: Optional[bool] = None

    ipsec_intermediate_system_usage: Optional[bool] = None

    ipsec_tunnel: Optional[bool] = None

    ipsec_user: Optional[bool] = None

    microsoft_ca_exchange: Optional[bool] = None

    microsoft_cert_trust_list_signing: Optional[bool] = None

    microsoft_csp_signature: Optional[bool] = None

    microsoft_document_signing: Optional[bool] = None

    microsoft_drm: Optional[bool] = None

    microsoft_drm_individualization: Optional[bool] = None

    microsoft_efs_recovery: Optional[bool] = None

    microsoft_embedded_nt_crypto: Optional[bool] = None

    microsoft_encrypted_file_system: Optional[bool] = None

    microsoft_enrollment_agent: Optional[bool] = None

    microsoft_kernel_mode_code_signing: Optional[bool] = None

    microsoft_key_recovery_21: Optional[bool] = None

    microsoft_key_recovery_3: Optional[bool] = None

    microsoft_license_server: Optional[bool] = None

    microsoft_licenses: Optional[bool] = None

    microsoft_lifetime_signing: Optional[bool] = None

    microsoft_mobile_device_software: Optional[bool] = None

    microsoft_nt5_crypto: Optional[bool] = None

    microsoft_oem_whql_crypto: Optional[bool] = None

    microsoft_qualified_subordinate: Optional[bool] = None

    microsoft_root_list_signer: Optional[bool] = None

    microsoft_server_gated_crypto: Optional[bool] = None

    microsoft_sgc_serialized: Optional[bool] = None

    microsoft_smart_display: Optional[bool] = None

    microsoft_smartcard_logon: Optional[bool] = None

    microsoft_system_health: Optional[bool] = None

    microsoft_system_health_loophole: Optional[bool] = None

    microsoft_timestamp_signing: Optional[bool] = None

    microsoft_whql_crypto: Optional[bool] = None

    netscape_server_gated_crypto: Optional[bool] = None

    ocsp_signing: Optional[bool] = None

    sbgp_cert_aa_service_auth: Optional[bool] = None

    server_auth: Optional[bool] = None

    time_stamping: Optional[bool] = None

    unknown: OptionalNullable[List[str]] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "any",
            "apple_code_signing",
            "apple_code_signing_development",
            "apple_code_signing_third_party",
            "apple_crypto_development_env",
            "apple_crypto_env",
            "apple_crypto_maintenance_env",
            "apple_crypto_production_env",
            "apple_crypto_qos",
            "apple_crypto_test_env",
            "apple_crypto_tier0_qos",
            "apple_crypto_tier1_qos",
            "apple_crypto_tier2_qos",
            "apple_crypto_tier3_qos",
            "apple_ichat_encryption",
            "apple_ichat_signing",
            "apple_resource_signing",
            "apple_software_update_signing",
            "apple_system_identity",
            "client_auth",
            "code_signing",
            "dvcs",
            "eap_over_lan",
            "eap_over_ppp",
            "email_protection",
            "ipsec_end_system",
            "ipsec_intermediate_system_usage",
            "ipsec_tunnel",
            "ipsec_user",
            "microsoft_ca_exchange",
            "microsoft_cert_trust_list_signing",
            "microsoft_csp_signature",
            "microsoft_document_signing",
            "microsoft_drm",
            "microsoft_drm_individualization",
            "microsoft_efs_recovery",
            "microsoft_embedded_nt_crypto",
            "microsoft_encrypted_file_system",
            "microsoft_enrollment_agent",
            "microsoft_kernel_mode_code_signing",
            "microsoft_key_recovery_21",
            "microsoft_key_recovery_3",
            "microsoft_license_server",
            "microsoft_licenses",
            "microsoft_lifetime_signing",
            "microsoft_mobile_device_software",
            "microsoft_nt5_crypto",
            "microsoft_oem_whql_crypto",
            "microsoft_qualified_subordinate",
            "microsoft_root_list_signer",
            "microsoft_server_gated_crypto",
            "microsoft_sgc_serialized",
            "microsoft_smart_display",
            "microsoft_smartcard_logon",
            "microsoft_system_health",
            "microsoft_system_health_loophole",
            "microsoft_timestamp_signing",
            "microsoft_whql_crypto",
            "netscape_server_gated_crypto",
            "ocsp_signing",
            "sbgp_cert_aa_service_auth",
            "server_auth",
            "time_stamping",
            "unknown",
        ]
        nullable_fields = ["unknown"]
        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
