// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Microsoft.Azure.KeyVault.Models
{
    using Azure;
    using KeyVault;
    using Rest;
    using Rest.Serialization;
    using Newtonsoft.Json;
    using System.Linq;

    /// <summary>
    /// The key operations parameters.
    /// </summary>
    public partial class KeySignParameters
    {
        /// <summary>
        /// Initializes a new instance of the KeySignParameters class.
        /// </summary>
        public KeySignParameters() { }

        /// <summary>
        /// Initializes a new instance of the KeySignParameters class.
        /// </summary>
        /// <param name="algorithm">The signing/verification algorithm
        /// identifier. For more information on possible algorithm types, see
        /// JsonWebKeySignatureAlgorithm. Possible values include: 'RS256',
        /// 'RS384', 'RS512', 'RSNULL'</param>
        public KeySignParameters(string algorithm, byte[] value)
        {
            Algorithm = algorithm;
            Value = value;
        }

        /// <summary>
        /// Gets or sets the signing/verification algorithm identifier. For
        /// more information on possible algorithm types, see
        /// JsonWebKeySignatureAlgorithm. Possible values include: 'RS256',
        /// 'RS384', 'RS512', 'RSNULL'
        /// </summary>
        [JsonProperty(PropertyName = "alg")]
        public string Algorithm { get; set; }

        /// <summary>
        /// </summary>
        [JsonConverter(typeof(Base64UrlJsonConverter))]
        [JsonProperty(PropertyName = "value")]
        public byte[] Value { get; set; }

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

