generated/api/Models/AlertRuleQueryEntityDetails.json.cs

// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/powershell@4.0.708)
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

namespace Commvault.Powershell.Models
{
    using static Commvault.Powershell.Runtime.Extensions;

    /// <summary>query entity object</summary>
    public partial class AlertRuleQueryEntityDetails
    {

        /// <summary>
        /// <c>AfterFromJson</c> will be called after the json deserialization has finished, allowing customization of the object
        /// before it is returned. Implement this method in a partial class to enable this behavior
        /// </summary>
        /// <param name="json">The JsonNode that should be deserialized into this object.</param>

        partial void AfterFromJson(Commvault.Powershell.Runtime.Json.JsonObject json);

        /// <summary>
        /// <c>AfterToJson</c> will be called after the json serialization has finished, allowing customization of the <see cref="Commvault.Powershell.Runtime.Json.JsonObject"
        /// /> before it is returned. Implement this method in a partial class to enable this behavior
        /// </summary>
        /// <param name="container">The JSON container that the serialization result will be placed in.</param>

        partial void AfterToJson(ref Commvault.Powershell.Runtime.Json.JsonObject container);

        /// <summary>
        /// <c>BeforeFromJson</c> will be called before the json deserialization has commenced, allowing complete customization of
        /// the object before it is deserialized.
        /// If you wish to disable the default deserialization entirely, return <c>true</c> in the <paramref name= "returnNow" />
        /// output parameter.
        /// Implement this method in a partial class to enable this behavior.
        /// </summary>
        /// <param name="json">The JsonNode that should be deserialized into this object.</param>
        /// <param name="returnNow">Determines if the rest of the deserialization should be processed, or if the method should return
        /// instantly.</param>

        partial void BeforeFromJson(Commvault.Powershell.Runtime.Json.JsonObject json, ref bool returnNow);

        /// <summary>
        /// <c>BeforeToJson</c> will be called before the json serialization has commenced, allowing complete customization of the
        /// object before it is serialized.
        /// If you wish to disable the default serialization entirely, return <c>true</c> in the <paramref name="returnNow" /> output
        /// parameter.
        /// Implement this method in a partial class to enable this behavior.
        /// </summary>
        /// <param name="container">The JSON container that the serialization result will be placed in.</param>
        /// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return
        /// instantly.</param>

        partial void BeforeToJson(ref Commvault.Powershell.Runtime.Json.JsonObject container, ref bool returnNow);

