// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>

namespace k8s.Models
{
    using Microsoft.Rest;
    using Newtonsoft.Json;
    using System.Linq;

    /// <summary>
    /// EndpointAddress is a tuple that describes single IP address.
    /// </summary>
    public partial class V1EndpointAddress
    {
        /// <summary>
        /// Initializes a new instance of the V1EndpointAddress class.
        /// </summary>
        public V1EndpointAddress()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1EndpointAddress class.
        /// </summary>
        /// <param name="ip">The IP of this endpoint. May not be loopback
        /// (127.0.0.0/8), link-local (169.254.0.0/16), or link-local multicast
        /// ((224.0.0.0/24). IPv6 is also accepted but not fully supported on
        /// all platforms. Also, certain kubernetes components, like
        /// kube-proxy, are not IPv6 ready.</param>
        /// <param name="hostname">The Hostname of this endpoint</param>
        /// <param name="nodeName">Optional: Node hosting this endpoint. This
        /// can be used to determine endpoints local to a node.</param>
        /// <param name="targetRef">Reference to object providing the
        /// endpoint.</param>
        public V1EndpointAddress(string ip, string hostname = default(string), string nodeName = default(string), V1ObjectReference targetRef = default(V1ObjectReference))
        {
            Hostname = hostname;
            Ip = ip;
            NodeName = nodeName;
            TargetRef = targetRef;
            CustomInit();
        }

        /// <summary>
        /// An initialization method that performs custom operations like setting defaults
        /// </summary>
        partial void CustomInit();

        /// <summary>
        /// Gets or sets the Hostname of this endpoint
        /// </summary>
        [JsonProperty(PropertyName = "hostname")]
        public string Hostname { get; set; }

        /// <summary>
        /// Gets or sets the IP of this endpoint. May not be loopback
        /// (127.0.0.0/8), link-local (169.254.0.0/16), or link-local multicast
        /// ((224.0.0.0/24). IPv6 is also accepted but not fully supported on
        /// all platforms. Also, certain kubernetes components, like
        /// kube-proxy, are not IPv6 ready.
        /// </summary>
        [JsonProperty(PropertyName = "ip")]
        public string Ip { get; set; }

        /// <summary>
        /// Gets or sets optional: Node hosting this endpoint. This can be used
        /// to determine endpoints local to a node.
        /// </summary>
        [JsonProperty(PropertyName = "nodeName")]
        public string NodeName { get; set; }

        /// <summary>
        /// Gets or sets reference to object providing the endpoint.
        /// </summary>
        [JsonProperty(PropertyName = "targetRef")]
        public V1ObjectReference TargetRef { get; set; }

        /// <summary>
        /// Validate the object.
        /// </summary>
        /// <exception cref="ValidationException">
        /// Thrown if validation fails
        /// </exception>
        public virtual void Validate()
        {
            if (Ip == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "Ip");
            }
        }
    }
}
