// <auto-generated>
// Code generated by https://github.com/kubernetes-client/csharp/tree/master/src/LibKubernetesGenerator
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>

namespace k8s.Models
{
    /// <summary>
    /// {{ToXmlDoc def.description}}
    /// </summary>
    public partial class {{clz}}
    {
        /// <summary>
        /// Initializes a new instance of the {{GetClassName def}} class.
        /// </summary>
        public {{clz}}()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the {{GetClassName def}} class.
        /// </summary>
        {{ for property in properties }}
        {{ if property.IsRequired }}
        /// <param name="{{GetDotNetName property.name "fieldctor"}}">
        /// {{ToXmlDoc property.description}}
        /// </param>
        {{ end }}
        {{ end }}

        {{ for property in properties }}
        {{ if !property.IsRequired }}
        /// <param name="{{GetDotNetName property.name "fieldctor"}}">
        /// {{ToXmlDoc property.description}}
        /// </param>
        {{ end }}
        {{ end }}
        public {{clz}}({{GetModelCtorParam def}})
        {
            {{ for property in properties }}
            {{GetDotNetName property.name "field"}} = {{GetDotNetName property.name "fieldctor"}};
            {{ end }}
            CustomInit();
        }

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

        {{ for property in properties }}
        /// <summary>
        /// {{ToXmlDoc property.description}}
        /// </summary>
        [JsonPropertyName("{{property.name}}")]
        public {{GetDotNetType property}} {{GetDotNetName property.name "field"}} { get; set; }
        {{ end }}

        /// <summary>
        /// Validate the object.
        /// </summary>

        public virtual void Validate()
        {
            {{ for property in properties }}
            {{if IfType property "object" }}
            {{ if property.IsRequired }}
            if ({{GetDotNetName property.name "field"}} == null)
            {
                throw new ArgumentNullException("{{GetDotNetName property.name "field"}}");    
            }
            {{ end }}
            {{ end }}
            
            {{ end }}

            {{ for property in properties }}
            {{if IfType property "object" }}
            {{GetDotNetName property.name "field"}}?.Validate();
            {{ end }}

            {{if IfType property "objectarray" }}
            if ({{GetDotNetName property.name "field"}} != null){
                foreach(var obj in {{GetDotNetName property.name "field"}})
                {
                    obj.Validate();
                }
            }
            {{ end }}
            {{ end }}
        }
    }
}
