// <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.Collections;
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// Initializer describes the name and the failure policy of an
    /// initializer, and what resources it applies to.
    /// </summary>
    public partial class V1alpha1Initializer
    {
        /// <summary>
        /// Initializes a new instance of the V1alpha1Initializer class.
        /// </summary>
        public V1alpha1Initializer()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1alpha1Initializer class.
        /// </summary>
        /// <param name="name">Name is the identifier of the initializer. It
        /// will be added to the object that needs to be initialized. Name
        /// should be fully qualified, e.g., alwayspullimages.kubernetes.io,
        /// where "alwayspullimages" is the name of the webhook, and
        /// kubernetes.io is the name of the organization. Required</param>
        /// <param name="rules">Rules describes what resources/subresources the
        /// initializer cares about. The initializer cares about an operation
        /// if it matches _any_ Rule. Rule.Resources must not include
        /// subresources.</param>
        public V1alpha1Initializer(string name, IList<V1alpha1Rule> rules = default(IList<V1alpha1Rule>))
        {
            Name = name;
            Rules = rules;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets name is the identifier of the initializer. It will be
        /// added to the object that needs to be initialized. Name should be
        /// fully qualified, e.g., alwayspullimages.kubernetes.io, where
        /// "alwayspullimages" is the name of the webhook, and kubernetes.io is
        /// the name of the organization. Required
        /// </summary>
        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets rules describes what resources/subresources the
        /// initializer cares about. The initializer cares about an operation
        /// if it matches _any_ Rule. Rule.Resources must not include
        /// subresources.
        /// </summary>
        [JsonProperty(PropertyName = "rules")]
        public IList<V1alpha1Rule> Rules { get; set; }

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