| | | 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; |
| | | 9 | | using System.Collections.Generic; |
| | | 10 | | using System.Text.Json; |
| | | 11 | | using Azure.Core; |
| | | 12 | | |
| | | 13 | | namespace Azure.ResourceManager.Compute.Models |
| | | 14 | | { |
| | | 15 | | public partial class GalleryImage : IUtf8JsonSerializable |
| | | 16 | | { |
| | | 17 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | | 18 | | { |
| | 24 | 19 | | writer.WriteStartObject(); |
| | 24 | 20 | | if (Id != null) |
| | | 21 | | { |
| | 0 | 22 | | writer.WritePropertyName("id"); |
| | 0 | 23 | | writer.WriteStringValue(Id); |
| | | 24 | | } |
| | 24 | 25 | | if (Name != null) |
| | | 26 | | { |
| | 0 | 27 | | writer.WritePropertyName("name"); |
| | 0 | 28 | | writer.WriteStringValue(Name); |
| | | 29 | | } |
| | 24 | 30 | | if (Type != null) |
| | | 31 | | { |
| | 0 | 32 | | writer.WritePropertyName("type"); |
| | 0 | 33 | | writer.WriteStringValue(Type); |
| | | 34 | | } |
| | 24 | 35 | | writer.WritePropertyName("location"); |
| | 24 | 36 | | writer.WriteStringValue(Location); |
| | 24 | 37 | | if (Tags != null) |
| | | 38 | | { |
| | 0 | 39 | | writer.WritePropertyName("tags"); |
| | 0 | 40 | | writer.WriteStartObject(); |
| | 0 | 41 | | foreach (var item in Tags) |
| | | 42 | | { |
| | 0 | 43 | | writer.WritePropertyName(item.Key); |
| | 0 | 44 | | writer.WriteStringValue(item.Value); |
| | | 45 | | } |
| | 0 | 46 | | writer.WriteEndObject(); |
| | | 47 | | } |
| | 24 | 48 | | writer.WritePropertyName("properties"); |
| | 24 | 49 | | writer.WriteStartObject(); |
| | 24 | 50 | | if (Description != null) |
| | | 51 | | { |
| | 24 | 52 | | writer.WritePropertyName("description"); |
| | 24 | 53 | | writer.WriteStringValue(Description); |
| | | 54 | | } |
| | 24 | 55 | | if (Eula != null) |
| | | 56 | | { |
| | 0 | 57 | | writer.WritePropertyName("eula"); |
| | 0 | 58 | | writer.WriteStringValue(Eula); |
| | | 59 | | } |
| | 24 | 60 | | if (PrivacyStatementUri != null) |
| | | 61 | | { |
| | 0 | 62 | | writer.WritePropertyName("privacyStatementUri"); |
| | 0 | 63 | | writer.WriteStringValue(PrivacyStatementUri); |
| | | 64 | | } |
| | 24 | 65 | | if (ReleaseNoteUri != null) |
| | | 66 | | { |
| | 0 | 67 | | writer.WritePropertyName("releaseNoteUri"); |
| | 0 | 68 | | writer.WriteStringValue(ReleaseNoteUri); |
| | | 69 | | } |
| | 24 | 70 | | if (OsType != null) |
| | | 71 | | { |
| | 24 | 72 | | writer.WritePropertyName("osType"); |
| | 24 | 73 | | writer.WriteStringValue(OsType.Value.ToSerialString()); |
| | | 74 | | } |
| | 24 | 75 | | if (OsState != null) |
| | | 76 | | { |
| | 24 | 77 | | writer.WritePropertyName("osState"); |
| | 24 | 78 | | writer.WriteStringValue(OsState.Value.ToSerialString()); |
| | | 79 | | } |
| | 24 | 80 | | if (HyperVGeneration != null) |
| | | 81 | | { |
| | 0 | 82 | | writer.WritePropertyName("hyperVGeneration"); |
| | 0 | 83 | | writer.WriteStringValue(HyperVGeneration.Value.ToString()); |
| | | 84 | | } |
| | 24 | 85 | | if (EndOfLifeDate != null) |
| | | 86 | | { |
| | 0 | 87 | | writer.WritePropertyName("endOfLifeDate"); |
| | 0 | 88 | | writer.WriteStringValue(EndOfLifeDate.Value, "O"); |
| | | 89 | | } |
| | 24 | 90 | | if (Identifier != null) |
| | | 91 | | { |
| | 24 | 92 | | writer.WritePropertyName("identifier"); |
| | 24 | 93 | | writer.WriteObjectValue(Identifier); |
| | | 94 | | } |
| | 24 | 95 | | if (Recommended != null) |
| | | 96 | | { |
| | 0 | 97 | | writer.WritePropertyName("recommended"); |
| | 0 | 98 | | writer.WriteObjectValue(Recommended); |
| | | 99 | | } |
| | 24 | 100 | | if (Disallowed != null) |
| | | 101 | | { |
| | 0 | 102 | | writer.WritePropertyName("disallowed"); |
| | 0 | 103 | | writer.WriteObjectValue(Disallowed); |
| | | 104 | | } |
| | 24 | 105 | | if (PurchasePlan != null) |
| | | 106 | | { |
| | 0 | 107 | | writer.WritePropertyName("purchasePlan"); |
| | 0 | 108 | | writer.WriteObjectValue(PurchasePlan); |
| | | 109 | | } |
| | 24 | 110 | | if (ProvisioningState != null) |
| | | 111 | | { |
| | 0 | 112 | | writer.WritePropertyName("provisioningState"); |
| | 0 | 113 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | | 114 | | } |
| | 24 | 115 | | writer.WriteEndObject(); |
| | 24 | 116 | | writer.WriteEndObject(); |
| | 24 | 117 | | } |
| | | 118 | | |
| | | 119 | | internal static GalleryImage DeserializeGalleryImage(JsonElement element) |
| | | 120 | | { |
| | 24 | 121 | | string id = default; |
| | 24 | 122 | | string name = default; |
| | 24 | 123 | | string type = default; |
| | 24 | 124 | | string location = default; |
| | 24 | 125 | | IDictionary<string, string> tags = default; |
| | 24 | 126 | | string description = default; |
| | 24 | 127 | | string eula = default; |
| | 24 | 128 | | string privacyStatementUri = default; |
| | 24 | 129 | | string releaseNoteUri = default; |
| | 24 | 130 | | OperatingSystemTypes? osType = default; |
| | 24 | 131 | | OperatingSystemStateTypes? osState = default; |
| | 24 | 132 | | HyperVGeneration? hyperVGeneration = default; |
| | 24 | 133 | | DateTimeOffset? endOfLifeDate = default; |
| | 24 | 134 | | GalleryImageIdentifier identifier = default; |
| | 24 | 135 | | RecommendedMachineConfiguration recommended = default; |
| | 24 | 136 | | Disallowed disallowed = default; |
| | 24 | 137 | | ImagePurchasePlan purchasePlan = default; |
| | 24 | 138 | | GalleryImagePropertiesProvisioningState? provisioningState = default; |
| | 288 | 139 | | foreach (var property in element.EnumerateObject()) |
| | | 140 | | { |
| | 120 | 141 | | if (property.NameEquals("id")) |
| | | 142 | | { |
| | 24 | 143 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 144 | | { |
| | | 145 | | continue; |
| | | 146 | | } |
| | 24 | 147 | | id = property.Value.GetString(); |
| | 24 | 148 | | continue; |
| | | 149 | | } |
| | 96 | 150 | | if (property.NameEquals("name")) |
| | | 151 | | { |
| | 24 | 152 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 153 | | { |
| | | 154 | | continue; |
| | | 155 | | } |
| | 24 | 156 | | name = property.Value.GetString(); |
| | 24 | 157 | | continue; |
| | | 158 | | } |
| | 72 | 159 | | if (property.NameEquals("type")) |
| | | 160 | | { |
| | 24 | 161 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 162 | | { |
| | | 163 | | continue; |
| | | 164 | | } |
| | 24 | 165 | | type = property.Value.GetString(); |
| | 24 | 166 | | continue; |
| | | 167 | | } |
| | 48 | 168 | | if (property.NameEquals("location")) |
| | | 169 | | { |
| | 24 | 170 | | location = property.Value.GetString(); |
| | 24 | 171 | | continue; |
| | | 172 | | } |
| | 24 | 173 | | if (property.NameEquals("tags")) |
| | | 174 | | { |
| | 0 | 175 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | | 176 | | { |
| | | 177 | | continue; |
| | | 178 | | } |
| | 0 | 179 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| | 0 | 180 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | | 181 | | { |
| | 0 | 182 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 183 | | { |
| | 0 | 184 | | dictionary.Add(property0.Name, null); |
| | | 185 | | } |
| | | 186 | | else |
| | | 187 | | { |
| | 0 | 188 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | | 189 | | } |
| | | 190 | | } |
| | 0 | 191 | | tags = dictionary; |
| | 0 | 192 | | continue; |
| | | 193 | | } |
| | 24 | 194 | | if (property.NameEquals("properties")) |
| | | 195 | | { |
| | 336 | 196 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | | 197 | | { |
| | 144 | 198 | | if (property0.NameEquals("description")) |
| | | 199 | | { |
| | 24 | 200 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 201 | | { |
| | | 202 | | continue; |
| | | 203 | | } |
| | 24 | 204 | | description = property0.Value.GetString(); |
| | 24 | 205 | | continue; |
| | | 206 | | } |
| | 120 | 207 | | if (property0.NameEquals("eula")) |
| | | 208 | | { |
| | 0 | 209 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 210 | | { |
| | | 211 | | continue; |
| | | 212 | | } |
| | 0 | 213 | | eula = property0.Value.GetString(); |
| | 0 | 214 | | continue; |
| | | 215 | | } |
| | 120 | 216 | | if (property0.NameEquals("privacyStatementUri")) |
| | | 217 | | { |
| | 0 | 218 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 219 | | { |
| | | 220 | | continue; |
| | | 221 | | } |
| | 0 | 222 | | privacyStatementUri = property0.Value.GetString(); |
| | 0 | 223 | | continue; |
| | | 224 | | } |
| | 120 | 225 | | if (property0.NameEquals("releaseNoteUri")) |
| | | 226 | | { |
| | 0 | 227 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 228 | | { |
| | | 229 | | continue; |
| | | 230 | | } |
| | 0 | 231 | | releaseNoteUri = property0.Value.GetString(); |
| | 0 | 232 | | continue; |
| | | 233 | | } |
| | 120 | 234 | | if (property0.NameEquals("osType")) |
| | | 235 | | { |
| | 24 | 236 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 237 | | { |
| | | 238 | | continue; |
| | | 239 | | } |
| | 24 | 240 | | osType = property0.Value.GetString().ToOperatingSystemTypes(); |
| | 24 | 241 | | continue; |
| | | 242 | | } |
| | 96 | 243 | | if (property0.NameEquals("osState")) |
| | | 244 | | { |
| | 24 | 245 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 246 | | { |
| | | 247 | | continue; |
| | | 248 | | } |
| | 24 | 249 | | osState = property0.Value.GetString().ToOperatingSystemStateTypes(); |
| | 24 | 250 | | continue; |
| | | 251 | | } |
| | 72 | 252 | | if (property0.NameEquals("hyperVGeneration")) |
| | | 253 | | { |
| | 24 | 254 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 255 | | { |
| | | 256 | | continue; |
| | | 257 | | } |
| | 24 | 258 | | hyperVGeneration = new HyperVGeneration(property0.Value.GetString()); |
| | 24 | 259 | | continue; |
| | | 260 | | } |
| | 48 | 261 | | if (property0.NameEquals("endOfLifeDate")) |
| | | 262 | | { |
| | 0 | 263 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 264 | | { |
| | | 265 | | continue; |
| | | 266 | | } |
| | 0 | 267 | | endOfLifeDate = property0.Value.GetDateTimeOffset("O"); |
| | 0 | 268 | | continue; |
| | | 269 | | } |
| | 48 | 270 | | if (property0.NameEquals("identifier")) |
| | | 271 | | { |
| | 24 | 272 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 273 | | { |
| | | 274 | | continue; |
| | | 275 | | } |
| | 24 | 276 | | identifier = GalleryImageIdentifier.DeserializeGalleryImageIdentifier(property0.Value); |
| | 24 | 277 | | continue; |
| | | 278 | | } |
| | 24 | 279 | | if (property0.NameEquals("recommended")) |
| | | 280 | | { |
| | 0 | 281 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 282 | | { |
| | | 283 | | continue; |
| | | 284 | | } |
| | 0 | 285 | | recommended = RecommendedMachineConfiguration.DeserializeRecommendedMachineConfiguration(pro |
| | 0 | 286 | | continue; |
| | | 287 | | } |
| | 24 | 288 | | if (property0.NameEquals("disallowed")) |
| | | 289 | | { |
| | 0 | 290 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 291 | | { |
| | | 292 | | continue; |
| | | 293 | | } |
| | 0 | 294 | | disallowed = Disallowed.DeserializeDisallowed(property0.Value); |
| | 0 | 295 | | continue; |
| | | 296 | | } |
| | 24 | 297 | | if (property0.NameEquals("purchasePlan")) |
| | | 298 | | { |
| | 0 | 299 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 300 | | { |
| | | 301 | | continue; |
| | | 302 | | } |
| | 0 | 303 | | purchasePlan = ImagePurchasePlan.DeserializeImagePurchasePlan(property0.Value); |
| | 0 | 304 | | continue; |
| | | 305 | | } |
| | 24 | 306 | | if (property0.NameEquals("provisioningState")) |
| | | 307 | | { |
| | 24 | 308 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | | 309 | | { |
| | | 310 | | continue; |
| | | 311 | | } |
| | 24 | 312 | | provisioningState = new GalleryImagePropertiesProvisioningState(property0.Value.GetString()) |
| | | 313 | | continue; |
| | | 314 | | } |
| | | 315 | | } |
| | | 316 | | continue; |
| | | 317 | | } |
| | | 318 | | } |
| | 24 | 319 | | return new GalleryImage(id, name, type, location, tags, description, eula, privacyStatementUri, releaseNoteU |
| | | 320 | | } |
| | | 321 | | } |
| | | 322 | | } |