// <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 Newtonsoft.Json;
    using System.Linq;

    /// <summary>
    /// NetworkPolicyPeer describes a peer to allow traffic to/from. Only
    /// certain combinations of fields are allowed
    /// </summary>
    public partial class V1NetworkPolicyPeer
    {
        /// <summary>
        /// Initializes a new instance of the V1NetworkPolicyPeer class.
        /// </summary>
        public V1NetworkPolicyPeer()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1NetworkPolicyPeer class.
        /// </summary>
        /// <param name="ipBlock">IPBlock defines policy on a particular
        /// IPBlock. If this field is set then neither of the other fields can
        /// be.</param>
        /// <param name="namespaceSelector">Selects Namespaces using
        /// cluster-scoped labels. This field follows standard label selector
        /// semantics; if present but empty, it selects all namespaces.
        ///
        /// If PodSelector is also set, then the NetworkPolicyPeer as a whole
        /// selects the Pods matching PodSelector in the Namespaces selected by
        /// NamespaceSelector. Otherwise it selects all Pods in the Namespaces
        /// selected by NamespaceSelector.</param>
        /// <param name="podSelector">This is a label selector which selects
        /// Pods. This field follows standard label selector semantics; if
        /// present but empty, it selects all pods.
        ///
        /// If NamespaceSelector is also set, then the NetworkPolicyPeer as a
        /// whole selects the Pods matching PodSelector in the Namespaces
        /// selected by NamespaceSelector. Otherwise it selects the Pods
        /// matching PodSelector in the policy's own Namespace.</param>
        public V1NetworkPolicyPeer(V1IPBlock ipBlock = default(V1IPBlock), V1LabelSelector namespaceSelector = default(V1LabelSelector), V1LabelSelector podSelector = default(V1LabelSelector))
        {
            IpBlock = ipBlock;
            NamespaceSelector = namespaceSelector;
            PodSelector = podSelector;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets iPBlock defines policy on a particular IPBlock. If
        /// this field is set then neither of the other fields can be.
        /// </summary>
        [JsonProperty(PropertyName = "ipBlock")]
        public V1IPBlock IpBlock { get; set; }

        /// <summary>
        /// Gets or sets selects Namespaces using cluster-scoped labels. This
        /// field follows standard label selector semantics; if present but
        /// empty, it selects all namespaces.
        ///
        /// If PodSelector is also set, then the NetworkPolicyPeer as a whole
        /// selects the Pods matching PodSelector in the Namespaces selected by
        /// NamespaceSelector. Otherwise it selects all Pods in the Namespaces
        /// selected by NamespaceSelector.
        /// </summary>
        [JsonProperty(PropertyName = "namespaceSelector")]
        public V1LabelSelector NamespaceSelector { get; set; }

        /// <summary>
        /// Gets or sets this is a label selector which selects Pods. This
        /// field follows standard label selector semantics; if present but
        /// empty, it selects all pods.
        ///
        /// If NamespaceSelector is also set, then the NetworkPolicyPeer as a
        /// whole selects the Pods matching PodSelector in the Namespaces
        /// selected by NamespaceSelector. Otherwise it selects the Pods
        /// matching PodSelector in the policy's own Namespace.
        /// </summary>
        [JsonProperty(PropertyName = "podSelector")]
        public V1LabelSelector PodSelector { get; set; }

        /// <summary>
        /// Validate the object.
        /// </summary>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown if validation fails
        /// </exception>
        public virtual void Validate()
        {
            if (IpBlock != null)
            {
                IpBlock.Validate();
            }
        }
    }
}
