| | 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.Resources.Models |
| | 13 | | { |
| | 14 | | public partial class ErrorResponse : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Code != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("code"); |
| 0 | 22 | | writer.WriteStringValue(Code); |
| | 23 | | } |
| 0 | 24 | | if (Message != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("message"); |
| 0 | 27 | | writer.WriteStringValue(Message); |
| | 28 | | } |
| 0 | 29 | | if (Target != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("target"); |
| 0 | 32 | | writer.WriteStringValue(Target); |
| | 33 | | } |
| 0 | 34 | | if (Details != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("details"); |
| 0 | 37 | | writer.WriteStartArray(); |
| 0 | 38 | | foreach (var item in Details) |
| | 39 | | { |
| 0 | 40 | | writer.WriteObjectValue(item); |
| | 41 | | } |
| 0 | 42 | | writer.WriteEndArray(); |
| | 43 | | } |
| 0 | 44 | | if (AdditionalInfo != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("additionalInfo"); |
| 0 | 47 | | writer.WriteStartArray(); |
| 0 | 48 | | foreach (var item in AdditionalInfo) |
| | 49 | | { |
| 0 | 50 | | writer.WriteObjectValue(item); |
| | 51 | | } |
| 0 | 52 | | writer.WriteEndArray(); |
| | 53 | | } |
| 0 | 54 | | writer.WriteEndObject(); |
| 0 | 55 | | } |
| | 56 | |
|
| | 57 | | internal static ErrorResponse DeserializeErrorResponse(JsonElement element) |
| | 58 | | { |
| 16 | 59 | | string code = default; |
| 16 | 60 | | string message = default; |
| 16 | 61 | | string target = default; |
| 16 | 62 | | IList<ErrorResponse> details = default; |
| 16 | 63 | | IList<ErrorAdditionalInfo> additionalInfo = default; |
| 96 | 64 | | foreach (var property in element.EnumerateObject()) |
| | 65 | | { |
| 32 | 66 | | if (property.NameEquals("code")) |
| | 67 | | { |
| 16 | 68 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 69 | | { |
| | 70 | | continue; |
| | 71 | | } |
| 16 | 72 | | code = property.Value.GetString(); |
| 16 | 73 | | continue; |
| | 74 | | } |
| 16 | 75 | | if (property.NameEquals("message")) |
| | 76 | | { |
| 16 | 77 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 78 | | { |
| | 79 | | continue; |
| | 80 | | } |
| 16 | 81 | | message = property.Value.GetString(); |
| 16 | 82 | | continue; |
| | 83 | | } |
| 0 | 84 | | if (property.NameEquals("target")) |
| | 85 | | { |
| 0 | 86 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 87 | | { |
| | 88 | | continue; |
| | 89 | | } |
| 0 | 90 | | target = property.Value.GetString(); |
| 0 | 91 | | continue; |
| | 92 | | } |
| 0 | 93 | | if (property.NameEquals("details")) |
| | 94 | | { |
| 0 | 95 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| | 97 | | continue; |
| | 98 | | } |
| 0 | 99 | | List<ErrorResponse> array = new List<ErrorResponse>(); |
| 0 | 100 | | foreach (var item in property.Value.EnumerateArray()) |
| | 101 | | { |
| 0 | 102 | | if (item.ValueKind == JsonValueKind.Null) |
| | 103 | | { |
| 0 | 104 | | array.Add(null); |
| | 105 | | } |
| | 106 | | else |
| | 107 | | { |
| 0 | 108 | | array.Add(DeserializeErrorResponse(item)); |
| | 109 | | } |
| | 110 | | } |
| 0 | 111 | | details = array; |
| 0 | 112 | | continue; |
| | 113 | | } |
| 0 | 114 | | if (property.NameEquals("additionalInfo")) |
| | 115 | | { |
| 0 | 116 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 117 | | { |
| | 118 | | continue; |
| | 119 | | } |
| 0 | 120 | | List<ErrorAdditionalInfo> array = new List<ErrorAdditionalInfo>(); |
| 0 | 121 | | foreach (var item in property.Value.EnumerateArray()) |
| | 122 | | { |
| 0 | 123 | | if (item.ValueKind == JsonValueKind.Null) |
| | 124 | | { |
| 0 | 125 | | array.Add(null); |
| | 126 | | } |
| | 127 | | else |
| | 128 | | { |
| 0 | 129 | | array.Add(ErrorAdditionalInfo.DeserializeErrorAdditionalInfo(item)); |
| | 130 | | } |
| | 131 | | } |
| 0 | 132 | | additionalInfo = array; |
| | 133 | | continue; |
| | 134 | | } |
| | 135 | | } |
| 16 | 136 | | return new ErrorResponse(code, message, target, details, additionalInfo); |
| | 137 | | } |
| | 138 | | } |
| | 139 | | } |