// 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.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Microsoft.Azure.Batch.Protocol.Models
{
    using System.Linq;

    /// <summary>
    /// A reference to an application package to be deployed to compute nodes.
    /// </summary>
    public partial class ApplicationPackageReference
    {
        /// <summary>
        /// Initializes a new instance of the ApplicationPackageReference
        /// class.
        /// </summary>
        public ApplicationPackageReference() { }

        /// <summary>
        /// Initializes a new instance of the ApplicationPackageReference
        /// class.
        /// </summary>
        /// <param name="applicationId">The ID of the application to
        /// deploy.</param>
        /// <param name="version">The version of the application to deploy. If
        /// omitted, the default version is deployed.</param>
        public ApplicationPackageReference(string applicationId, string version = default(string))
        {
            this.ApplicationId = applicationId;
            this.Version = version;
        }

        /// <summary>
        /// Gets or sets the ID of the application to deploy.
        /// </summary>
        [Newtonsoft.Json.JsonProperty(PropertyName = "applicationId")]
        public string ApplicationId { get; set; }

        /// <summary>
        /// Gets or sets the version of the application to deploy. If omitted,
        /// the default version is deployed.
        /// </summary>
        /// <remarks>
        /// If this is omitted, and no default version is specified for this
        /// application, the request fails with the error code
        /// InvalidApplicationPackageReferences. If you are calling the REST
        /// API directly, the HTTP status code is 409.
        /// </remarks>
        [Newtonsoft.Json.JsonProperty(PropertyName = "version")]
        public string Version { get; set; }

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