// <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>
    /// CustomResourceConversion describes how to convert different versions of
    /// a CR.
    /// </summary>
    public partial class V1CustomResourceConversion
    {
        /// <summary>
        /// Initializes a new instance of the V1CustomResourceConversion class.
        /// </summary>
        public V1CustomResourceConversion()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1CustomResourceConversion class.
        /// </summary>
        /// <param name="strategy">strategy specifies how custom resources are
        /// converted between versions. Allowed values are: - `None`: The
        /// converter only change the apiVersion and would not touch any other
        /// field in the custom resource. - `Webhook`: API Server will call to
        /// an external webhook to do the conversion. Additional information
        /// is needed for this option. This requires spec.preserveUnknownFields
        /// to be false, and spec.conversion.webhook to be set.</param>
        /// <param name="webhook">webhook describes how to call the conversion
        /// webhook. Required when `strategy` is set to `Webhook`.</param>
        public V1CustomResourceConversion(string strategy, V1WebhookConversion webhook = default(V1WebhookConversion))
        {
            Strategy = strategy;
            Webhook = webhook;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets strategy specifies how custom resources are converted
        /// between versions. Allowed values are: - `None`: The converter only
        /// change the apiVersion and would not touch any other field in the
        /// custom resource. - `Webhook`: API Server will call to an external
        /// webhook to do the conversion. Additional information
        /// is needed for this option. This requires spec.preserveUnknownFields
        /// to be false, and spec.conversion.webhook to be set.
        /// </summary>
        [JsonProperty(PropertyName = "strategy")]
        public string Strategy { get; set; }

        /// <summary>
        /// Gets or sets webhook describes how to call the conversion webhook.
        /// Required when `strategy` is set to `Webhook`.
        /// </summary>
        [JsonProperty(PropertyName = "webhook")]
        public V1WebhookConversion Webhook { get; set; }

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