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