// <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>
    /// Event represents a single event to a watched resource.
    /// </summary>
    public partial class V1WatchEvent
    {
        /// <summary>
        /// Initializes a new instance of the V1WatchEvent class.
        /// </summary>
        public V1WatchEvent()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1WatchEvent class.
        /// </summary>
        /// <param name="objectProperty">Object is:
        /// * If Type is Added or Modified: the new state of the object.
        /// * If Type is Deleted: the state of the object immediately before
        /// deletion.
        /// * If Type is Error: *Status is recommended; other types may make
        /// sense
        /// depending on context.</param>
        public V1WatchEvent(RuntimeRawExtension objectProperty, string type)
        {
            ObjectProperty = objectProperty;
            Type = type;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets object is:
        /// * If Type is Added or Modified: the new state of the object.
        /// * If Type is Deleted: the state of the object immediately before
        /// deletion.
        /// * If Type is Error: *Status is recommended; other types may make
        /// sense
        /// depending on context.
        /// </summary>
        [JsonProperty(PropertyName = "object")]
        public RuntimeRawExtension ObjectProperty { get; set; }

        /// <summary>
        /// </summary>
        [JsonProperty(PropertyName = "type")]
        public string Type { get; set; }

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