# 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 Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr

class V1ContainerPort(BaseModel):
    """
    ContainerPort represents a network port in a single container.  # noqa: E501
    """
    container_port: StrictInt = Field(..., alias="containerPort", description="Number of port to expose on the pod's IP address. This must be a valid port number, 0 < x < 65536.")
    host_ip: Optional[StrictStr] = Field(None, alias="hostIP", description="What host IP to bind the external port to.")
    host_port: Optional[StrictInt] = Field(None, alias="hostPort", description="Number of port to expose on the host. If specified, this must be a valid port number, 0 < x < 65536. If HostNetwork is specified, this must match ContainerPort. Most containers do not need this.")
    name: Optional[StrictStr] = Field(None, description="If specified, this must be an IANA_SVC_NAME and unique within the pod. Each named port in a pod must have a unique name. Name for the port that can be referred to by services.")
    protocol: Optional[StrictStr] = Field(None, description="Protocol for port. Must be UDP, TCP, or SCTP. Defaults to \"TCP\".")
    __properties = ["containerPort", "hostIP", "hostPort", "name", "protocol"]

    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) -> V1ContainerPort:
        """Create an instance of V1ContainerPort 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)
        return _dict

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

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

        _obj = V1ContainerPort.parse_obj({
            "container_port": obj.get("containerPort"),
            "host_ip": obj.get("hostIP"),
            "host_port": obj.get("hostPort"),
            "name": obj.get("name"),
            "protocol": obj.get("protocol")
        })
        return _obj


