// <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>
    /// CertificateSigningRequest objects provide a mechanism to obtain x509
    /// certificates by submitting a certificate signing request, and having it
    /// asynchronously approved and issued.
    ///
    /// Kubelets use this API to obtain:
    /// 1. client certificates to authenticate to kube-apiserver (with the
    /// "kubernetes.io/kube-apiserver-client-kubelet" signerName).
    /// 2. serving certificates for TLS endpoints kube-apiserver can connect to
    /// securely (with the "kubernetes.io/kubelet-serving" signerName).
    ///
    /// This API can be used to request client certificates to authenticate to
    /// kube-apiserver (with the "kubernetes.io/kube-apiserver-client"
    /// signerName), or to obtain certificates from custom non-Kubernetes
    /// signers.
    /// </summary>
    public partial class V1CertificateSigningRequest
    {
        /// <summary>
        /// Initializes a new instance of the V1CertificateSigningRequest
        /// class.
        /// </summary>
        public V1CertificateSigningRequest()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1CertificateSigningRequest
        /// class.
        /// </summary>
        /// <param name="spec">spec contains the certificate request, and is
        /// immutable after creation. Only the request, signerName, and usages
        /// fields can be set on creation. Other fields are derived by
        /// Kubernetes and cannot be modified by users.</param>
        /// <param name="apiVersion">APIVersion defines the versioned schema of
        /// this representation of an object. Servers should convert recognized
        /// schemas to the latest internal value, and may reject unrecognized
        /// values. More info:
        /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources</param>
        /// <param name="kind">Kind is a string value representing the REST
        /// resource this object represents. Servers may infer this from the
        /// endpoint the client submits requests to. Cannot be updated. In
        /// CamelCase. More info:
        /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds</param>
        /// <param name="status">status contains information about whether the
        /// request is approved or denied, and the certificate issued by the
        /// signer, or the failure condition indicating signer failure.</param>
        public V1CertificateSigningRequest(V1CertificateSigningRequestSpec spec, string apiVersion = default(string), string kind = default(string), V1ObjectMeta metadata = default(V1ObjectMeta), V1CertificateSigningRequestStatus status = default(V1CertificateSigningRequestStatus))
        {
            ApiVersion = apiVersion;
            Kind = kind;
            Metadata = metadata;
            Spec = spec;
            Status = status;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets aPIVersion defines the versioned schema of this
        /// representation of an object. Servers should convert recognized
        /// schemas to the latest internal value, and may reject unrecognized
        /// values. More info:
        /// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
        /// </summary>
        [JsonProperty(PropertyName = "apiVersion")]
        public string ApiVersion { get; set; }

        /// <summary>
        /// Gets or sets kind is a string value representing the REST resource
        /// this object represents. Servers may infer this from the endpoint
        /// the client submits requests to. Cannot be updated. In CamelCase.
        /// 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>
        /// </summary>
        [JsonProperty(PropertyName = "metadata")]
        public V1ObjectMeta Metadata { get; set; }

        /// <summary>
        /// Gets or sets spec contains the certificate request, and is
        /// immutable after creation. Only the request, signerName, and usages
        /// fields can be set on creation. Other fields are derived by
        /// Kubernetes and cannot be modified by users.
        /// </summary>
        [JsonProperty(PropertyName = "spec")]
        public V1CertificateSigningRequestSpec Spec { get; set; }

        /// <summary>
        /// Gets or sets status contains information about whether the request
        /// is approved or denied, and the certificate issued by the signer, or
        /// the failure condition indicating signer failure.
        /// </summary>
        [JsonProperty(PropertyName = "status")]
        public V1CertificateSigningRequestStatus Status { get; set; }

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