﻿// *********************************************************************
// Copyright (c) Microsoft Corporation.  All rights reserved.
// Licensed under the MIT License
// *********************************************************************
using System;
using System.Collections.Generic;
using System.Text;

namespace DataX.SimulatedData.DataGenService.Model
{
    /// <summary>
    /// Class to create schema for data generated by DetaGenService
    /// </summary>
    public class DataSchema
    {
        //Time in minutes to reset the rules counter
        public int rulesCounterRefreshInMinutes { get; set; }
        //List of DataObjects 
        public List<DataObject> dataSchema { get; set; }
        //Counter for managing Rules data. Note: Donot include in schema file
        public int currentCounter { get; set; }
    }
    public class DataObject
    {
        //Name for the DataObject
        public string dataTypeName { get; set; }
        //Period in minutes when the DataObject would be simulated.
        public int simulationPeriodInMinute { get; set; }
        //Number of events to simulate in each batch
        public int numEventsPerBatch { get; set; }
        //List of fields in each simulated DataObject
        public List<Properties> fields { get; set; }
        //List of RulesData to simulate in each batch
        public List<RulesData> rulesData { get; set; }
    }

    public class Properties
    {
        //Name of the property
        public string name { get; set; }
        //Datatype of the property
        public string type { get; set; }
        //Value of property in case property value is constant
        public string value { get; set; }
        //Lengh of the array in case of an array type property
        public int length { get; set; }
        //Number of seconds to add in case of a datetime type property
        public double utcAddSeconds { get; set; }
        //DateTime format in case of a datetime type property
        public string datetimeStringFormat { get; set; }
        //Min value of property where property value is expected to be within a range
        public string minRange { get; set; }
        //Max value of property where property value is expected to be within a range
        public string maxRange { get; set; }
        //Flag to cast the value of non-string type property to string 
        public bool castAsString { get; set; }
        //List of strings to set as value for a string type property
        public List<string> valueList { get; set; }
        //List of properties
        public List<Properties> properties { get; set; }
    }

    public class RulesData
    {
        //Stream of data expected to be generated where the property value will not be random
        public string dataStream { get; set; }
        //Trigger conditions for RulesData
        public List<TriggerConditions> triggerConditions { get; set; }
    }

    public class TriggerConditions
    {
        //Parent JSON proerty path for which the value needs to be set
        public string parentJsonPropertyPath { get; set; }
        //Property name for which the value needs to be set
        public string propertyName { get; set; }
        //Property type for which the value needs to be set
        public string propertyType { get; set; }
        //Min value of the property for which the the rule will trigger an alert where value is within a range
        public double ruleTriggerMinRange { get; set; }
        //Max value of the property for which the the rule will trigger an alert where value is within a range
        public double ruleTriggerMaxRange { get; set; }
        //Min value of the property for which the the rule will not trigger an alert where value is within a range
        public double ruleNotTriggerMinRange { get; set; }
        //Max value of the property for which the the rule will not trigger an alert where value is within a range
        public double ruleNotTriggerMaxRange { get; set; }
        //Value of the property for which the rule will trigger an alert
        public string ruleTriggerValue { get; set; }
        //Value of the property for which the rule will not trigger an alert
        public string ruleNotTriggerValue { get; set; }
        //Instances in minutes where the rule is not expected to trigger an alert
        public List<int> ruleNotTriggerTimeInMinutes { get; set; }
        //Number of seconds to add in case of a datetime type property
        public double utcAddSeconds { get; set; }
        //DateTime format in case of a datetime type property
        public string datetimeStringFormat { get; set; }
        //Flag to cast the value of non-string type property to string 
        public bool castAsString { get; set; }
    }
}
