| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Compute.Models |
| | 13 | | { |
| | 14 | | public partial class VirtualMachineCaptureResult : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Schema != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("$schema"); |
| 0 | 22 | | writer.WriteStringValue(Schema); |
| | 23 | | } |
| 0 | 24 | | if (ContentVersion != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("contentVersion"); |
| 0 | 27 | | writer.WriteStringValue(ContentVersion); |
| | 28 | | } |
| 0 | 29 | | if (Parameters != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("parameters"); |
| 0 | 32 | | writer.WriteObjectValue(Parameters); |
| | 33 | | } |
| 0 | 34 | | if (Resources != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("resources"); |
| 0 | 37 | | writer.WriteStartArray(); |
| 0 | 38 | | foreach (var item in Resources) |
| | 39 | | { |
| 0 | 40 | | writer.WriteObjectValue(item); |
| | 41 | | } |
| 0 | 42 | | writer.WriteEndArray(); |
| | 43 | | } |
| 0 | 44 | | if (Id != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("id"); |
| 0 | 47 | | writer.WriteStringValue(Id); |
| | 48 | | } |
| 0 | 49 | | writer.WriteEndObject(); |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | internal static VirtualMachineCaptureResult DeserializeVirtualMachineCaptureResult(JsonElement element) |
| | 53 | | { |
| 0 | 54 | | string schema = default; |
| 0 | 55 | | string contentVersion = default; |
| 0 | 56 | | object parameters = default; |
| 0 | 57 | | IList<object> resources = default; |
| 0 | 58 | | string id = default; |
| 0 | 59 | | foreach (var property in element.EnumerateObject()) |
| | 60 | | { |
| 0 | 61 | | if (property.NameEquals("$schema")) |
| | 62 | | { |
| 0 | 63 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 64 | | { |
| | 65 | | continue; |
| | 66 | | } |
| 0 | 67 | | schema = property.Value.GetString(); |
| 0 | 68 | | continue; |
| | 69 | | } |
| 0 | 70 | | if (property.NameEquals("contentVersion")) |
| | 71 | | { |
| 0 | 72 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 73 | | { |
| | 74 | | continue; |
| | 75 | | } |
| 0 | 76 | | contentVersion = property.Value.GetString(); |
| 0 | 77 | | continue; |
| | 78 | | } |
| 0 | 79 | | if (property.NameEquals("parameters")) |
| | 80 | | { |
| 0 | 81 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 82 | | { |
| | 83 | | continue; |
| | 84 | | } |
| 0 | 85 | | parameters = property.Value.GetObject(); |
| 0 | 86 | | continue; |
| | 87 | | } |
| 0 | 88 | | if (property.NameEquals("resources")) |
| | 89 | | { |
| 0 | 90 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 91 | | { |
| | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | List<object> array = new List<object>(); |
| 0 | 95 | | foreach (var item in property.Value.EnumerateArray()) |
| | 96 | | { |
| 0 | 97 | | if (item.ValueKind == JsonValueKind.Null) |
| | 98 | | { |
| 0 | 99 | | array.Add(null); |
| | 100 | | } |
| | 101 | | else |
| | 102 | | { |
| 0 | 103 | | array.Add(item.GetObject()); |
| | 104 | | } |
| | 105 | | } |
| 0 | 106 | | resources = array; |
| 0 | 107 | | continue; |
| | 108 | | } |
| 0 | 109 | | if (property.NameEquals("id")) |
| | 110 | | { |
| 0 | 111 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 112 | | { |
| | 113 | | continue; |
| | 114 | | } |
| 0 | 115 | | id = property.Value.GetString(); |
| | 116 | | continue; |
| | 117 | | } |
| | 118 | | } |
| 0 | 119 | | return new VirtualMachineCaptureResult(id, schema, contentVersion, parameters, resources); |
| | 120 | | } |
| | 121 | | } |
| | 122 | | } |