# coding: utf-8

"""
    Graphiant APIs

    Graphiant API documentation.

    The version of the OpenAPI document: 1.0.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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_dhcp_subnets_inner_leases_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerLeasesInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_dhcp_subnets_inner_nameservers import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerNameservers
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_dhcp_subnets_inner_ranges_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerRangesInner
from graphiant_sdk.models.v1_extranets_get200_response_policies_inner_branches_excluded_devices_inner_segments_inner_dhcp_subnets_inner_static_leases_inner import V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerStaticLeasesInner
from typing import Optional, Set
from typing_extensions import Self

class V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInner(BaseModel):
    """
    V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInner
    """ # noqa: E501
    default_lease_time_secs: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="defaultLeaseTimeSecs")
    description: Optional[StrictStr] = None
    domain_name: Optional[StrictStr] = Field(default=None, alias="domainName")
    gateway: Optional[StrictStr] = None
    id: Optional[StrictInt] = None
    interface: Optional[StrictStr] = None
    ip_prefix: Optional[StrictStr] = Field(default=None, alias="ipPrefix")
    ip_version: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="ipVersion")
    leases: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerLeasesInner]] = None
    max_lease_time_secs: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="maxLeaseTimeSecs")
    min_lease_time_secs: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="minLeaseTimeSecs")
    name: Optional[StrictStr] = None
    nameservers: Optional[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerNameservers] = None
    ranges: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerRangesInner]] = None
    static_leases: Optional[List[V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerStaticLeasesInner]] = Field(default=None, alias="staticLeases")
    total_addresses: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="totalAddresses")
    utilization: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
    __properties: ClassVar[List[str]] = ["defaultLeaseTimeSecs", "description", "domainName", "gateway", "id", "interface", "ipPrefix", "ipVersion", "leases", "maxLeaseTimeSecs", "minLeaseTimeSecs", "name", "nameservers", "ranges", "staticLeases", "totalAddresses", "utilization"]

    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 V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInner 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 leases (list)
        _items = []
        if self.leases:
            for _item_leases in self.leases:
                if _item_leases:
                    _items.append(_item_leases.to_dict())
            _dict['leases'] = _items
        # override the default output from pydantic by calling `to_dict()` of nameservers
        if self.nameservers:
            _dict['nameservers'] = self.nameservers.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in ranges (list)
        _items = []
        if self.ranges:
            for _item_ranges in self.ranges:
                if _item_ranges:
                    _items.append(_item_ranges.to_dict())
            _dict['ranges'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in static_leases (list)
        _items = []
        if self.static_leases:
            for _item_static_leases in self.static_leases:
                if _item_static_leases:
                    _items.append(_item_static_leases.to_dict())
            _dict['staticLeases'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "defaultLeaseTimeSecs": obj.get("defaultLeaseTimeSecs"),
            "description": obj.get("description"),
            "domainName": obj.get("domainName"),
            "gateway": obj.get("gateway"),
            "id": obj.get("id"),
            "interface": obj.get("interface"),
            "ipPrefix": obj.get("ipPrefix"),
            "ipVersion": obj.get("ipVersion"),
            "leases": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerLeasesInner.from_dict(_item) for _item in obj["leases"]] if obj.get("leases") is not None else None,
            "maxLeaseTimeSecs": obj.get("maxLeaseTimeSecs"),
            "minLeaseTimeSecs": obj.get("minLeaseTimeSecs"),
            "name": obj.get("name"),
            "nameservers": V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerNameservers.from_dict(obj["nameservers"]) if obj.get("nameservers") is not None else None,
            "ranges": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerRangesInner.from_dict(_item) for _item in obj["ranges"]] if obj.get("ranges") is not None else None,
            "staticLeases": [V1ExtranetsGet200ResponsePoliciesInnerBranchesExcludedDevicesInnerSegmentsInnerDhcpSubnetsInnerStaticLeasesInner.from_dict(_item) for _item in obj["staticLeases"]] if obj.get("staticLeases") is not None else None,
            "totalAddresses": obj.get("totalAddresses"),
            "utilization": obj.get("utilization")
        })
        return _obj


