generated/api/Models/TapeMediaOperationsReq.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>Request body to perform tape media operations</summary> public partial class TapeMediaOperationsReq { /// <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 <see cref="Commvault.Powershell.Runtime.Json.JsonNode"/> into an instance of Commvault.Powershell.Models.ITapeMediaOperationsReq. /// </summary> /// <param name="node">a <see cref="Commvault.Powershell.Runtime.Json.JsonNode" /> to deserialize from.</param> /// <returns>an instance of Commvault.Powershell.Models.ITapeMediaOperationsReq.</returns> public static Commvault.Powershell.Models.ITapeMediaOperationsReq FromJson(Commvault.Powershell.Runtime.Json.JsonNode node) { return node is Commvault.Powershell.Runtime.Json.JsonObject json ? new TapeMediaOperationsReq(json) : null; } /// <summary> /// Deserializes a Commvault.Powershell.Runtime.Json.JsonObject into a new instance of <see cref="TapeMediaOperationsReq" />. /// </summary> /// <param name="json">A Commvault.Powershell.Runtime.Json.JsonObject instance to deserialize from.</param> internal TapeMediaOperationsReq(Commvault.Powershell.Runtime.Json.JsonObject json) { bool returnNow = false; BeforeFromJson(json, ref returnNow); if (returnNow) { return; } {_mediaTypeId = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("mediaTypeId"), out var __jsonMediaTypeId) ? (long?)__jsonMediaTypeId : _mediaTypeId;} {_spareGroupId = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("spareGroupId"), out var __jsonSpareGroupId) ? (long?)__jsonSpareGroupId : _spareGroupId;} {_destSpareGroupId = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonNumber>("destSpareGroupId"), out var __jsonDestSpareGroupId) ? (long?)__jsonDestSpareGroupId : _destSpareGroupId;} {_slotList = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("slotList"), out var __jsonSlotList) ? If( __jsonSlotList as Commvault.Powershell.Runtime.Json.JsonArray, out var __v) ? new global::System.Func<System.Collections.Generic.List<long>>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__v, (__u)=>(long) (__u is Commvault.Powershell.Runtime.Json.JsonNumber __t ? (long)__t : default(long))) ))() : null : _slotList;} {_operationType = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("operationType"), out var __jsonOperationType) ? (string)__jsonOperationType : (string)_operationType;} {_mediaList = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonArray>("mediaList"), out var __jsonMediaList) ? If( __jsonMediaList as Commvault.Powershell.Runtime.Json.JsonArray, out var __q) ? new global::System.Func<System.Collections.Generic.List<long>>(()=> global::System.Linq.Enumerable.ToList(global::System.Linq.Enumerable.Select(__q, (__p)=>(long) (__p is Commvault.Powershell.Runtime.Json.JsonNumber __o ? (long)__o : default(long))) ))() : null : _mediaList;} {_updateBarcodeOpType = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("UpdateBarcodeOpType"), out var __jsonUpdateBarcodeOpType) ? (string)__jsonUpdateBarcodeOpType : (string)_updateBarcodeOpType;} {_barcode = If( json?.PropertyT<Commvault.Powershell.Runtime.Json.JsonString>("barcode"), out var __jsonBarcode) ? (string)__jsonBarcode : (string)_barcode;} AfterFromJson(json); } /// <summary> /// Serializes this instance of <see cref="TapeMediaOperationsReq" /> 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="TapeMediaOperationsReq" /> 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._mediaTypeId ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._mediaTypeId) : null, "mediaTypeId" ,container.Add ); AddIf( null != this._spareGroupId ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._spareGroupId) : null, "spareGroupId" ,container.Add ); AddIf( null != this._destSpareGroupId ? (Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber((long)this._destSpareGroupId) : null, "destSpareGroupId" ,container.Add ); if (null != this._slotList) { var __w = new Commvault.Powershell.Runtime.Json.XNodeArray(); foreach( var __x in this._slotList ) { AddIf((Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber(__x) ,__w.Add); } container.Add("slotList",__w); } AddIf( null != (((object)this._operationType)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._operationType.ToString()) : null, "operationType" ,container.Add ); if (null != this._mediaList) { var __r = new Commvault.Powershell.Runtime.Json.XNodeArray(); foreach( var __s in this._mediaList ) { AddIf((Commvault.Powershell.Runtime.Json.JsonNode)new Commvault.Powershell.Runtime.Json.JsonNumber(__s) ,__r.Add); } container.Add("mediaList",__r); } AddIf( null != (((object)this._updateBarcodeOpType)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._updateBarcodeOpType.ToString()) : null, "UpdateBarcodeOpType" ,container.Add ); AddIf( null != (((object)this._barcode)?.ToString()) ? (Commvault.Powershell.Runtime.Json.JsonNode) new Commvault.Powershell.Runtime.Json.JsonString(this._barcode.ToString()) : null, "barcode" ,container.Add ); AfterToJson(ref container); return container; } } } |