<filename>tools/class_header.template.py
#
# !!! DO NOT EDIT THIS FILE, IT IS GENERATED !!!
#
# The general rule of thumb for this file is that others can import it,
# but it cannot import from others and has to be self-contained unless there
# is a good reason. For more information, see tools/generate_class.py.
#
# pylint: skip-file
import re
from typing import List, Dict, Optional

import pydantic
from pydantic import constr


# Some ASFF classes have inconsistent naming, e.g. 'SseType' or 'SSEAlgorithm'.
# This dict collects such exception.
_ALIAS_NORMALIZER = {
    "sse_algorithm": "SSEAlgorithm",
    "kms_master_key_id": "KMSMasterKeyID",
}

# Taken from Security Hub error response.
ISO8601_REGEX = r"(\d\d\d\d)-[0-1](\d)-[0-3](\d)[Tt](?:[0-2](\d):[0-5](\d):[0-5](\d)|23:59:60)(?:\.(\d)+)?(?:[Zz]|[+-](\d\d)(?::?(\d\d))?)$"  # noqa: B950


class ASFFBaseModel(pydantic.BaseModel):
    """
    Base model with common settings, which other classes inherit from.
    """

    class Config:
        validate_assignment = True
        allow_population_by_field_name = True
        alias_generator = lambda x: _ALIAS_NORMALIZER.get(
            x, re.sub(r"(?:^|_)(.)", lambda m: m.group(1).upper(), x)
        )


# Custom types
Iso8601Timestamp = constr(regex=ISO8601_REGEX)

# Generated part below
