| | 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.Network.Models |
| | 13 | | { |
| | 14 | | internal partial class Error |
| | 15 | | { |
| | 16 | | internal static Error DeserializeError(JsonElement element) |
| | 17 | | { |
| 0 | 18 | | string code = default; |
| 0 | 19 | | string message = default; |
| 0 | 20 | | string target = default; |
| 0 | 21 | | IReadOnlyList<ErrorDetails> details = default; |
| 0 | 22 | | string innerError = default; |
| 0 | 23 | | foreach (var property in element.EnumerateObject()) |
| | 24 | | { |
| 0 | 25 | | if (property.NameEquals("code")) |
| | 26 | | { |
| 0 | 27 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 28 | | { |
| | 29 | | continue; |
| | 30 | | } |
| 0 | 31 | | code = property.Value.GetString(); |
| 0 | 32 | | continue; |
| | 33 | | } |
| 0 | 34 | | if (property.NameEquals("message")) |
| | 35 | | { |
| 0 | 36 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 37 | | { |
| | 38 | | continue; |
| | 39 | | } |
| 0 | 40 | | message = property.Value.GetString(); |
| 0 | 41 | | continue; |
| | 42 | | } |
| 0 | 43 | | if (property.NameEquals("target")) |
| | 44 | | { |
| 0 | 45 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 46 | | { |
| | 47 | | continue; |
| | 48 | | } |
| 0 | 49 | | target = property.Value.GetString(); |
| 0 | 50 | | continue; |
| | 51 | | } |
| 0 | 52 | | if (property.NameEquals("details")) |
| | 53 | | { |
| 0 | 54 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 55 | | { |
| | 56 | | continue; |
| | 57 | | } |
| 0 | 58 | | List<ErrorDetails> array = new List<ErrorDetails>(); |
| 0 | 59 | | foreach (var item in property.Value.EnumerateArray()) |
| | 60 | | { |
| 0 | 61 | | if (item.ValueKind == JsonValueKind.Null) |
| | 62 | | { |
| 0 | 63 | | array.Add(null); |
| | 64 | | } |
| | 65 | | else |
| | 66 | | { |
| 0 | 67 | | array.Add(ErrorDetails.DeserializeErrorDetails(item)); |
| | 68 | | } |
| | 69 | | } |
| 0 | 70 | | details = array; |
| 0 | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | if (property.NameEquals("innerError")) |
| | 74 | | { |
| 0 | 75 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 76 | | { |
| | 77 | | continue; |
| | 78 | | } |
| 0 | 79 | | innerError = property.Value.GetString(); |
| | 80 | | continue; |
| | 81 | | } |
| | 82 | | } |
| 0 | 83 | | return new Error(code, message, target, details, innerError); |
| | 84 | | } |
| | 85 | | } |
| | 86 | | } |