# coding: utf-8

"""
    Ringer Business API - Phone Number Management

    This API provides endpoints for managing phone numbers within a Ringer Business account and its sites. Phone numbers are essential for making and receiving calls and can be routed to various features like devices, menus, or voicemail.  Functionality includes: - Listing phone numbers associated with a specific site. - Assigning (creating) a new phone number to a site. - Retrieving details of a specific phone number. - Updating a phone number's configuration (e.g., its routing destination). - Deleting/unassigning a phone number from a site. - Transferring a phone number between sites. - Listing available phone numbers for assignment to a site (from inventory or search). - Searching for available phone numbers based on criteria like area code, city, etc. 

    The version of the OpenAPI document: 1.0.0
    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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class Link1(BaseModel):
    """
    Represents a HATEOAS link.
    """ # noqa: E501
    href: StrictStr = Field(description="The target URI of the link.")
    rel: StrictStr = Field(description="The relation type of the link (e.g., self, next, prev, item).")
    method: Optional[StrictStr] = Field(default='GET', description="The HTTP method to use for the link's action.")
    title: Optional[StrictStr] = Field(default=None, description="A human-readable title for the link.")
    __properties: ClassVar[List[str]] = ["href", "rel", "method", "title"]

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

        if value not in set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD']):
            raise ValueError("must be one of enum values ('GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD')")
        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 Link1 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 title (nullable) is None
        # and model_fields_set contains the field
        if self.title is None and "title" in self.model_fields_set:
            _dict['title'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "href": obj.get("href"),
            "rel": obj.get("rel"),
            "method": obj.get("method") if obj.get("method") is not None else 'GET',
            "title": obj.get("title")
        })
        return _obj


