# 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 slack_beta_ti.models.objs_external_org_migrations import ObjsExternalOrgMigrations
from slack_beta_ti.models.objs_icon import ObjsIcon
from slack_beta_ti.models.objs_primary_owner import ObjsPrimaryOwner
from slack_beta_ti.models.objs_team_sso_provider import ObjsTeamSsoProvider
from typing import Optional, Set
from typing_extensions import Self

class ObjsTeam(BaseModel):
    """
    ObjsTeam
    """ # noqa: E501
    archived: Optional[StrictBool] = None
    avatar_base_url: Optional[StrictStr] = None
    created: Optional[StrictInt] = None
    date_create: Optional[StrictInt] = None
    deleted: Optional[StrictBool] = None
    discoverable: Optional[Dict[str, Any]] = None
    domain: StrictStr
    email_domain: StrictStr
    enterprise_id: Optional[Annotated[str, Field(strict=True)]] = None
    enterprise_name: Optional[StrictStr] = None
    external_org_migrations: Optional[ObjsExternalOrgMigrations] = None
    has_compliance_export: Optional[StrictBool] = None
    icon: ObjsIcon
    id: Annotated[str, Field(strict=True)]
    is_assigned: Optional[StrictBool] = None
    is_enterprise: Optional[StrictInt] = None
    is_over_storage_limit: Optional[StrictBool] = None
    limit_ts: Optional[StrictInt] = None
    locale: Optional[StrictStr] = None
    messages_count: Optional[StrictInt] = None
    msg_edit_window_mins: Optional[StrictInt] = None
    name: StrictStr
    over_integrations_limit: Optional[StrictBool] = None
    over_storage_limit: Optional[StrictBool] = None
    pay_prod_cur: Optional[StrictStr] = None
    plan: Optional[StrictStr] = None
    primary_owner: Optional[ObjsPrimaryOwner] = None
    sso_provider: Optional[ObjsTeamSsoProvider] = None
    __properties: ClassVar[List[str]] = ["archived", "avatar_base_url", "created", "date_create", "deleted", "discoverable", "domain", "email_domain", "enterprise_id", "enterprise_name", "external_org_migrations", "has_compliance_export", "icon", "id", "is_assigned", "is_enterprise", "is_over_storage_limit", "limit_ts", "locale", "messages_count", "msg_edit_window_mins", "name", "over_integrations_limit", "over_storage_limit", "pay_prod_cur", "plan", "primary_owner", "sso_provider"]

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

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

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

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

        if value not in set(['', 'std', 'plus', 'compliance', 'enterprise']):
            raise ValueError("must be one of enum values ('', 'std', 'plus', 'compliance', 'enterprise')")
        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 ObjsTeam 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,
        )
        # override the default output from pydantic by calling `to_dict()` of external_org_migrations
        if self.external_org_migrations:
            _dict['external_org_migrations'] = self.external_org_migrations.to_dict()
        # override the default output from pydantic by calling `to_dict()` of icon
        if self.icon:
            _dict['icon'] = self.icon.to_dict()
        # override the default output from pydantic by calling `to_dict()` of primary_owner
        if self.primary_owner:
            _dict['primary_owner'] = self.primary_owner.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sso_provider
        if self.sso_provider:
            _dict['sso_provider'] = self.sso_provider.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "archived": obj.get("archived"),
            "avatar_base_url": obj.get("avatar_base_url"),
            "created": obj.get("created"),
            "date_create": obj.get("date_create"),
            "deleted": obj.get("deleted"),
            "discoverable": obj.get("discoverable"),
            "domain": obj.get("domain"),
            "email_domain": obj.get("email_domain"),
            "enterprise_id": obj.get("enterprise_id"),
            "enterprise_name": obj.get("enterprise_name"),
            "external_org_migrations": ObjsExternalOrgMigrations.from_dict(obj["external_org_migrations"]) if obj.get("external_org_migrations") is not None else None,
            "has_compliance_export": obj.get("has_compliance_export"),
            "icon": ObjsIcon.from_dict(obj["icon"]) if obj.get("icon") is not None else None,
            "id": obj.get("id"),
            "is_assigned": obj.get("is_assigned"),
            "is_enterprise": obj.get("is_enterprise"),
            "is_over_storage_limit": obj.get("is_over_storage_limit"),
            "limit_ts": obj.get("limit_ts"),
            "locale": obj.get("locale"),
            "messages_count": obj.get("messages_count"),
            "msg_edit_window_mins": obj.get("msg_edit_window_mins"),
            "name": obj.get("name"),
            "over_integrations_limit": obj.get("over_integrations_limit"),
            "over_storage_limit": obj.get("over_storage_limit"),
            "pay_prod_cur": obj.get("pay_prod_cur"),
            "plan": obj.get("plan"),
            "primary_owner": ObjsPrimaryOwner.from_dict(obj["primary_owner"]) if obj.get("primary_owner") is not None else None,
            "sso_provider": ObjsTeamSsoProvider.from_dict(obj["sso_provider"]) if obj.get("sso_provider") is not None else None
        })
        return _obj


