| | 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 DdosCustomPolicy : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Etag != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("etag"); |
| 0 | 22 | | writer.WriteStringValue(Etag); |
| | 23 | | } |
| 0 | 24 | | if (Id != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("id"); |
| 0 | 27 | | writer.WriteStringValue(Id); |
| | 28 | | } |
| 0 | 29 | | if (Name != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("name"); |
| 0 | 32 | | writer.WriteStringValue(Name); |
| | 33 | | } |
| 0 | 34 | | if (Type != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("type"); |
| 0 | 37 | | writer.WriteStringValue(Type); |
| | 38 | | } |
| 0 | 39 | | if (Location != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("location"); |
| 0 | 42 | | writer.WriteStringValue(Location); |
| | 43 | | } |
| 0 | 44 | | if (Tags != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("tags"); |
| 0 | 47 | | writer.WriteStartObject(); |
| 0 | 48 | | foreach (var item in Tags) |
| | 49 | | { |
| 0 | 50 | | writer.WritePropertyName(item.Key); |
| 0 | 51 | | writer.WriteStringValue(item.Value); |
| | 52 | | } |
| 0 | 53 | | writer.WriteEndObject(); |
| | 54 | | } |
| 0 | 55 | | writer.WritePropertyName("properties"); |
| 0 | 56 | | writer.WriteStartObject(); |
| 0 | 57 | | if (ResourceGuid != null) |
| | 58 | | { |
| 0 | 59 | | writer.WritePropertyName("resourceGuid"); |
| 0 | 60 | | writer.WriteStringValue(ResourceGuid); |
| | 61 | | } |
| 0 | 62 | | if (ProvisioningState != null) |
| | 63 | | { |
| 0 | 64 | | writer.WritePropertyName("provisioningState"); |
| 0 | 65 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 66 | | } |
| 0 | 67 | | if (PublicIPAddresses != null) |
| | 68 | | { |
| 0 | 69 | | writer.WritePropertyName("publicIPAddresses"); |
| 0 | 70 | | writer.WriteStartArray(); |
| 0 | 71 | | foreach (var item in PublicIPAddresses) |
| | 72 | | { |
| 0 | 73 | | writer.WriteObjectValue(item); |
| | 74 | | } |
| 0 | 75 | | writer.WriteEndArray(); |
| | 76 | | } |
| 0 | 77 | | if (ProtocolCustomSettings != null) |
| | 78 | | { |
| 0 | 79 | | writer.WritePropertyName("protocolCustomSettings"); |
| 0 | 80 | | writer.WriteStartArray(); |
| 0 | 81 | | foreach (var item in ProtocolCustomSettings) |
| | 82 | | { |
| 0 | 83 | | writer.WriteObjectValue(item); |
| | 84 | | } |
| 0 | 85 | | writer.WriteEndArray(); |
| | 86 | | } |
| 0 | 87 | | writer.WriteEndObject(); |
| 0 | 88 | | writer.WriteEndObject(); |
| 0 | 89 | | } |
| | 90 | |
|
| | 91 | | internal static DdosCustomPolicy DeserializeDdosCustomPolicy(JsonElement element) |
| | 92 | | { |
| 0 | 93 | | string etag = default; |
| 0 | 94 | | string id = default; |
| 0 | 95 | | string name = default; |
| 0 | 96 | | string type = default; |
| 0 | 97 | | string location = default; |
| 0 | 98 | | IDictionary<string, string> tags = default; |
| 0 | 99 | | string resourceGuid = default; |
| 0 | 100 | | ProvisioningState? provisioningState = default; |
| 0 | 101 | | IList<SubResource> publicIPAddresses = default; |
| 0 | 102 | | IList<ProtocolCustomSettingsFormat> protocolCustomSettings = default; |
| 0 | 103 | | foreach (var property in element.EnumerateObject()) |
| | 104 | | { |
| 0 | 105 | | if (property.NameEquals("etag")) |
| | 106 | | { |
| 0 | 107 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 108 | | { |
| | 109 | | continue; |
| | 110 | | } |
| 0 | 111 | | etag = property.Value.GetString(); |
| 0 | 112 | | continue; |
| | 113 | | } |
| 0 | 114 | | if (property.NameEquals("id")) |
| | 115 | | { |
| 0 | 116 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 117 | | { |
| | 118 | | continue; |
| | 119 | | } |
| 0 | 120 | | id = property.Value.GetString(); |
| 0 | 121 | | continue; |
| | 122 | | } |
| 0 | 123 | | if (property.NameEquals("name")) |
| | 124 | | { |
| 0 | 125 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 126 | | { |
| | 127 | | continue; |
| | 128 | | } |
| 0 | 129 | | name = property.Value.GetString(); |
| 0 | 130 | | continue; |
| | 131 | | } |
| 0 | 132 | | if (property.NameEquals("type")) |
| | 133 | | { |
| 0 | 134 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 135 | | { |
| | 136 | | continue; |
| | 137 | | } |
| 0 | 138 | | type = property.Value.GetString(); |
| 0 | 139 | | continue; |
| | 140 | | } |
| 0 | 141 | | if (property.NameEquals("location")) |
| | 142 | | { |
| 0 | 143 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 144 | | { |
| | 145 | | continue; |
| | 146 | | } |
| 0 | 147 | | location = property.Value.GetString(); |
| 0 | 148 | | continue; |
| | 149 | | } |
| 0 | 150 | | if (property.NameEquals("tags")) |
| | 151 | | { |
| 0 | 152 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 153 | | { |
| | 154 | | continue; |
| | 155 | | } |
| 0 | 156 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 157 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 158 | | { |
| 0 | 159 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 160 | | { |
| 0 | 161 | | dictionary.Add(property0.Name, null); |
| | 162 | | } |
| | 163 | | else |
| | 164 | | { |
| 0 | 165 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 166 | | } |
| | 167 | | } |
| 0 | 168 | | tags = dictionary; |
| 0 | 169 | | continue; |
| | 170 | | } |
| 0 | 171 | | if (property.NameEquals("properties")) |
| | 172 | | { |
| 0 | 173 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 174 | | { |
| 0 | 175 | | if (property0.NameEquals("resourceGuid")) |
| | 176 | | { |
| 0 | 177 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 178 | | { |
| | 179 | | continue; |
| | 180 | | } |
| 0 | 181 | | resourceGuid = property0.Value.GetString(); |
| 0 | 182 | | continue; |
| | 183 | | } |
| 0 | 184 | | if (property0.NameEquals("provisioningState")) |
| | 185 | | { |
| 0 | 186 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 187 | | { |
| | 188 | | continue; |
| | 189 | | } |
| 0 | 190 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| 0 | 191 | | continue; |
| | 192 | | } |
| 0 | 193 | | if (property0.NameEquals("publicIPAddresses")) |
| | 194 | | { |
| 0 | 195 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 196 | | { |
| | 197 | | continue; |
| | 198 | | } |
| 0 | 199 | | List<SubResource> array = new List<SubResource>(); |
| 0 | 200 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 201 | | { |
| 0 | 202 | | if (item.ValueKind == JsonValueKind.Null) |
| | 203 | | { |
| 0 | 204 | | array.Add(null); |
| | 205 | | } |
| | 206 | | else |
| | 207 | | { |
| 0 | 208 | | array.Add(SubResource.DeserializeSubResource(item)); |
| | 209 | | } |
| | 210 | | } |
| 0 | 211 | | publicIPAddresses = array; |
| 0 | 212 | | continue; |
| | 213 | | } |
| 0 | 214 | | if (property0.NameEquals("protocolCustomSettings")) |
| | 215 | | { |
| 0 | 216 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 217 | | { |
| | 218 | | continue; |
| | 219 | | } |
| 0 | 220 | | List<ProtocolCustomSettingsFormat> array = new List<ProtocolCustomSettingsFormat>(); |
| 0 | 221 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 222 | | { |
| 0 | 223 | | if (item.ValueKind == JsonValueKind.Null) |
| | 224 | | { |
| 0 | 225 | | array.Add(null); |
| | 226 | | } |
| | 227 | | else |
| | 228 | | { |
| 0 | 229 | | array.Add(ProtocolCustomSettingsFormat.DeserializeProtocolCustomSettingsFormat(item) |
| | 230 | | } |
| | 231 | | } |
| 0 | 232 | | protocolCustomSettings = array; |
| | 233 | | continue; |
| | 234 | | } |
| | 235 | | } |
| | 236 | | continue; |
| | 237 | | } |
| | 238 | | } |
| 0 | 239 | | return new DdosCustomPolicy(id, name, type, location, tags, etag, resourceGuid, provisioningState, publicIPA |
| | 240 | | } |
| | 241 | | } |
| | 242 | | } |