from __future__ import annotations
import json
from enum import Enum
{{#vendorExtensions.x-py-other-imports}}
{{{.}}}
{{/vendorExtensions.x-py-other-imports}}
from typing_extensions import Self


class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum):
    """
    {{{description}}}{{^description}}{{{classname}}}{{/description}}
    """

    """
    allowed enum values
    """
{{#allowableValues}}
    {{#enumVars}}
    {{^-last}}
    {{{name}}} = {{{value}}}
    {{/-last}}
    {{#-last}}
    {{^enumUnknownDefaultCase}}
    {{{name}}} = {{{value}}}
    {{/enumUnknownDefaultCase}}
    {{#enumUnknownDefaultCase}}
    UNKNOWN_DEFAULT_OPEN_API = {{{value}}}
    {{/enumUnknownDefaultCase}}
    {{/-last}}
    {{/enumVars}}

    @classmethod
    def from_json(cls, json_str: str) -> Self:
        """Create an instance of {{classname}} from a JSON string"""
        return cls(json.loads(json_str))

    {{#defaultValue}}

    #
    @classmethod
    def _missing_value_(cls, value):
        if value is no_arg:
            return cls.{{{.}}}
    {{/defaultValue}}
{{/allowableValues}}
{{#enumUnknownDefaultCase}}

    @classmethod
    def _missing_(cls, value):
        return cls.UNKNOWN_DEFAULT_OPEN_API
{{/enumUnknownDefaultCase}}
