# coding: utf-8

"""
    authentik

    Making authentication simple.

    The version of the OpenAPI document: 2024.2.2
    Contact: hello@goauthentik.io
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import List, Optional
from pydantic import BaseModel, Field, StrictStr, conlist, constr
from authentik_client.models.device_classes_enum import DeviceClassesEnum
from authentik_client.models.flow_set_request import FlowSetRequest
from authentik_client.models.not_configured_action_enum import NotConfiguredActionEnum
from authentik_client.models.user_verification_enum import UserVerificationEnum

class AuthenticatorValidateStageRequest(BaseModel):
    """
    AuthenticatorValidateStage Serializer  # noqa: E501
    """
    name: constr(strict=True, min_length=1) = Field(...)
    flow_set: Optional[conlist(FlowSetRequest)] = None
    not_configured_action: Optional[NotConfiguredActionEnum] = None
    device_classes: Optional[conlist(DeviceClassesEnum)] = Field(None, description="Device classes which can be used to authenticate")
    configuration_stages: Optional[conlist(StrictStr)] = Field(None, description="Stages used to configure Authenticator when user doesn't have any compatible devices. After this configuration Stage passes, the user is not prompted again.")
    last_auth_threshold: Optional[constr(strict=True, min_length=1)] = Field(None, description="If any of the user's device has been used within this threshold, this stage will be skipped")
    webauthn_user_verification: Optional[UserVerificationEnum] = Field(None, description="Enforce user verification for WebAuthn devices.")
    __properties = ["name", "flow_set", "not_configured_action", "device_classes", "configuration_stages", "last_auth_threshold", "webauthn_user_verification"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of each item in flow_set (list)
        _items = []
        if self.flow_set:
            for _item in self.flow_set:
                if _item:
                    _items.append(_item.to_dict())
            _dict['flow_set'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> AuthenticatorValidateStageRequest:
        """Create an instance of AuthenticatorValidateStageRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return AuthenticatorValidateStageRequest.parse_obj(obj)

        _obj = AuthenticatorValidateStageRequest.parse_obj({
            "name": obj.get("name"),
            "flow_set": [FlowSetRequest.from_dict(_item) for _item in obj.get("flow_set")] if obj.get("flow_set") is not None else None,
            "not_configured_action": obj.get("not_configured_action"),
            "device_classes": obj.get("device_classes"),
            "configuration_stages": obj.get("configuration_stages"),
            "last_auth_threshold": obj.get("last_auth_threshold"),
            "webauthn_user_verification": obj.get("webauthn_user_verification")
        })
        return _obj


