| | 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.Network.Models |
| | 14 | | { |
| | 15 | | public partial class ConnectionStateSnapshot |
| | 16 | | { |
| | 17 | | internal static ConnectionStateSnapshot DeserializeConnectionStateSnapshot(JsonElement element) |
| | 18 | | { |
| 0 | 19 | | ConnectionState? connectionState = default; |
| 0 | 20 | | DateTimeOffset? startTime = default; |
| 0 | 21 | | DateTimeOffset? endTime = default; |
| 0 | 22 | | EvaluationState? evaluationState = default; |
| 0 | 23 | | int? avgLatencyInMs = default; |
| 0 | 24 | | int? minLatencyInMs = default; |
| 0 | 25 | | int? maxLatencyInMs = default; |
| 0 | 26 | | int? probesSent = default; |
| 0 | 27 | | int? probesFailed = default; |
| 0 | 28 | | IReadOnlyList<ConnectivityHop> hops = default; |
| 0 | 29 | | foreach (var property in element.EnumerateObject()) |
| | 30 | | { |
| 0 | 31 | | if (property.NameEquals("connectionState")) |
| | 32 | | { |
| 0 | 33 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 34 | | { |
| | 35 | | continue; |
| | 36 | | } |
| 0 | 37 | | connectionState = new ConnectionState(property.Value.GetString()); |
| 0 | 38 | | continue; |
| | 39 | | } |
| 0 | 40 | | if (property.NameEquals("startTime")) |
| | 41 | | { |
| 0 | 42 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 43 | | { |
| | 44 | | continue; |
| | 45 | | } |
| 0 | 46 | | startTime = property.Value.GetDateTimeOffset("O"); |
| 0 | 47 | | continue; |
| | 48 | | } |
| 0 | 49 | | if (property.NameEquals("endTime")) |
| | 50 | | { |
| 0 | 51 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 52 | | { |
| | 53 | | continue; |
| | 54 | | } |
| 0 | 55 | | endTime = property.Value.GetDateTimeOffset("O"); |
| 0 | 56 | | continue; |
| | 57 | | } |
| 0 | 58 | | if (property.NameEquals("evaluationState")) |
| | 59 | | { |
| 0 | 60 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 61 | | { |
| | 62 | | continue; |
| | 63 | | } |
| 0 | 64 | | evaluationState = new EvaluationState(property.Value.GetString()); |
| 0 | 65 | | continue; |
| | 66 | | } |
| 0 | 67 | | if (property.NameEquals("avgLatencyInMs")) |
| | 68 | | { |
| 0 | 69 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | avgLatencyInMs = property.Value.GetInt32(); |
| 0 | 74 | | continue; |
| | 75 | | } |
| 0 | 76 | | if (property.NameEquals("minLatencyInMs")) |
| | 77 | | { |
| 0 | 78 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 79 | | { |
| | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | minLatencyInMs = property.Value.GetInt32(); |
| 0 | 83 | | continue; |
| | 84 | | } |
| 0 | 85 | | if (property.NameEquals("maxLatencyInMs")) |
| | 86 | | { |
| 0 | 87 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 88 | | { |
| | 89 | | continue; |
| | 90 | | } |
| 0 | 91 | | maxLatencyInMs = property.Value.GetInt32(); |
| 0 | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | if (property.NameEquals("probesSent")) |
| | 95 | | { |
| 0 | 96 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 97 | | { |
| | 98 | | continue; |
| | 99 | | } |
| 0 | 100 | | probesSent = property.Value.GetInt32(); |
| 0 | 101 | | continue; |
| | 102 | | } |
| 0 | 103 | | if (property.NameEquals("probesFailed")) |
| | 104 | | { |
| 0 | 105 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 106 | | { |
| | 107 | | continue; |
| | 108 | | } |
| 0 | 109 | | probesFailed = property.Value.GetInt32(); |
| 0 | 110 | | continue; |
| | 111 | | } |
| 0 | 112 | | if (property.NameEquals("hops")) |
| | 113 | | { |
| 0 | 114 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 115 | | { |
| | 116 | | continue; |
| | 117 | | } |
| 0 | 118 | | List<ConnectivityHop> array = new List<ConnectivityHop>(); |
| 0 | 119 | | foreach (var item in property.Value.EnumerateArray()) |
| | 120 | | { |
| 0 | 121 | | if (item.ValueKind == JsonValueKind.Null) |
| | 122 | | { |
| 0 | 123 | | array.Add(null); |
| | 124 | | } |
| | 125 | | else |
| | 126 | | { |
| 0 | 127 | | array.Add(ConnectivityHop.DeserializeConnectivityHop(item)); |
| | 128 | | } |
| | 129 | | } |
| 0 | 130 | | hops = array; |
| | 131 | | continue; |
| | 132 | | } |
| | 133 | | } |
| 0 | 134 | | return new ConnectionStateSnapshot(connectionState, startTime, endTime, evaluationState, avgLatencyInMs, min |
| | 135 | | } |
| | 136 | | } |
| | 137 | | } |