# 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 Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, constr, validator
from authentik_client.models.denied_action_enum import DeniedActionEnum
from authentik_client.models.flow_designation_enum import FlowDesignationEnum
from authentik_client.models.flow_layout_enum import FlowLayoutEnum
from authentik_client.models.policy_engine_mode import PolicyEngineMode

class FlowSet(BaseModel):
    """
    Stripped down flow serializer  # noqa: E501
    """
    pk: StrictStr = Field(...)
    policybindingmodel_ptr_id: StrictStr = Field(...)
    name: StrictStr = Field(...)
    slug: constr(strict=True, max_length=50) = Field(..., description="Visible in the URL.")
    title: StrictStr = Field(..., description="Shown as the Title in Flow pages.")
    designation: FlowDesignationEnum = Field(..., description="Decides what this Flow is used for. For example, the Authentication flow is redirect to when an un-authenticated user visits authentik.")
    background: StrictStr = Field(..., description="Get the URL to the background image. If the name is /static or starts with http it is returned as-is")
    policy_engine_mode: Optional[PolicyEngineMode] = None
    compatibility_mode: Optional[StrictBool] = Field(None, description="Enable compatibility mode, increases compatibility with password managers on mobile devices.")
    export_url: StrictStr = Field(..., description="Get export URL for flow")
    layout: Optional[FlowLayoutEnum] = None
    denied_action: Optional[DeniedActionEnum] = Field(None, description="Configure what should happen when a flow denies access to a user.")
    __properties = ["pk", "policybindingmodel_ptr_id", "name", "slug", "title", "designation", "background", "policy_engine_mode", "compatibility_mode", "export_url", "layout", "denied_action"]

    @validator('slug')
    def slug_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if not re.match(r"^[-a-zA-Z0-9_]+$", value):
            raise ValueError(r"must validate the regular expression /^[-a-zA-Z0-9_]+$/")
        return value

    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) -> FlowSet:
        """Create an instance of FlowSet 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={
                            "pk",
                            "policybindingmodel_ptr_id",
                            "background",
                            "export_url",
                          },
                          exclude_none=True)
        return _dict

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

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

        _obj = FlowSet.parse_obj({
            "pk": obj.get("pk"),
            "policybindingmodel_ptr_id": obj.get("policybindingmodel_ptr_id"),
            "name": obj.get("name"),
            "slug": obj.get("slug"),
            "title": obj.get("title"),
            "designation": obj.get("designation"),
            "background": obj.get("background"),
            "policy_engine_mode": obj.get("policy_engine_mode"),
            "compatibility_mode": obj.get("compatibility_mode"),
            "export_url": obj.get("export_url"),
            "layout": obj.get("layout"),
            "denied_action": obj.get("denied_action")
        })
        return _obj


