// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Microsoft.Azure.Management.MachineLearning.WebServices.Models
{
    using Microsoft.Azure;
    using Microsoft.Azure.Management;
    using Microsoft.Azure.Management.MachineLearning;
    using Microsoft.Azure.Management.MachineLearning.WebServices;
    using Microsoft.Rest;
    using Newtonsoft.Json;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// The swagger 2.0 schema describing the service's inputs or outputs. See
    /// Swagger specification: http://swagger.io/specification/
    /// </summary>
    public partial class ServiceInputOutputSpecification
    {
        /// <summary>
        /// Initializes a new instance of the ServiceInputOutputSpecification
        /// class.
        /// </summary>
        public ServiceInputOutputSpecification()
        {
          CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the ServiceInputOutputSpecification
        /// class.
        /// </summary>
        /// <param name="type">The type of the entity described in swagger.
        /// Always 'object'.</param>
        /// <param name="properties">Specifies a collection that contains the
        /// column schema for each input or output of the web service. For more
        /// information, see the Swagger specification.</param>
        /// <param name="title">The title of your Swagger schema.</param>
        /// <param name="description">The description of the Swagger
        /// schema.</param>
        public ServiceInputOutputSpecification(string type, IDictionary<string, TableSpecification> properties, string title = default(string), string description = default(string))
        {
            Title = title;
            Description = description;
            Type = type;
            Properties = properties;
            CustomInit();
        }

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

        /// <summary>
        /// Gets or sets the title of your Swagger schema.
        /// </summary>
        [JsonProperty(PropertyName = "title")]
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the description of the Swagger schema.
        /// </summary>
        [JsonProperty(PropertyName = "description")]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the type of the entity described in swagger. Always
        /// 'object'.
        /// </summary>
        [JsonProperty(PropertyName = "type")]
        public string Type { get; set; }

        /// <summary>
        /// Gets or sets specifies a collection that contains the column schema
        /// for each input or output of the web service. For more information,
        /// see the Swagger specification.
        /// </summary>
        [JsonProperty(PropertyName = "properties")]
        public IDictionary<string, TableSpecification> Properties { get; set; }

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