generated/api/Models/MigrationGroupDetails.json.cs

// Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.4, generator: @autorest/powershell@3.0.415)
// 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>MigrationGroupDetailsResp</summary>
    public partial class MigrationGroupDetails
    {

        /// <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 erialization 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 <see "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 <see "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 <see cref="Commvault.Powershell.Runtime.Json.JsonNode"/> into an instance of Commvault.Powershell.Models.IMigrationGroupDetails.
        /// </summary>
        /// <param name="node">a <see cref="Commvault.Powershell.Runtime.Json.JsonNode" /> to deserialize from.</param>
        /// <returns>an instance of Commvault.Powershell.Models.IMigrationGroupDetails.</returns>
        public static Commvault.Powershell.Models.IMigrationGroupDetails FromJson(Commvault.Powershell.Runtime.Json.JsonNode node)
        {
            return node is Commvault.Powershell.Runtime.Json.JsonObject json ? new MigrationGroupDetails(json) : null;
        }

        /// <summary>
        /// Deserializes a Commvault.Powershell.Runtime.Json.JsonObject into a new instance of <see cref="MigrationGroupDetails" />.
        /// </summary>
        /// <param name="json">A Commvault.Powershell.Runtime.Json.JsonObject instance to deserialize from.</param>
        internal MigrationGroupDetails(Commvault.Powershell.Runtime.Json.JsonObject json)
        {
            bool returnNow = false;
            BeforeFromJson(json, ref returnNow);
            if (returnNow)
            {
                return;
            }
            {_sourceClient = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("sourceClient"), out var __jsonSourceClient) ? Commvault.Powershell.Models.IdName.FromJson(__jsonSourceClient) : SourceClient;}
            {_destinationClient = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("destinationClient"), out var __jsonDestinationClient) ? Commvault.Powershell.Models.IdName.FromJson(__jsonDestinationClient) : DestinationClient;}
            {_credentials = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("credentials"), out var __jsonCredentials) ? Commvault.Powershell.Models.Credentials.FromJson(__jsonCredentials) : Credentials;}
            {_updateFrequency = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("updateFrequency"), out var __jsonUpdateFrequency) ? Commvault.Powershell.Models.PlanPattern.FromJson(__jsonUpdateFrequency) : UpdateFrequency;}
            {_sourceBackupset = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("sourceBackupset"), out var __jsonSourceBackupset) ? Commvault.Powershell.Models.IdName.FromJson(__jsonSourceBackupset) : SourceBackupset;}
            {_destinationBackupset = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("destinationBackupset"), out var __jsonDestinationBackupset) ? Commvault.Powershell.Models.IdName.FromJson(__jsonDestinationBackupset) : DestinationBackupset;}
            {_sourceInstance = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("sourceInstance"), out var __jsonSourceInstance) ? Commvault.Powershell.Models.IdName.FromJson(__jsonSourceInstance) : SourceInstance;}
            {_destinationInstance = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("destinationInstance"), out var __jsonDestinationInstance) ? Commvault.Powershell.Models.IdName.FromJson(__jsonDestinationInstance) : DestinationInstance;}
            {_sourceSubclient = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("sourceSubclient"), out var __jsonSourceSubclient) ? Commvault.Powershell.Models.IdName.FromJson(__jsonSourceSubclient) : SourceSubclient;}
            {_destinationSubclient = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("destinationSubclient"), out var __jsonDestinationSubclient) ? Commvault.Powershell.Models.IdName.FromJson(__jsonDestinationSubclient) : DestinationSubclient;}
            {_sourceApplication = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("sourceApplication"), out var __jsonSourceApplication) ? Commvault.Powershell.Models.IdName.FromJson(__jsonSourceApplication) : SourceApplication;}
            {_destinationApplication = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("destinationApplication"), out var __jsonDestinationApplication) ? Commvault.Powershell.Models.IdName.FromJson(__jsonDestinationApplication) : DestinationApplication;}
            {_backupSchedulePolicy = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("backupSchedulePolicy"), out var __jsonBackupSchedulePolicy) ? Commvault.Powershell.Models.IdName.FromJson(__jsonBackupSchedulePolicy) : BackupSchedulePolicy;}
            {_backupSchedule = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("backupSchedule"), out var __jsonBackupSchedule) ? Commvault.Powershell.Models.IdName.FromJson(__jsonBackupSchedule) : BackupSchedule;}
            {_region = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("region"), out var __jsonRegion) ? Commvault.Powershell.Models.IdName.FromJson(__jsonRegion) : Region;}
            {_sourceAccessNode = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("sourceAccessNode"), out var __jsonSourceAccessNode) ? If( __jsonSourceAccessNode as Commvault.Powershell.Runtime.Json.JsonArray, out var __v) ? new global::System.Func<Commvault.Powershell.Models.IAccessNodes[]>(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__v, (__u)=>(Commvault.Powershell.Models.IAccessNodes) (Commvault.Powershell.Models.AccessNodes.FromJson(__u) )) ))() : null : SourceAccessNode;}
            {_destinationAccessNode = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("destinationAccessNode"), out var __jsonDestinationAccessNode) ? If( __jsonDestinationAccessNode as Commvault.Powershell.Runtime.Json.JsonArray, out var __q) ? new global::System.Func<Commvault.Powershell.Models.IAccessNodes[]>(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__q, (__p)=>(Commvault.Powershell.Models.IAccessNodes) (Commvault.Powershell.Models.AccessNodes.FromJson(__p) )) ))() : null : DestinationAccessNode;}
            {_migrationGroupName = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("migrationGroupName"), out var __jsonMigrationGroupName) ? (string)__jsonMigrationGroupName : (string)MigrationGroupName;}
            {_migrationMonitors = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("migrationMonitors"), out var __jsonMigrationMonitors) ? If( __jsonMigrationMonitors as Commvault.Powershell.Runtime.Json.JsonArray, out var __l) ? new global::System.Func<Commvault.Powershell.Models.IMigrationMonitor[]>(()=> global::System.Linq.Enumerable.ToArray(global::System.Linq.Enumerable.Select(__l, (__k)=>(Commvault.Powershell.Models.IMigrationMonitor) (Commvault.Powershell.Models.MigrationMonitor.FromJson(__k) )) ))() : null : MigrationMonitors;}
            {_migrationGroupState = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("migrationGroupState"), out var __jsonMigrationGroupState) ? (bool?)__jsonMigrationGroupState : MigrationGroupState;}
            {_migrationSize = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("migrationSize"), out var __jsonMigrationSize) ? (long?)__jsonMigrationSize : MigrationSize;}
            {_numOfFiles = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("numOfFiles"), out var __jsonNumOfFiles) ? (long?)__jsonNumOfFiles : NumOfFiles;}
            {_failures = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("failures"), out var __jsonFailures) ? (string)__jsonFailures : (string)Failures;}
            {_backupJobId = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("backupJobId"), out var __jsonBackupJobId) ? (long?)__jsonBackupJobId : BackupJobId;}
            {_restoreJobId = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("restoreJobId"), out var __jsonRestoreJobId) ? (long?)__jsonRestoreJobId : RestoreJobId;}
            {_migrationStatus = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("migrationStatus"), out var __jsonMigrationStatus) ? (string)__jsonMigrationStatus : (string)MigrationStatus;}
            {_lastSyncTime = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("lastSyncTime"), out var __jsonLastSyncTime) ? (long?)__jsonLastSyncTime : LastSyncTime;}
            {_failureReason = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("failureReason"), out var __jsonFailureReason) ? (string)__jsonFailureReason : (string)FailureReason;}
            AfterFromJson(json);
        }

        /// <summary>
        /// Serializes this instance of <see cref="MigrationGroupDetails" /> 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="MigrationGroupDetails" /> 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._sourceClient ? (Commvault.Powershell.Runtime.Json.JsonNode) this._sourceClient.ToJson(null,serializationMode) : null, "sourceClient" ,container.Add );
            AddIf( null != this._destinationClient ? (Commvault.Powershell.Runtime.Json.JsonNode) this._destinationClient.ToJson(null,serializationMode) : null, "destinationClient" ,container.Add );
            AddIf( null != this._credentials ? (Commvault.Powershell.Runtime.Json.JsonNode) this._credentials.ToJson(null,serializationMode) : null, "credentials" ,container.Add );
            AddIf( null != this._updateFrequency ? (Commvault.Powershell.Runtime.Json.JsonNode) this._updateFrequency.ToJson(null,serializationMode) : null, "updateFrequency" ,container.Add );
            AddIf( null != this._sourceBackupset ? (Commvault.Powershell.Runtime.Json.JsonNode) this._sourceBackupset.ToJson(null,serializationMode) : null, "sourceBackupset" ,container.Add );
            AddIf( null != this._destinationBackupset ? (Commvault.Powershell.Runtime.Json.JsonNode) this._destinationBackupset.ToJson(null,serializationMode) : null, "destinationBackupset" ,container.Add );
            AddIf( null != this._sourceInstance ? (Commvault.Powershell.Runtime.Json.JsonNode) this._sourceInstance.ToJson(null,serializationMode) : null, "sourceInstance" ,container.Add );
            AddIf( null != this._destinationInstance ? (Commvault.Powershell.Runtime.Json.JsonNode) this._destinationInstance.ToJson(null,serializationMode) : null, "destinationInstance" ,container.Add );
            AddIf( null != this._sourceSubclient ? (Commvault.Powershell.Runtime.Json.JsonNode) this._sourceSubclient.ToJson(null,serializationMode) : null, "sourceSubclient" ,container.Add );
            AddIf( null != this._destinationSubclient ? (Commvault.Powershell.Runtime.Json.JsonNode) this._destinationSubclient.ToJson(null,serializationMode) : null, "destinationSubclient" ,container.Add );
            AddIf( null != this._sourceApplication ? (Commvault.Powershell.Runtime.Json.JsonNode) this._sourceApplication.ToJson(null,serializationMode) : null, "sourceApplication" ,container.Add );
            AddIf( null != this._destinationApplication ? (Commvault.Powershell.Runtime.Json.JsonNode) this._destinationApplication.ToJson(null,serializationMode) : null, "destinationApplication" ,container.Add );
            AddIf( null != this._backupSchedulePolicy ? (Commvault.Powershell.Runtime.Json.JsonNode) this._backupSchedulePolicy.ToJson(null,serializationMode) : null, "backupSchedulePolicy" ,container.Add );
            AddIf( null != this._backupSchedule ? (Commvault.Powershell.Runtime.Json.JsonNode) this._backupSchedule.ToJson(null,serializationMode) : null, "backupSchedule" ,container.Add );
            AddIf( null != this._region ? (Commvault.Powershell.Runtime.Json.JsonNode) this._region.ToJson(null,serializationMode) : null, "region" ,container.Add );
            if (null != this._sourceAccessNode)
            {
                var __w = new Commvault.Powershell.Runtime.Json.XNodeArray();
                foreach( var __x in this._sourceAccessNode )
                {
                    AddIf(__x?.ToJson(null, serializationMode) ,__w.Add);
                }
                container.Add("sourceAccessNode",__w);
            }
            if (null != this._destinationAccessNode)
            {
                var __r = new Commvault.Powershell.Runtime.Json.XNodeArray();
                foreach( var __s in this._destinationAccessNode )
                {
                    AddIf(__s?.ToJson(null, serializationMode) ,__r.Add);
                }
                container.Add("destinationAccessNode",__r);
            }
            AddIf( null != (((object)this._migrationGroupName)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._migrationGroupName.ToString()) : null, "migrationGroupName" ,container.Add );
            if (null != this._migrationMonitors)
            {
                var __m = new Commvault.Powershell.Runtime.Json.XNodeArray();
                foreach( var __n in this._migrationMonitors )
                {
                    AddIf(__n?.ToJson(null, serializationMode) ,__m.Add);
                }
                container.Add("migrationMonitors",__m);
            }
            AddIf( null != this._migrationGroupState ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._migrationGroupState) : null, "migrationGroupState" ,container.Add );
            AddIf( null != this._migrationSize ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._migrationSize) : null, "migrationSize" ,container.Add );
            AddIf( null != this._numOfFiles ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._numOfFiles) : null, "numOfFiles" ,container.Add );
            AddIf( null != (((object)this._failures)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._failures.ToString()) : null, "failures" ,container.Add );
            AddIf( null != this._backupJobId ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._backupJobId) : null, "backupJobId" ,container.Add );
            AddIf( null != this._restoreJobId ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._restoreJobId) : null, "restoreJobId" ,container.Add );
            AddIf( null != (((object)this._migrationStatus)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._migrationStatus.ToString()) : null, "migrationStatus" ,container.Add );
            AddIf( null != this._lastSyncTime ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._lastSyncTime) : null, "lastSyncTime" ,container.Add );
            AddIf( null != (((object)this._failureReason)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._failureReason.ToString()) : null, "failureReason" ,container.Add );
            AfterToJson(ref container);
            return container;
        }
    }
}