# coding: utf-8

"""
    One-API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 2.0
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from bsg_api.models.short_domain_slug_type import ShortDomainSlugType
from typing import Optional, Set
from typing_extensions import Self

class ShortUrlDomainSchema(BaseModel):
    """
    ShortUrlDomainSchema
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Unique Id of short domain (uuid)")
    system_domain_id: Optional[StrictStr] = None
    status: Optional[StrictStr] = None
    name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=20)]] = Field(default=None, description="short domain")
    is_default: Optional[StrictBool] = True
    slug_type: Optional[ShortDomainSlugType] = None
    init_deleted_at: Optional[datetime] = None
    created_at: Optional[datetime] = None
    not_found_page: Optional[StrictStr] = Field(default=None, description="Url to redirect if original link return status 404 not found")
    can_refresh_status: Optional[StrictBool] = True
    can_restore: Optional[StrictBool] = True
    record_type: Optional[StrictStr] = Field(default=None, description="if system_domain_id is null it is necessary to setup your dns")
    hostname: Optional[StrictStr] = Field(default=None, description="if system_domain_id is null it is necessary to setup your dns")
    cname: Optional[StrictStr] = Field(default=None, description="if system_domain_id is null it is necessary to setup your dns")
    count_short_links: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["id", "system_domain_id", "status", "name", "is_default", "slug_type", "init_deleted_at", "created_at", "not_found_page", "can_refresh_status", "can_restore", "record_type", "hostname", "cname", "count_short_links"]

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['active', 'inactive', 'deleted', 'blocked', 'not_paid']):
            raise ValueError("must be one of enum values ('active', 'inactive', 'deleted', 'blocked', 'not_paid')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

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

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if system_domain_id (nullable) is None
        # and model_fields_set contains the field
        if self.system_domain_id is None and "system_domain_id" in self.model_fields_set:
            _dict['system_domain_id'] = None

        # set to None if init_deleted_at (nullable) is None
        # and model_fields_set contains the field
        if self.init_deleted_at is None and "init_deleted_at" in self.model_fields_set:
            _dict['init_deleted_at'] = None

        # set to None if record_type (nullable) is None
        # and model_fields_set contains the field
        if self.record_type is None and "record_type" in self.model_fields_set:
            _dict['record_type'] = None

        # set to None if hostname (nullable) is None
        # and model_fields_set contains the field
        if self.hostname is None and "hostname" in self.model_fields_set:
            _dict['hostname'] = None

        # set to None if cname (nullable) is None
        # and model_fields_set contains the field
        if self.cname is None and "cname" in self.model_fields_set:
            _dict['cname'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ShortUrlDomainSchema from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "system_domain_id": obj.get("system_domain_id"),
            "status": obj.get("status"),
            "name": obj.get("name"),
            "is_default": obj.get("is_default") if obj.get("is_default") is not None else True,
            "slug_type": obj.get("slug_type"),
            "init_deleted_at": obj.get("init_deleted_at"),
            "created_at": obj.get("created_at"),
            "not_found_page": obj.get("not_found_page"),
            "can_refresh_status": obj.get("can_refresh_status") if obj.get("can_refresh_status") is not None else True,
            "can_restore": obj.get("can_restore") if obj.get("can_restore") is not None else True,
            "record_type": obj.get("record_type"),
            "hostname": obj.get("hostname"),
            "cname": obj.get("cname"),
            "count_short_links": obj.get("count_short_links")
        })
        return _obj


