// <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>
    /// ContainerResourceMetricSource indicates how to scale on a resource
    /// metric known to Kubernetes, as specified in requests and limits,
    /// describing each pod in the current scale target (e.g. CPU or memory).
    /// The values will be averaged together before being compared to the
    /// target.  Such metrics are built in to Kubernetes, and have special
    /// scaling options on top of those available to normal per-pod metrics
    /// using the "pods" source.  Only one "target" type should be set.
    /// </summary>
    public partial class V2beta2ContainerResourceMetricSource
    {
        /// <summary>
        /// Initializes a new instance of the
        /// V2beta2ContainerResourceMetricSource class.
        /// </summary>
        public V2beta2ContainerResourceMetricSource()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the
        /// V2beta2ContainerResourceMetricSource class.
        /// </summary>
        /// <param name="container">container is the name of the container in
        /// the pods of the scaling target</param>
        /// <param name="name">name is the name of the resource in
        /// question.</param>
        /// <param name="target">target specifies the target value for the
        /// given metric</param>
        public V2beta2ContainerResourceMetricSource(string container, string name, V2beta2MetricTarget target)
        {
            Container = container;
            Name = name;
            Target = target;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets container is the name of the container in the pods of
        /// the scaling target
        /// </summary>
        [JsonProperty(PropertyName = "container")]
        public string Container { get; set; }

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

        /// <summary>
        /// Gets or sets target specifies the target value for the given metric
        /// </summary>
        [JsonProperty(PropertyName = "target")]
        public V2beta2MetricTarget Target { get; set; }

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