// <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.Collections;
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// TokenRequestSpec contains client provided parameters of a token
    /// request.
    /// </summary>
    public partial class V1TokenRequestSpec
    {
        /// <summary>
        /// Initializes a new instance of the V1TokenRequestSpec class.
        /// </summary>
        public V1TokenRequestSpec()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the V1TokenRequestSpec class.
        /// </summary>
        /// <param name="audiences">Audiences are the intendend audiences of
        /// the token. A recipient of a token must identitfy themself with an
        /// identifier in the list of audiences of the token, and otherwise
        /// should reject the token. A token issued for multiple audiences may
        /// be used to authenticate against any of the audiences listed but
        /// implies a high degree of trust between the target
        /// audiences.</param>
        /// <param name="boundObjectRef">BoundObjectRef is a reference to an
        /// object that the token will be bound to. The token will only be
        /// valid for as long as the bound object exists. NOTE: The API
        /// server's TokenReview endpoint will validate the BoundObjectRef, but
        /// other audiences may not. Keep ExpirationSeconds small if you want
        /// prompt revocation.</param>
        /// <param name="expirationSeconds">ExpirationSeconds is the requested
        /// duration of validity of the request. The token issuer may return a
        /// token with a different validity duration so a client needs to check
        /// the 'expiration' field in a response.</param>
        public V1TokenRequestSpec(IList<string> audiences, V1BoundObjectReference boundObjectRef = default(V1BoundObjectReference), long? expirationSeconds = default(long?))
        {
            Audiences = audiences;
            BoundObjectRef = boundObjectRef;
            ExpirationSeconds = expirationSeconds;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets audiences are the intendend audiences of the token. A
        /// recipient of a token must identitfy themself with an identifier in
        /// the list of audiences of the token, and otherwise should reject the
        /// token. A token issued for multiple audiences may be used to
        /// authenticate against any of the audiences listed but implies a high
        /// degree of trust between the target audiences.
        /// </summary>
        [JsonProperty(PropertyName = "audiences")]
        public IList<string> Audiences { get; set; }

        /// <summary>
        /// Gets or sets boundObjectRef is a reference to an object that the
        /// token will be bound to. The token will only be valid for as long as
        /// the bound object exists. NOTE: The API server's TokenReview
        /// endpoint will validate the BoundObjectRef, but other audiences may
        /// not. Keep ExpirationSeconds small if you want prompt revocation.
        /// </summary>
        [JsonProperty(PropertyName = "boundObjectRef")]
        public V1BoundObjectReference BoundObjectRef { get; set; }

        /// <summary>
        /// Gets or sets expirationSeconds is the requested duration of
        /// validity of the request. The token issuer may return a token with a
        /// different validity duration so a client needs to check the
        /// 'expiration' field in a response.
        /// </summary>
        [JsonProperty(PropertyName = "expirationSeconds")]
        public long? ExpirationSeconds { get; set; }

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