# coding: utf-8

"""
    Ringer Business API

    This API provides comprehensive endpoints for the Ringer Business system. It includes functionality for managing customer accounts, addresses, sites,  phone numbers, payments, users, and other business resources.  Operations typically require authentication and appropriate permissions. 

    The version of the OpenAPI document: 1.0.4
    Contact: support@ringer.tel
    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
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from ringer_business.models.schemas_link import SchemasLink
from typing import Optional, Set
from typing_extensions import Self

class SiteResponse(BaseModel):
    """
    Detailed information about a specific site.
    """ # noqa: E501
    name: StrictStr = Field(description="A user-friendly name for the site (e.g., \"Main Office\", \"Sales Department\").")
    dns_extension: StrictStr = Field(description="The DNS extension for the site, used to form part of its unique SIP domain.")
    active: StrictBool = Field(description="Indicates if the site is active. Inactive sites cannot place or receive calls.")
    caller_id_name: StrictStr = Field(description="Default Caller ID name for outbound calls originating from this site.")
    caller_id_number: StrictStr = Field(description="Default Caller ID number for outbound calls from this site (e.g., main business number).")
    thin_client_id: StrictInt = Field(description="Identifier of the thin client (call processing node) assigned to this site.")
    acl: StrictStr = Field(description="Access Control List (e.g., IP addresses or ranges) defining who can connect to this site's SIP services.")
    channel_limit: Annotated[int, Field(le=1000, strict=True, ge=0)] = Field(description="Maximum number of concurrent call channels allowed for this site.")
    permitted_country_codes: List[StrictStr] = Field(description="List of permitted outbound country codes or dialing zones for this site. Reference Country Codes API for available values.")
    music_on_hold_url: Optional[StrictStr] = Field(default=None, description="URL to the music on hold audio file for the site.")
    id: StrictInt = Field(description="Unique identifier for the site.")
    dns_name: StrictStr = Field(description="The fully qualified DNS name for the site (e.g., hq.ivy.teliax.com).")
    thin_client_name: Optional[StrictStr] = Field(default=None, description="Name of the assigned thin client.")
    links: Optional[List[SchemasLink]] = Field(default=None, description="HATEOAS links related to this site.")
    __properties: ClassVar[List[str]] = ["name", "dns_extension", "active", "caller_id_name", "caller_id_number", "thin_client_id", "acl", "channel_limit", "permitted_country_codes", "music_on_hold_url", "id", "dns_name", "thin_client_name", "links"]

    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 SiteResponse 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 each item in links (list)
        _items = []
        if self.links:
            for _item_links in self.links:
                if _item_links:
                    _items.append(_item_links.to_dict())
            _dict['links'] = _items
        # set to None if music_on_hold_url (nullable) is None
        # and model_fields_set contains the field
        if self.music_on_hold_url is None and "music_on_hold_url" in self.model_fields_set:
            _dict['music_on_hold_url'] = None

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "dns_extension": obj.get("dns_extension"),
            "active": obj.get("active"),
            "caller_id_name": obj.get("caller_id_name"),
            "caller_id_number": obj.get("caller_id_number"),
            "thin_client_id": obj.get("thin_client_id"),
            "acl": obj.get("acl"),
            "channel_limit": obj.get("channel_limit"),
            "permitted_country_codes": obj.get("permitted_country_codes"),
            "music_on_hold_url": obj.get("music_on_hold_url"),
            "id": obj.get("id"),
            "dns_name": obj.get("dns_name"),
            "thin_client_name": obj.get("thin_client_name"),
            "links": [SchemasLink.from_dict(_item) for _item in obj["links"]] if obj.get("links") is not None else None
        })
        return _obj


