| | 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 AzureFirewallApplicationRule : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Name != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("name"); |
| 0 | 22 | | writer.WriteStringValue(Name); |
| | 23 | | } |
| 0 | 24 | | if (Description != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("description"); |
| 0 | 27 | | writer.WriteStringValue(Description); |
| | 28 | | } |
| 0 | 29 | | if (SourceAddresses != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("sourceAddresses"); |
| 0 | 32 | | writer.WriteStartArray(); |
| 0 | 33 | | foreach (var item in SourceAddresses) |
| | 34 | | { |
| 0 | 35 | | writer.WriteStringValue(item); |
| | 36 | | } |
| 0 | 37 | | writer.WriteEndArray(); |
| | 38 | | } |
| 0 | 39 | | if (Protocols != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("protocols"); |
| 0 | 42 | | writer.WriteStartArray(); |
| 0 | 43 | | foreach (var item in Protocols) |
| | 44 | | { |
| 0 | 45 | | writer.WriteObjectValue(item); |
| | 46 | | } |
| 0 | 47 | | writer.WriteEndArray(); |
| | 48 | | } |
| 0 | 49 | | if (TargetFqdns != null) |
| | 50 | | { |
| 0 | 51 | | writer.WritePropertyName("targetFqdns"); |
| 0 | 52 | | writer.WriteStartArray(); |
| 0 | 53 | | foreach (var item in TargetFqdns) |
| | 54 | | { |
| 0 | 55 | | writer.WriteStringValue(item); |
| | 56 | | } |
| 0 | 57 | | writer.WriteEndArray(); |
| | 58 | | } |
| 0 | 59 | | if (FqdnTags != null) |
| | 60 | | { |
| 0 | 61 | | writer.WritePropertyName("fqdnTags"); |
| 0 | 62 | | writer.WriteStartArray(); |
| 0 | 63 | | foreach (var item in FqdnTags) |
| | 64 | | { |
| 0 | 65 | | writer.WriteStringValue(item); |
| | 66 | | } |
| 0 | 67 | | writer.WriteEndArray(); |
| | 68 | | } |
| 0 | 69 | | if (SourceIpGroups != null) |
| | 70 | | { |
| 0 | 71 | | writer.WritePropertyName("sourceIpGroups"); |
| 0 | 72 | | writer.WriteStartArray(); |
| 0 | 73 | | foreach (var item in SourceIpGroups) |
| | 74 | | { |
| 0 | 75 | | writer.WriteStringValue(item); |
| | 76 | | } |
| 0 | 77 | | writer.WriteEndArray(); |
| | 78 | | } |
| 0 | 79 | | writer.WriteEndObject(); |
| 0 | 80 | | } |
| | 81 | |
|
| | 82 | | internal static AzureFirewallApplicationRule DeserializeAzureFirewallApplicationRule(JsonElement element) |
| | 83 | | { |
| 0 | 84 | | string name = default; |
| 0 | 85 | | string description = default; |
| 0 | 86 | | IList<string> sourceAddresses = default; |
| 0 | 87 | | IList<AzureFirewallApplicationRuleProtocol> protocols = default; |
| 0 | 88 | | IList<string> targetFqdns = default; |
| 0 | 89 | | IList<string> fqdnTags = default; |
| 0 | 90 | | IList<string> sourceIpGroups = default; |
| 0 | 91 | | foreach (var property in element.EnumerateObject()) |
| | 92 | | { |
| 0 | 93 | | if (property.NameEquals("name")) |
| | 94 | | { |
| 0 | 95 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| | 97 | | continue; |
| | 98 | | } |
| 0 | 99 | | name = property.Value.GetString(); |
| 0 | 100 | | continue; |
| | 101 | | } |
| 0 | 102 | | if (property.NameEquals("description")) |
| | 103 | | { |
| 0 | 104 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 105 | | { |
| | 106 | | continue; |
| | 107 | | } |
| 0 | 108 | | description = property.Value.GetString(); |
| 0 | 109 | | continue; |
| | 110 | | } |
| 0 | 111 | | if (property.NameEquals("sourceAddresses")) |
| | 112 | | { |
| 0 | 113 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 114 | | { |
| | 115 | | continue; |
| | 116 | | } |
| 0 | 117 | | List<string> array = new List<string>(); |
| 0 | 118 | | foreach (var item in property.Value.EnumerateArray()) |
| | 119 | | { |
| 0 | 120 | | if (item.ValueKind == JsonValueKind.Null) |
| | 121 | | { |
| 0 | 122 | | array.Add(null); |
| | 123 | | } |
| | 124 | | else |
| | 125 | | { |
| 0 | 126 | | array.Add(item.GetString()); |
| | 127 | | } |
| | 128 | | } |
| 0 | 129 | | sourceAddresses = array; |
| 0 | 130 | | continue; |
| | 131 | | } |
| 0 | 132 | | if (property.NameEquals("protocols")) |
| | 133 | | { |
| 0 | 134 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 135 | | { |
| | 136 | | continue; |
| | 137 | | } |
| 0 | 138 | | List<AzureFirewallApplicationRuleProtocol> array = new List<AzureFirewallApplicationRuleProtocol>(); |
| 0 | 139 | | foreach (var item in property.Value.EnumerateArray()) |
| | 140 | | { |
| 0 | 141 | | if (item.ValueKind == JsonValueKind.Null) |
| | 142 | | { |
| 0 | 143 | | array.Add(null); |
| | 144 | | } |
| | 145 | | else |
| | 146 | | { |
| 0 | 147 | | array.Add(AzureFirewallApplicationRuleProtocol.DeserializeAzureFirewallApplicationRuleProtoc |
| | 148 | | } |
| | 149 | | } |
| 0 | 150 | | protocols = array; |
| 0 | 151 | | continue; |
| | 152 | | } |
| 0 | 153 | | if (property.NameEquals("targetFqdns")) |
| | 154 | | { |
| 0 | 155 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 156 | | { |
| | 157 | | continue; |
| | 158 | | } |
| 0 | 159 | | List<string> array = new List<string>(); |
| 0 | 160 | | foreach (var item in property.Value.EnumerateArray()) |
| | 161 | | { |
| 0 | 162 | | if (item.ValueKind == JsonValueKind.Null) |
| | 163 | | { |
| 0 | 164 | | array.Add(null); |
| | 165 | | } |
| | 166 | | else |
| | 167 | | { |
| 0 | 168 | | array.Add(item.GetString()); |
| | 169 | | } |
| | 170 | | } |
| 0 | 171 | | targetFqdns = array; |
| 0 | 172 | | continue; |
| | 173 | | } |
| 0 | 174 | | if (property.NameEquals("fqdnTags")) |
| | 175 | | { |
| 0 | 176 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 177 | | { |
| | 178 | | continue; |
| | 179 | | } |
| 0 | 180 | | List<string> array = new List<string>(); |
| 0 | 181 | | foreach (var item in property.Value.EnumerateArray()) |
| | 182 | | { |
| 0 | 183 | | if (item.ValueKind == JsonValueKind.Null) |
| | 184 | | { |
| 0 | 185 | | array.Add(null); |
| | 186 | | } |
| | 187 | | else |
| | 188 | | { |
| 0 | 189 | | array.Add(item.GetString()); |
| | 190 | | } |
| | 191 | | } |
| 0 | 192 | | fqdnTags = array; |
| 0 | 193 | | continue; |
| | 194 | | } |
| 0 | 195 | | if (property.NameEquals("sourceIpGroups")) |
| | 196 | | { |
| 0 | 197 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 198 | | { |
| | 199 | | continue; |
| | 200 | | } |
| 0 | 201 | | List<string> array = new List<string>(); |
| 0 | 202 | | foreach (var item in property.Value.EnumerateArray()) |
| | 203 | | { |
| 0 | 204 | | if (item.ValueKind == JsonValueKind.Null) |
| | 205 | | { |
| 0 | 206 | | array.Add(null); |
| | 207 | | } |
| | 208 | | else |
| | 209 | | { |
| 0 | 210 | | array.Add(item.GetString()); |
| | 211 | | } |
| | 212 | | } |
| 0 | 213 | | sourceIpGroups = array; |
| | 214 | | continue; |
| | 215 | | } |
| | 216 | | } |
| 0 | 217 | | return new AzureFirewallApplicationRule(name, description, sourceAddresses, protocols, targetFqdns, fqdnTags |
| | 218 | | } |
| | 219 | | } |
| | 220 | | } |