# coding: utf-8

"""
    Slack Web API

    One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes.

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

class ObjsChannel(BaseModel):
    """
    ObjsChannel
    """ # noqa: E501
    accepted_user: Optional[Annotated[str, Field(strict=True)]] = None
    created: StrictInt
    creator: Annotated[str, Field(strict=True)]
    id: Annotated[str, Field(strict=True)]
    is_archived: Optional[StrictBool] = None
    is_channel: StrictBool
    is_frozen: Optional[StrictBool] = None
    is_general: Optional[StrictBool] = None
    is_member: Optional[StrictBool] = None
    is_moved: Optional[StrictInt] = None
    is_mpim: StrictBool
    is_non_threadable: Optional[StrictBool] = None
    is_org_shared: StrictBool
    is_pending_ext_shared: Optional[StrictBool] = None
    is_private: StrictBool
    is_read_only: Optional[StrictBool] = None
    is_shared: StrictBool
    is_thread_only: Optional[StrictBool] = None
    last_read: Optional[Annotated[str, Field(strict=True)]] = None
    latest: Optional[Dict[str, Any]] = None
    members: Annotated[List[Annotated[str, Field(strict=True)]], Field(min_length=0)]
    name: StrictStr
    name_normalized: StrictStr
    num_members: Optional[StrictInt] = None
    pending_shared: Optional[Annotated[List[Annotated[str, Field(strict=True)]], Field(min_length=0)]] = None
    previous_names: Optional[Annotated[List[StrictStr], Field(min_length=0)]] = None
    priority: Optional[Union[StrictFloat, StrictInt]] = None
    purpose: Dict[str, Any]
    topic: Dict[str, Any]
    unlinked: Optional[StrictInt] = None
    unread_count: Optional[StrictInt] = None
    unread_count_display: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["accepted_user", "created", "creator", "id", "is_archived", "is_channel", "is_frozen", "is_general", "is_member", "is_moved", "is_mpim", "is_non_threadable", "is_org_shared", "is_pending_ext_shared", "is_private", "is_read_only", "is_shared", "is_thread_only", "last_read", "latest", "members", "name", "name_normalized", "num_members", "pending_shared", "previous_names", "priority", "purpose", "topic", "unlinked", "unread_count", "unread_count_display"]

    @field_validator('accepted_user')
    def accepted_user_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"^[UW][A-Z0-9]{2,}$", value):
            raise ValueError(r"must validate the regular expression /^[UW][A-Z0-9]{2,}$/")
        return value

    @field_validator('creator')
    def creator_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if not re.match(r"^[UW][A-Z0-9]{2,}$", value):
            raise ValueError(r"must validate the regular expression /^[UW][A-Z0-9]{2,}$/")
        return value

    @field_validator('id')
    def id_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if not re.match(r"^[C][A-Z0-9]{2,}$", value):
            raise ValueError(r"must validate the regular expression /^[C][A-Z0-9]{2,}$/")
        return value

    @field_validator('last_read')
    def last_read_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"^\d{10}\.\d{6}$", value):
            raise ValueError(r"must validate the regular expression /^\d{10}\.\d{6}$/")
        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 ObjsChannel 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "accepted_user": obj.get("accepted_user"),
            "created": obj.get("created"),
            "creator": obj.get("creator"),
            "id": obj.get("id"),
            "is_archived": obj.get("is_archived"),
            "is_channel": obj.get("is_channel"),
            "is_frozen": obj.get("is_frozen"),
            "is_general": obj.get("is_general"),
            "is_member": obj.get("is_member"),
            "is_moved": obj.get("is_moved"),
            "is_mpim": obj.get("is_mpim"),
            "is_non_threadable": obj.get("is_non_threadable"),
            "is_org_shared": obj.get("is_org_shared"),
            "is_pending_ext_shared": obj.get("is_pending_ext_shared"),
            "is_private": obj.get("is_private"),
            "is_read_only": obj.get("is_read_only"),
            "is_shared": obj.get("is_shared"),
            "is_thread_only": obj.get("is_thread_only"),
            "last_read": obj.get("last_read"),
            "latest": obj.get("latest"),
            "members": obj.get("members"),
            "name": obj.get("name"),
            "name_normalized": obj.get("name_normalized"),
            "num_members": obj.get("num_members"),
            "pending_shared": obj.get("pending_shared"),
            "previous_names": obj.get("previous_names"),
            "priority": obj.get("priority"),
            "purpose": obj.get("purpose"),
            "topic": obj.get("topic"),
            "unlinked": obj.get("unlinked"),
            "unread_count": obj.get("unread_count"),
            "unread_count_display": obj.get("unread_count_display")
        })
        return _obj