        /// <summary>
        /// Deserializes a Commvault.Powershell.Runtime.Json.JsonObject into a new instance of <see cref="AlertRuleQueryEntityDetails" />.
        /// </summary>
        /// <param name="json">A Commvault.Powershell.Runtime.Json.JsonObject instance to deserialize from.</param>
        internal AlertRuleQueryEntityDetails(Commvault.Powershell.Runtime.Json.JsonObject json)
        {
            bool returnNow = false;
            BeforeFromJson(json, ref returnNow);
            if (returnNow)
            {
                return;
            }
            {_creator = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("creator"), out var __jsonCreator) ? Commvault.Powershell.Models.AlertRuleQueryCreator.FromJson(__jsonCreator) : _creator;}
            {_additionalQueryDetails = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("additionalQueryDetails"), out var __jsonAdditionalQueryDetails) ? Commvault.Powershell.Models.AlertRuleAdditionalQueryDetails.FromJson(__jsonAdditionalQueryDetails) : _additionalQueryDetails;}
            {_queryEntity = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("queryEntity"), out var __jsonQueryEntity) ? Commvault.Powershell.Models.AlertRuleQueryEntity.FromJson(__jsonQueryEntity) : _queryEntity;}
            {_securityAssociations = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("securityAssociations"), out var __jsonSecurityAssociations) ? Commvault.Powershell.Models.AlertRuleSecurityAssociations.FromJson(__jsonSecurityAssociations) : _securityAssociations;}
            {_isQueryModifyEnabled = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("isQueryModifyEnabled"), out var __jsonIsQueryModifyEnabled) ? (bool?)__jsonIsQueryModifyEnabled : _isQueryModifyEnabled;}
            {_visibility = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("visibility"), out var __jsonVisibility) ? (long?)__jsonVisibility : _visibility;}
            {_sqlQuery = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("sqlQuery"), out var __jsonSqlQuery) ? (string)__jsonSqlQuery : (string)_sqlQuery;}
            {_doesQuerySupportOutputFilter = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("doesQuerySupportOutputFilter"), out var __jsonDoesQuerySupportOutputFilter) ? (bool?)__jsonDoesQuerySupportOutputFilter : _doesQuerySupportOutputFilter;}
            {_frequency = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("frequency"), out var __jsonFrequency) ? (long?)__jsonFrequency : _frequency;}
            {_isOverwriteAssociationAtAlertAllowed = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("isOverwriteAssociationAtAlertAllowed"), out var __jsonIsOverwriteAssociationAtAlertAllowed) ? (bool?)__jsonIsOverwriteAssociationAtAlertAllowed : _isOverwriteAssociationAtAlertAllowed;}
            {_isSystemCreated = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("isSystemCreated"), out var __jsonIsSystemCreated) ? (bool?)__jsonIsSystemCreated : _isSystemCreated;}
            {_isPrimaryKeyPresent = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("isPrimaryKeyPresent"), out var __jsonIsPrimaryKeyPresent) ? (bool?)__jsonIsPrimaryKeyPresent : _isPrimaryKeyPresent;}
            {_isDisabled = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("isDisabled"), out var __jsonIsDisabled) ? (bool?)__jsonIsDisabled : _isDisabled;}
            {_queryDescription = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("queryDescription"), out var __jsonQueryDescription) ? (string)__jsonQueryDescription : (string)_queryDescription;}
            {_queryCriteriaName = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("queryCriteriaName"), out var __jsonQueryCriteriaName) ? (string)__jsonQueryCriteriaName : (string)_queryCriteriaName;}
            {_customAlertType = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("customAlertType"), out var __jsonCustomAlertType) ? (long?)__jsonCustomAlertType : _customAlertType;}
            {_queryOutputColumns = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("queryOutputColumns"), out var __jsonQueryOutputColumns) ? If( __jsonQueryOutputColumns as Commvault.Powershell.Runtime.Json.JsonArray, out var __v) ? new global::System.Func<System.Collections.Generic.List<Commvault.Powershell.Models.IAlertRuleQueryOutputColumnObject>>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(Commvault.Powershell.Models.IAlertRuleQueryOutputColumnObject) (Commvault.Powershell.Models.AlertRuleQueryOutputColumnObject.FromJson(__u) )) ))() : null : _queryOutputColumns;}
            AfterFromJson(json);
        }

        /// <summary>
        /// Deserializes a <see cref="Commvault.Powershell.Runtime.Json.JsonNode"/> into an instance of Commvault.Powershell.Models.IAlertRuleQueryEntityDetails.
        /// </summary>
        /// <param name="node">a <see cref="Commvault.Powershell.Runtime.Json.JsonNode" /> to deserialize from.</param>
        /// <returns>an instance of Commvault.Powershell.Models.IAlertRuleQueryEntityDetails.</returns>
        public static Commvault.Powershell.Models.IAlertRuleQueryEntityDetails FromJson(Commvault.Powershell.Runtime.Json.JsonNode node)
        {
            return node is Commvault.Powershell.Runtime.Json.JsonObject json ? new AlertRuleQueryEntityDetails(json) : null;
        }

        /// <summary>
        /// Serializes this instance of <see cref="AlertRuleQueryEntityDetails" /> into a <see cref="Commvault.Powershell.Runtime.Json.JsonNode" />.
        /// </summary>
        /// <param name="container">The <see cref="Commvault.Powershell.Runtime.Json.JsonObject"/> container to serialize this object into. If the caller
        /// passes in <c>null</c>, a new instance will be created and returned to the caller.</param>
        /// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Commvault.Powershell.Runtime.SerializationMode"/>.</param>
        /// <returns>
        /// a serialized instance of <see cref="AlertRuleQueryEntityDetails" /> as a <see cref="Commvault.Powershell.Runtime.Json.JsonNode" />.
        /// </returns>
        public Commvault.Powershell.Runtime.Json.JsonNode ToJson(Commvault.Powershell.Runtime.Json.JsonObject container, Commvault.Powershell.Runtime.SerializationMode serializationMode)
        {
            container = container ?? new Commvault.Powershell.Runtime.Json.JsonObject();

            bool returnNow = false;
            BeforeToJson(ref container, ref returnNow);
            if (returnNow)
            {
                return container;
            }
            AddIf( null != this._creator ? (Commvault.Powershell.Runtime.Json.JsonNode) this._creator.ToJson(null,serializationMode) : null, "creator" ,container.Add );
            AddIf( null != this._additionalQueryDetails ? (Commvault.Powershell.Runtime.Json.JsonNode) this._additionalQueryDetails.ToJson(null,serializationMode) : null, "additionalQueryDetails" ,container.Add );
            AddIf( null != this._queryEntity ? (Commvault.Powershell.Runtime.Json.JsonNode) this._queryEntity.ToJson(null,serializationMode) : null, "queryEntity" ,container.Add );
            AddIf( null != this._securityAssociations ? (Commvault.Powershell.Runtime.Json.JsonNode) this._securityAssociations.ToJson(null,serializationMode) : null, "securityAssociations" ,container.Add );
            AddIf( null != this._isQueryModifyEnabled ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._isQueryModifyEnabled) : null, "isQueryModifyEnabled" ,container.Add );
            AddIf( null != this._visibility ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._visibility) : null, "visibility" ,container.Add );
            AddIf( null != (((object)this._sqlQuery)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._sqlQuery.ToString()) : null, "sqlQuery" ,container.Add );
            AddIf( null != this._doesQuerySupportOutputFilter ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._doesQuerySupportOutputFilter) : null, "doesQuerySupportOutputFilter" ,container.Add );
            AddIf( null != this._frequency ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._frequency) : null, "frequency" ,container.Add );
            AddIf( null != this._isOverwriteAssociationAtAlertAllowed ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._isOverwriteAssociationAtAlertAllowed) : null, "isOverwriteAssociationAtAlertAllowed" ,container.Add );
            AddIf( null != this._isSystemCreated ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._isSystemCreated) : null, "isSystemCreated" ,container.Add );
            AddIf( null != this._isPrimaryKeyPresent ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._isPrimaryKeyPresent) : null, "isPrimaryKeyPresent" ,container.Add );
            AddIf( null != this._isDisabled ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._isDisabled) : null, "isDisabled" ,container.Add );
            AddIf( null != (((object)this._queryDescription)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._queryDescription.ToString()) : null, "queryDescription" ,container.Add );
            AddIf( null != (((object)this._queryCriteriaName)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._queryCriteriaName.ToString()) : null, "queryCriteriaName" ,container.Add );
            AddIf( null != this._customAlertType ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._customAlertType) : null, "customAlertType" ,container.Add );
            if (null != this._queryOutputColumns)
            {
                var __w = new Commvault.Powershell.Runtime.Json.XNodeArray();
                foreach( var __x in this._queryOutputColumns )
                {
                    AddIf(__x?.ToJson(null, serializationMode) ,__w.Add);
                }
                container.Add("queryOutputColumns",__w);
            }
            AfterToJson(ref container);
            return container;
        }
    }
}