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