| | 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.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.ResourceManager.Network.Models |
| | 12 | | { |
| | 13 | | public partial class PacketCaptureFilter : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | if (Protocol != null) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("protocol"); |
| 0 | 21 | | writer.WriteStringValue(Protocol.Value.ToString()); |
| | 22 | | } |
| 0 | 23 | | if (LocalIPAddress != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("localIPAddress"); |
| 0 | 26 | | writer.WriteStringValue(LocalIPAddress); |
| | 27 | | } |
| 0 | 28 | | if (RemoteIPAddress != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("remoteIPAddress"); |
| 0 | 31 | | writer.WriteStringValue(RemoteIPAddress); |
| | 32 | | } |
| 0 | 33 | | if (LocalPort != null) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("localPort"); |
| 0 | 36 | | writer.WriteStringValue(LocalPort); |
| | 37 | | } |
| 0 | 38 | | if (RemotePort != null) |
| | 39 | | { |
| 0 | 40 | | writer.WritePropertyName("remotePort"); |
| 0 | 41 | | writer.WriteStringValue(RemotePort); |
| | 42 | | } |
| 0 | 43 | | writer.WriteEndObject(); |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal static PacketCaptureFilter DeserializePacketCaptureFilter(JsonElement element) |
| | 47 | | { |
| 0 | 48 | | PcProtocol? protocol = default; |
| 0 | 49 | | string localIPAddress = default; |
| 0 | 50 | | string remoteIPAddress = default; |
| 0 | 51 | | string localPort = default; |
| 0 | 52 | | string remotePort = default; |
| 0 | 53 | | foreach (var property in element.EnumerateObject()) |
| | 54 | | { |
| 0 | 55 | | if (property.NameEquals("protocol")) |
| | 56 | | { |
| 0 | 57 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 58 | | { |
| | 59 | | continue; |
| | 60 | | } |
| 0 | 61 | | protocol = new PcProtocol(property.Value.GetString()); |
| 0 | 62 | | continue; |
| | 63 | | } |
| 0 | 64 | | if (property.NameEquals("localIPAddress")) |
| | 65 | | { |
| 0 | 66 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 67 | | { |
| | 68 | | continue; |
| | 69 | | } |
| 0 | 70 | | localIPAddress = property.Value.GetString(); |
| 0 | 71 | | continue; |
| | 72 | | } |
| 0 | 73 | | if (property.NameEquals("remoteIPAddress")) |
| | 74 | | { |
| 0 | 75 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 76 | | { |
| | 77 | | continue; |
| | 78 | | } |
| 0 | 79 | | remoteIPAddress = property.Value.GetString(); |
| 0 | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | if (property.NameEquals("localPort")) |
| | 83 | | { |
| 0 | 84 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 85 | | { |
| | 86 | | continue; |
| | 87 | | } |
| 0 | 88 | | localPort = property.Value.GetString(); |
| 0 | 89 | | continue; |
| | 90 | | } |
| 0 | 91 | | if (property.NameEquals("remotePort")) |
| | 92 | | { |
| 0 | 93 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 94 | | { |
| | 95 | | continue; |
| | 96 | | } |
| 0 | 97 | | remotePort = property.Value.GetString(); |
| | 98 | | continue; |
| | 99 | | } |
| | 100 | | } |
| 0 | 101 | | return new PacketCaptureFilter(protocol, localIPAddress, remoteIPAddress, localPort, remotePort); |
| | 102 | | } |
| | 103 | | } |
| | 104 | | } |