// <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>
    /// CustomResourceDefinitionVersion describes a version for CRD.
    /// </summary>
    public partial class V1CustomResourceDefinitionVersion
    {
        /// <summary>
        /// Initializes a new instance of the V1CustomResourceDefinitionVersion
        /// class.
        /// </summary>
        public V1CustomResourceDefinitionVersion()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1CustomResourceDefinitionVersion
        /// class.
        /// </summary>
        /// <param name="name">name is the version name, e.g. “v1”, “v2beta1”,
        /// etc. The custom resources are served under this version at
        /// `/apis/&lt;group&gt;/&lt;version&gt;/...` if `served` is
        /// true.</param>
        /// <param name="served">served is a flag enabling/disabling this
        /// version from being served via REST APIs</param>
        /// <param name="storage">storage indicates this version should be used
        /// when persisting custom resources to storage. There must be exactly
        /// one version with storage=true.</param>
        /// <param name="additionalPrinterColumns">additionalPrinterColumns
        /// specifies additional columns returned in Table output. See
        /// https://kubernetes.io/docs/reference/using-api/api-concepts/#receiving-resources-as-tables
        /// for details. If no columns are specified, a single column
        /// displaying the age of the custom resource is used.</param>
        /// <param name="deprecated">deprecated indicates this version of the
        /// custom resource API is deprecated. When set to true, API requests
        /// to this version receive a warning header in the server response.
        /// Defaults to false.</param>
        /// <param name="deprecationWarning">deprecationWarning overrides the
        /// default warning returned to API clients. May only be set when
        /// `deprecated` is true. The default warning indicates this version is
        /// deprecated and recommends use of the newest served version of equal
        /// or greater stability, if one exists.</param>
        /// <param name="schema">schema describes the schema used for
        /// validation, pruning, and defaulting of this version of the custom
        /// resource.</param>
        /// <param name="subresources">subresources specify what subresources
        /// this version of the defined custom resource have.</param>
        public V1CustomResourceDefinitionVersion(string name, bool served, bool storage, IList<V1CustomResourceColumnDefinition> additionalPrinterColumns = default(IList<V1CustomResourceColumnDefinition>), bool? deprecated = default(bool?), string deprecationWarning = default(string), V1CustomResourceValidation schema = default(V1CustomResourceValidation), V1CustomResourceSubresources subresources = default(V1CustomResourceSubresources))
        {
            AdditionalPrinterColumns = additionalPrinterColumns;
            Deprecated = deprecated;
            DeprecationWarning = deprecationWarning;
            Name = name;
            Schema = schema;
            Served = served;
            Storage = storage;
            Subresources = subresources;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets additionalPrinterColumns specifies additional columns
        /// returned in Table output. See
        /// https://kubernetes.io/docs/reference/using-api/api-concepts/#receiving-resources-as-tables
        /// for details. If no columns are specified, a single column
        /// displaying the age of the custom resource is used.
        /// </summary>
        [JsonProperty(PropertyName = "additionalPrinterColumns")]
        public IList<V1CustomResourceColumnDefinition> AdditionalPrinterColumns { get; set; }

        /// <summary>
        /// Gets or sets deprecated indicates this version of the custom
        /// resource API is deprecated. When set to true, API requests to this
        /// version receive a warning header in the server response. Defaults
        /// to false.
        /// </summary>
        [JsonProperty(PropertyName = "deprecated")]
        public bool? Deprecated { get; set; }

        /// <summary>
        /// Gets or sets deprecationWarning overrides the default warning
        /// returned to API clients. May only be set when `deprecated` is true.
        /// The default warning indicates this version is deprecated and
        /// recommends use of the newest served version of equal or greater
        /// stability, if one exists.
        /// </summary>
        [JsonProperty(PropertyName = "deprecationWarning")]
        public string DeprecationWarning { get; set; }

        /// <summary>
        /// Gets or sets name is the version name, e.g. “v1”, “v2beta1”, etc.
        /// The custom resources are served under this version at
        /// `/apis/&amp;lt;group&amp;gt;/&amp;lt;version&amp;gt;/...` if
        /// `served` is true.
        /// </summary>
        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets schema describes the schema used for validation,
        /// pruning, and defaulting of this version of the custom resource.
        /// </summary>
        [JsonProperty(PropertyName = "schema")]
        public V1CustomResourceValidation Schema { get; set; }

        /// <summary>
        /// Gets or sets served is a flag enabling/disabling this version from
        /// being served via REST APIs
        /// </summary>
        [JsonProperty(PropertyName = "served")]
        public bool Served { get; set; }

        /// <summary>
        /// Gets or sets storage indicates this version should be used when
        /// persisting custom resources to storage. There must be exactly one
        /// version with storage=true.
        /// </summary>
        [JsonProperty(PropertyName = "storage")]
        public bool Storage { get; set; }

        /// <summary>
        /// Gets or sets subresources specify what subresources this version of
        /// the defined custom resource have.
        /// </summary>
        [JsonProperty(PropertyName = "subresources")]
        public V1CustomResourceSubresources Subresources { 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");
            }
            if (AdditionalPrinterColumns != null)
            {
                foreach (var element in AdditionalPrinterColumns)
                {
                    if (element != null)
                    {
                        element.Validate();
                    }
                }
            }
            if (Subresources != null)
            {
                Subresources.Validate();
            }
        }
    }
}
