# generated by datamodel-codegen:
#   filename:  _definitions.json
#   timestamp: 2021-01-20T05:35:16+00:00

from __future__ import annotations

from typing import Dict, List, Optional

from pydantic import BaseModel, Field

from ..... import Kind86, Kind87, Topology
from ...apimachinery.pkg.apis.meta import v1 as v1_1
from ..core import v1


class EndpointConditions(BaseModel):
    ready: Optional[bool] = Field(
        None,
        description='ready indicates that this endpoint is prepared to receive traffic, according to whatever system is managing the endpoint. A nil value indicates an unknown state. In most cases consumers should interpret this unknown state as ready. For compatibility reasons, ready should never be "true" for terminating endpoints.',
    )
    serving: Optional[bool] = Field(
        None,
        description='serving is identical to ready except that it is set regardless of the terminating state of endpoints. This condition should be set to true for a ready endpoint that is terminating. If nil, consumers should defer to the ready condition. This field can be enabled with the EndpointSliceTerminatingCondition feature gate.',
    )
    terminating: Optional[bool] = Field(
        None,
        description='terminating indicates that this endpoint is terminating. A nil value indicates an unknown state. Consumers should interpret this unknown state to mean that the endpoint is not terminating. This field can be enabled with the EndpointSliceTerminatingCondition feature gate.',
    )


class EndpointPort(BaseModel):
    appProtocol: Optional[str] = Field(
        None,
        description='The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and http://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol.',
    )
    name: Optional[str] = Field(
        None,
        description="The name of this port. All ports in an EndpointSlice must have a unique name. If the EndpointSlice is dervied from a Kubernetes service, this corresponds to the Service.ports[].name. Name must either be an empty string or pass DNS_LABEL validation: * must be no more than 63 characters long. * must consist of lower case alphanumeric characters or '-'. * must start and end with an alphanumeric character. Default is empty string.",
    )
    port: Optional[int] = Field(
        None,
        description='The port number of the endpoint. If this is not specified, ports are not restricted and must be interpreted in the context of the specific consumer.',
    )
    protocol: Optional[str] = Field(
        None,
        description='The IP protocol for this port. Must be UDP, TCP, or SCTP. Default is TCP.',
    )


class Endpoint(BaseModel):
    addresses: List[str] = 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.',
    )
    conditions: Optional[EndpointConditions] = Field(
        None,
        description='conditions contains information about the current status of the endpoint.',
    )
    hostname: Optional[str] = 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.',
    )
    nodeName: Optional[str] = Field(
        None,
        description='nodeName represents the name of the Node hosting this endpoint. This can be used to determine endpoints local to a Node. This field can be enabled with the EndpointSliceNodeName feature gate.',
    )
    targetRef: Optional[v1.ObjectReference] = Field(
        None,
        description='targetRef is a reference to a Kubernetes object that represents this endpoint.',
    )
    topology: Optional[Dict[str, Topology]] = Field(
        None,
        description='topology contains arbitrary topology information associated with the endpoint. These key/value pairs must conform with the label format. https://kubernetes.io/docs/concepts/overview/working-with-objects/labels Topology may include a maximum of 16 key/value pairs. This includes, but is not limited to the following well known keys: * kubernetes.io/hostname: the value indicates the hostname of the node\n  where the endpoint is located. This should match the corresponding\n  node label.\n* topology.kubernetes.io/zone: the value indicates the zone where the\n  endpoint is located. This should match the corresponding node label.\n* topology.kubernetes.io/region: the value indicates the region where the\n  endpoint is located. This should match the corresponding node label.\nThis field is deprecated and will be removed in future api versions.',
    )


class EndpointSlice(BaseModel):
    addressType: str = Field(
        ...,
        description='addressType specifies the type of address carried by this EndpointSlice. All addresses in this slice must be the same type. This field is immutable after creation. The following address types are currently supported: * IPv4: Represents an IPv4 Address. * IPv6: Represents an IPv6 Address. * FQDN: Represents a Fully Qualified Domain Name.',
    )
    apiVersion: Optional[str] = Field(
        None,
        description='APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources',
    )
    endpoints: List[Endpoint] = Field(
        ...,
        description='endpoints is a list of unique endpoints in this slice. Each slice may include a maximum of 1000 endpoints.',
    )
    kind: Optional[Kind86] = Field(
        None,
        description='Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds',
    )
    metadata: Optional[v1_1.ObjectMeta] = Field(
        None, description="Standard object's metadata."
    )
    ports: Optional[List[EndpointPort]] = Field(
        None,
        description='ports specifies the list of network ports exposed by each endpoint in this slice. Each port must have a unique name. When ports is empty, it indicates that there are no defined ports. When a port is defined with a nil port value, it indicates "all ports". Each slice may include a maximum of 100 ports.',
    )


class EndpointSliceList(BaseModel):
    apiVersion: Optional[str] = Field(
        None,
        description='APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources',
    )
    items: List[EndpointSlice] = Field(..., description='List of endpoint slices')
    kind: Optional[Kind87] = Field(
        None,
        description='Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds',
    )
    metadata: Optional[v1_1.ListMeta] = Field(
        None, description='Standard list metadata.'
    )
