# coding: utf-8

"""
    Kubernetes

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: release-1.29
    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 typing import Dict, List, Optional
from pydantic import BaseModel, Field, StrictStr, conlist
from .v1_endpoint_conditions import V1EndpointConditions
from .v1_endpoint_hints import V1EndpointHints
from .v1_object_reference import V1ObjectReference

class V1Endpoint(BaseModel):
    """
    Endpoint represents a single logical \"backend\" implementing a service.  # noqa: E501
    """
    addresses: conlist(StrictStr) = Field(..., description="addresses of this endpoint. The contents of this field are interpreted according to the corresponding EndpointSlice addressType field. Consumers must handle different types of addresses in the context of their own capabilities. This must contain at least one address but no more than 100. These are all assumed to be fungible and clients may choose to only use the first element. Refer to: https://issue.k8s.io/106267")
    conditions: Optional[V1EndpointConditions] = None
    deprecated_topology: Optional[Dict[str, StrictStr]] = Field(None, alias="deprecatedTopology", description="deprecatedTopology contains topology information part of the v1beta1 API. This field is deprecated, and will be removed when the v1beta1 API is removed (no sooner than kubernetes v1.24).  While this field can hold values, it is not writable through the v1 API, and any attempts to write to it will be silently ignored. Topology information can be found in the zone and nodeName fields instead.")
    hints: Optional[V1EndpointHints] = None
    hostname: Optional[StrictStr] = Field(None, description="hostname of this endpoint. This field may be used by consumers of endpoints to distinguish endpoints from each other (e.g. in DNS names). Multiple endpoints which use the same hostname should be considered fungible (e.g. multiple A values in DNS). Must be lowercase and pass DNS Label (RFC 1123) validation.")
    node_name: Optional[StrictStr] = Field(None, alias="nodeName", description="nodeName represents the name of the Node hosting this endpoint. This can be used to determine endpoints local to a Node.")
    target_ref: Optional[V1ObjectReference] = Field(None, alias="targetRef")
    zone: Optional[StrictStr] = Field(None, description="zone is the name of the Zone this endpoint exists in.")
    __properties = ["addresses", "conditions", "deprecatedTopology", "hints", "hostname", "nodeName", "targetRef", "zone"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> V1Endpoint:
        """Create an instance of V1Endpoint from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of conditions
        if self.conditions:
            _dict['conditions'] = self.conditions.to_dict()
        # override the default output from pydantic by calling `to_dict()` of hints
        if self.hints:
            _dict['hints'] = self.hints.to_dict()
        # override the default output from pydantic by calling `to_dict()` of target_ref
        if self.target_ref:
            _dict['targetRef'] = self.target_ref.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1Endpoint:
        """Create an instance of V1Endpoint from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1Endpoint.parse_obj(obj)

        _obj = V1Endpoint.parse_obj({
            "addresses": obj.get("addresses"),
            "conditions": V1EndpointConditions.from_dict(obj.get("conditions")) if obj.get("conditions") is not None else None,
            "deprecated_topology": obj.get("deprecatedTopology"),
            "hints": V1EndpointHints.from_dict(obj.get("hints")) if obj.get("hints") is not None else None,
            "hostname": obj.get("hostname"),
            "node_name": obj.get("nodeName"),
            "target_ref": V1ObjectReference.from_dict(obj.get("targetRef")) if obj.get("targetRef") is not None else None,
            "zone": obj.get("zone")
        })
        return _obj


