// <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>
    /// OwnerReference contains enough information to let you identify an
    /// owning object. An owning object must be in the same namespace as the
    /// dependent, or be cluster-scoped, so there is no namespace field.
    /// </summary>
    public partial class V1OwnerReference
    {
        /// <summary>
        /// Initializes a new instance of the V1OwnerReference class.
        /// </summary>
        public V1OwnerReference()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1OwnerReference class.
        /// </summary>
        /// <param name="apiVersion">API version of the referent.</param>
        /// <param name="kind">Kind of the referent. More info:
        /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds</param>
        /// <param name="name">Name of the referent. More info:
        /// http://kubernetes.io/docs/user-guide/identifiers#names</param>
        /// <param name="uid">UID of the referent. More info:
        /// http://kubernetes.io/docs/user-guide/identifiers#uids</param>
        /// <param name="blockOwnerDeletion">If true, AND if the owner has the
        /// "foregroundDeletion" finalizer, then the owner cannot be deleted
        /// from the key-value store until this reference is removed. Defaults
        /// to false. To set this field, a user needs "delete" permission of
        /// the owner, otherwise 422 (Unprocessable Entity) will be
        /// returned.</param>
        /// <param name="controller">If true, this reference points to the
        /// managing controller.</param>
        public V1OwnerReference(string apiVersion, string kind, string name, string uid, bool? blockOwnerDeletion = default(bool?), bool? controller = default(bool?))
        {
            ApiVersion = apiVersion;
            BlockOwnerDeletion = blockOwnerDeletion;
            Controller = controller;
            Kind = kind;
            Name = name;
            Uid = uid;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets API version of the referent.
        /// </summary>
        [JsonProperty(PropertyName = "apiVersion")]
        public string ApiVersion { get; set; }

        /// <summary>
        /// Gets or sets if true, AND if the owner has the "foregroundDeletion"
        /// finalizer, then the owner cannot be deleted from the key-value
        /// store until this reference is removed. Defaults to false. To set
        /// this field, a user needs "delete" permission of the owner,
        /// otherwise 422 (Unprocessable Entity) will be returned.
        /// </summary>
        [JsonProperty(PropertyName = "blockOwnerDeletion")]
        public bool? BlockOwnerDeletion { get; set; }

        /// <summary>
        /// Gets or sets if true, this reference points to the managing
        /// controller.
        /// </summary>
        [JsonProperty(PropertyName = "controller")]
        public bool? Controller { get; set; }

        /// <summary>
        /// Gets or sets kind of the referent. More info:
        /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
        /// </summary>
        [JsonProperty(PropertyName = "kind")]
        public string Kind { get; set; }

        /// <summary>
        /// Gets or sets name of the referent. More info:
        /// http://kubernetes.io/docs/user-guide/identifiers#names
        /// </summary>
        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets UID of the referent. More info:
        /// http://kubernetes.io/docs/user-guide/identifiers#uids
        /// </summary>
        [JsonProperty(PropertyName = "uid")]
        public string Uid { get; set; }

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