# 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, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class ObjsSubteam(BaseModel):
    """
    ObjsSubteam
    """ # noqa: E501
    auto_provision: StrictBool
    auto_type: Dict[str, Any]
    channel_count: Optional[StrictInt] = None
    created_by: Annotated[str, Field(strict=True)]
    date_create: StrictInt
    date_delete: StrictInt
    date_update: StrictInt
    deleted_by: Dict[str, Any]
    description: StrictStr
    enterprise_subteam_id: StrictStr
    handle: StrictStr
    id: Annotated[str, Field(strict=True)]
    is_external: StrictBool
    is_subteam: StrictBool
    is_usergroup: StrictBool
    name: StrictStr
    prefs: Dict[str, Any]
    team_id: Annotated[str, Field(strict=True)]
    updated_by: Annotated[str, Field(strict=True)]
    user_count: Optional[StrictInt] = None
    users: Optional[List[Annotated[str, Field(strict=True)]]] = None
    __properties: ClassVar[List[str]] = ["auto_provision", "auto_type", "channel_count", "created_by", "date_create", "date_delete", "date_update", "deleted_by", "description", "enterprise_subteam_id", "handle", "id", "is_external", "is_subteam", "is_usergroup", "name", "prefs", "team_id", "updated_by", "user_count", "users"]

    @field_validator('created_by')
    def created_by_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"^S[A-Z0-9]{2,}$", value):
            raise ValueError(r"must validate the regular expression /^S[A-Z0-9]{2,}$/")
        return value

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

    @field_validator('updated_by')
    def updated_by_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

    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 ObjsSubteam 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 ObjsSubteam from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "auto_provision": obj.get("auto_provision"),
            "auto_type": obj.get("auto_type"),
            "channel_count": obj.get("channel_count"),
            "created_by": obj.get("created_by"),
            "date_create": obj.get("date_create"),
            "date_delete": obj.get("date_delete"),
            "date_update": obj.get("date_update"),
            "deleted_by": obj.get("deleted_by"),
            "description": obj.get("description"),
            "enterprise_subteam_id": obj.get("enterprise_subteam_id"),
            "handle": obj.get("handle"),
            "id": obj.get("id"),
            "is_external": obj.get("is_external"),
            "is_subteam": obj.get("is_subteam"),
            "is_usergroup": obj.get("is_usergroup"),
            "name": obj.get("name"),
            "prefs": obj.get("prefs"),
            "team_id": obj.get("team_id"),
            "updated_by": obj.get("updated_by"),
            "user_count": obj.get("user_count"),
            "users": obj.get("users")
        })
        return _obj


