generated/api/Models/CloudDestinationOptions.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>cloudDestinationOptions</summary>
    public partial class CloudDestinationOptions
    {

        /// <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="CloudDestinationOptions" />.
        /// </summary>
        /// <param name="json">A Commvault.Powershell.Runtime.Json.JsonObject instance to deserialize from.</param>
        internal CloudDestinationOptions(Commvault.Powershell.Runtime.Json.JsonObject json)
        {
            bool returnNow = false;
            BeforeFromJson(json, ref returnNow);
            if (returnNow)
            {
                return;
            }
            {_region = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("region"), out var __jsonRegion) ? Commvault.Powershell.Models.Region.FromJson(__jsonRegion) : _region;}
            {_machineType = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("machineType"), out var __jsonMachineType) ? Commvault.Powershell.Models.IdName.FromJson(__jsonMachineType) : _machineType;}
            {_encryptionKey = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonObject>("encryptionKey"), out var __jsonEncryptionKey) ? Commvault.Powershell.Models.IdName.FromJson(__jsonEncryptionKey) : _encryptionKey;}
            {_keyPair = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("keyPair"), out var __jsonKeyPair) ? (string)__jsonKeyPair : (string)_keyPair;}
            {_restoreAsManagedVM = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("restoreAsManagedVM"), out var __jsonRestoreAsManagedVM) ? (bool?)__jsonRestoreAsManagedVM : _restoreAsManagedVM;}
            {_soleTenancyNodes = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("soleTenancyNodes"), out var __jsonSoleTenancyNodes) ? If( __jsonSoleTenancyNodes as Commvault.Powershell.Runtime.Json.JsonArray, out var __v) ? new global::System.Func<System.Collections.Generic.List<Commvault.Powershell.Models.INameValue>>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(Commvault.Powershell.Models.INameValue) (Commvault.Powershell.Models.NameValue.FromJson(__u) )) ))() : null : _soleTenancyNodes;}
            {_tags = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("tags"), out var __jsonTags) ? If( __jsonTags as Commvault.Powershell.Runtime.Json.JsonArray, out var __q) ? new global::System.Func<System.Collections.Generic.List<Commvault.Powershell.Models.INameValue>>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__q, (__p)=>(Commvault.Powershell.Models.INameValue) (Commvault.Powershell.Models.NameValue.FromJson(__p) )) ))() : null : _tags;}
            {_availabilityZone = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("availabilityZone"), out var __jsonAvailabilityZone) ? (string)__jsonAvailabilityZone : (string)_availabilityZone;}
            {_vMInstanceType = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("vmInstanceType"), out var __jsonVMInstanceType) ? (string)__jsonVMInstanceType : (string)_vMInstanceType;}
            {_volumeType = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("volumeType"), out var __jsonVolumeType) ? (string)__jsonVolumeType : (string)_volumeType;}
            {_testDiskType = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("testDiskType"), out var __jsonTestDiskType) ? (string)__jsonTestDiskType : (string)_testDiskType;}
            {_instanceTypes = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("instanceTypes"), out var __jsonInstanceTypes) ? If( __jsonInstanceTypes as Commvault.Powershell.Runtime.Json.JsonArray, out var __l) ? new global::System.Func<System.Collections.Generic.List<string>>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__l, (__k)=>(string) (__k is Commvault.Powershell.Runtime.Json.JsonString __j ? (string)(__j.ToString()) : null)) ))() : null : _instanceTypes;}
            {_publicIP = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonBoolean>("publicIP"), out var __jsonPublicIP) ? (bool?)__jsonPublicIP : _publicIP;}
            AfterFromJson(json);
        }

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

        /// <summary>
        /// Serializes this instance of <see cref="CloudDestinationOptions" /> 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="CloudDestinationOptions" /> 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._region ? (Commvault.Powershell.Runtime.Json.JsonNode) this._region.ToJson(null,serializationMode) : null, "region" ,container.Add );
            AddIf( null != this._machineType ? (Commvault.Powershell.Runtime.Json.JsonNode) this._machineType.ToJson(null,serializationMode) : null, "machineType" ,container.Add );
            AddIf( null != this._encryptionKey ? (Commvault.Powershell.Runtime.Json.JsonNode) this._encryptionKey.ToJson(null,serializationMode) : null, "encryptionKey" ,container.Add );
            AddIf( null != (((object)this._keyPair)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._keyPair.ToString()) : null, "keyPair" ,container.Add );
            AddIf( null != this._restoreAsManagedVM ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._restoreAsManagedVM) : null, "restoreAsManagedVM" ,container.Add );
            if (null != this._soleTenancyNodes)
            {
                var __w = new Commvault.Powershell.Runtime.Json.XNodeArray();
                foreach( var __x in this._soleTenancyNodes )
                {
                    AddIf(__x?.ToJson(null, serializationMode) ,__w.Add);
                }
                container.Add("soleTenancyNodes",__w);
            }
            if (null != this._tags)
            {
                var __r = new Commvault.Powershell.Runtime.Json.XNodeArray();
                foreach( var __s in this._tags )
                {
                    AddIf(__s?.ToJson(null, serializationMode) ,__r.Add);
                }
                container.Add("tags",__r);
            }
            AddIf( null != (((object)this._availabilityZone)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._availabilityZone.ToString()) : null, "availabilityZone" ,container.Add );
            AddIf( null != (((object)this._vMInstanceType)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._vMInstanceType.ToString()) : null, "vmInstanceType" ,container.Add );
            AddIf( null != (((object)this._volumeType)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._volumeType.ToString()) : null, "volumeType" ,container.Add );
            AddIf( null != (((object)this._testDiskType)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._testDiskType.ToString()) : null, "testDiskType" ,container.Add );
            if (null != this._instanceTypes)
            {
                var __m = new Commvault.Powershell.Runtime.Json.XNodeArray();
                foreach( var __n in this._instanceTypes )
                {
                    AddIf(null != (((object)__n)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(__n.ToString()) : null ,__m.Add);
                }
                container.Add("instanceTypes",__m);
            }
            AddIf( null != this._publicIP ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonBoolean((bool)this._publicIP) : null, "publicIP" ,container.Add );
            AfterToJson(ref container);
            return container;
        }
    }
}