// <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>
    /// ObjectMetricSource indicates how to scale on a metric describing a
    /// kubernetes object (for example, hits-per-second on an Ingress object).
    /// </summary>
    public partial class V2beta1ObjectMetricSource
    {
        /// <summary>
        /// Initializes a new instance of the V2beta1ObjectMetricSource class.
        /// </summary>
        public V2beta1ObjectMetricSource()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V2beta1ObjectMetricSource class.
        /// </summary>
        /// <param name="metricName">metricName is the name of the metric in
        /// question.</param>
        /// <param name="target">target is the described Kubernetes
        /// object.</param>
        /// <param name="targetValue">targetValue is the target value of the
        /// metric (as a quantity).</param>
        /// <param name="averageValue">averageValue is the target value of the
        /// average of the metric across all relevant pods (as a
        /// quantity)</param>
        /// <param name="selector">selector is the string-encoded form of a
        /// standard kubernetes label selector for the given metric When set,
        /// it is passed as an additional parameter to the metrics server for
        /// more specific metrics scoping When unset, just the metricName will
        /// be used to gather metrics.</param>
        public V2beta1ObjectMetricSource(string metricName, V2beta1CrossVersionObjectReference target, ResourceQuantity targetValue, ResourceQuantity averageValue = default(ResourceQuantity), V1LabelSelector selector = default(V1LabelSelector))
        {
            AverageValue = averageValue;
            MetricName = metricName;
            Selector = selector;
            Target = target;
            TargetValue = targetValue;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets averageValue is the target value of the average of the
        /// metric across all relevant pods (as a quantity)
        /// </summary>
        [JsonProperty(PropertyName = "averageValue")]
        public ResourceQuantity AverageValue { get; set; }

        /// <summary>
        /// Gets or sets metricName is the name of the metric in question.
        /// </summary>
        [JsonProperty(PropertyName = "metricName")]
        public string MetricName { get; set; }

        /// <summary>
        /// Gets or sets selector is the string-encoded form of a standard
        /// kubernetes label selector for the given metric When set, it is
        /// passed as an additional parameter to the metrics server for more
        /// specific metrics scoping When unset, just the metricName will be
        /// used to gather metrics.
        /// </summary>
        [JsonProperty(PropertyName = "selector")]
        public V1LabelSelector Selector { get; set; }

        /// <summary>
        /// Gets or sets target is the described Kubernetes object.
        /// </summary>
        [JsonProperty(PropertyName = "target")]
        public V2beta1CrossVersionObjectReference Target { get; set; }

        /// <summary>
        /// Gets or sets targetValue is the target value of the metric (as a
        /// quantity).
        /// </summary>
        [JsonProperty(PropertyName = "targetValue")]
        public ResourceQuantity TargetValue { get; set; }

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