| | 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 OutboundRule : 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 (Etag != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("etag"); |
| 0 | 27 | | writer.WriteStringValue(Etag); |
| | 28 | | } |
| 0 | 29 | | if (Type != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("type"); |
| 0 | 32 | | writer.WriteStringValue(Type); |
| | 33 | | } |
| 0 | 34 | | if (Id != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("id"); |
| 0 | 37 | | writer.WriteStringValue(Id); |
| | 38 | | } |
| 0 | 39 | | writer.WritePropertyName("properties"); |
| 0 | 40 | | writer.WriteStartObject(); |
| 0 | 41 | | if (AllocatedOutboundPorts != null) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("allocatedOutboundPorts"); |
| 0 | 44 | | writer.WriteNumberValue(AllocatedOutboundPorts.Value); |
| | 45 | | } |
| 0 | 46 | | if (FrontendIPConfigurations != null) |
| | 47 | | { |
| 0 | 48 | | writer.WritePropertyName("frontendIPConfigurations"); |
| 0 | 49 | | writer.WriteStartArray(); |
| 0 | 50 | | foreach (var item in FrontendIPConfigurations) |
| | 51 | | { |
| 0 | 52 | | writer.WriteObjectValue(item); |
| | 53 | | } |
| 0 | 54 | | writer.WriteEndArray(); |
| | 55 | | } |
| 0 | 56 | | if (BackendAddressPool != null) |
| | 57 | | { |
| 0 | 58 | | writer.WritePropertyName("backendAddressPool"); |
| 0 | 59 | | writer.WriteObjectValue(BackendAddressPool); |
| | 60 | | } |
| 0 | 61 | | if (ProvisioningState != null) |
| | 62 | | { |
| 0 | 63 | | writer.WritePropertyName("provisioningState"); |
| 0 | 64 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 65 | | } |
| 0 | 66 | | if (Protocol != null) |
| | 67 | | { |
| 0 | 68 | | writer.WritePropertyName("protocol"); |
| 0 | 69 | | writer.WriteStringValue(Protocol.Value.ToString()); |
| | 70 | | } |
| 0 | 71 | | if (EnableTcpReset != null) |
| | 72 | | { |
| 0 | 73 | | writer.WritePropertyName("enableTcpReset"); |
| 0 | 74 | | writer.WriteBooleanValue(EnableTcpReset.Value); |
| | 75 | | } |
| 0 | 76 | | if (IdleTimeoutInMinutes != null) |
| | 77 | | { |
| 0 | 78 | | writer.WritePropertyName("idleTimeoutInMinutes"); |
| 0 | 79 | | writer.WriteNumberValue(IdleTimeoutInMinutes.Value); |
| | 80 | | } |
| 0 | 81 | | writer.WriteEndObject(); |
| 0 | 82 | | writer.WriteEndObject(); |
| 0 | 83 | | } |
| | 84 | |
|
| | 85 | | internal static OutboundRule DeserializeOutboundRule(JsonElement element) |
| | 86 | | { |
| 0 | 87 | | string name = default; |
| 0 | 88 | | string etag = default; |
| 0 | 89 | | string type = default; |
| 0 | 90 | | string id = default; |
| 0 | 91 | | int? allocatedOutboundPorts = default; |
| 0 | 92 | | IList<SubResource> frontendIPConfigurations = default; |
| 0 | 93 | | SubResource backendAddressPool = default; |
| 0 | 94 | | ProvisioningState? provisioningState = default; |
| 0 | 95 | | LoadBalancerOutboundRuleProtocol? protocol = default; |
| 0 | 96 | | bool? enableTcpReset = default; |
| 0 | 97 | | int? idleTimeoutInMinutes = default; |
| 0 | 98 | | foreach (var property in element.EnumerateObject()) |
| | 99 | | { |
| 0 | 100 | | if (property.NameEquals("name")) |
| | 101 | | { |
| 0 | 102 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 103 | | { |
| | 104 | | continue; |
| | 105 | | } |
| 0 | 106 | | name = property.Value.GetString(); |
| 0 | 107 | | continue; |
| | 108 | | } |
| 0 | 109 | | if (property.NameEquals("etag")) |
| | 110 | | { |
| 0 | 111 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 112 | | { |
| | 113 | | continue; |
| | 114 | | } |
| 0 | 115 | | etag = property.Value.GetString(); |
| 0 | 116 | | continue; |
| | 117 | | } |
| 0 | 118 | | if (property.NameEquals("type")) |
| | 119 | | { |
| 0 | 120 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 121 | | { |
| | 122 | | continue; |
| | 123 | | } |
| 0 | 124 | | type = property.Value.GetString(); |
| 0 | 125 | | continue; |
| | 126 | | } |
| 0 | 127 | | if (property.NameEquals("id")) |
| | 128 | | { |
| 0 | 129 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 130 | | { |
| | 131 | | continue; |
| | 132 | | } |
| 0 | 133 | | id = property.Value.GetString(); |
| 0 | 134 | | continue; |
| | 135 | | } |
| 0 | 136 | | if (property.NameEquals("properties")) |
| | 137 | | { |
| 0 | 138 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 139 | | { |
| 0 | 140 | | if (property0.NameEquals("allocatedOutboundPorts")) |
| | 141 | | { |
| 0 | 142 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 143 | | { |
| | 144 | | continue; |
| | 145 | | } |
| 0 | 146 | | allocatedOutboundPorts = property0.Value.GetInt32(); |
| 0 | 147 | | continue; |
| | 148 | | } |
| 0 | 149 | | if (property0.NameEquals("frontendIPConfigurations")) |
| | 150 | | { |
| 0 | 151 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 152 | | { |
| | 153 | | continue; |
| | 154 | | } |
| 0 | 155 | | List<SubResource> array = new List<SubResource>(); |
| 0 | 156 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 157 | | { |
| 0 | 158 | | if (item.ValueKind == JsonValueKind.Null) |
| | 159 | | { |
| 0 | 160 | | array.Add(null); |
| | 161 | | } |
| | 162 | | else |
| | 163 | | { |
| 0 | 164 | | array.Add(DeserializeSubResource(item)); |
| | 165 | | } |
| | 166 | | } |
| 0 | 167 | | frontendIPConfigurations = array; |
| 0 | 168 | | continue; |
| | 169 | | } |
| 0 | 170 | | if (property0.NameEquals("backendAddressPool")) |
| | 171 | | { |
| 0 | 172 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 173 | | { |
| | 174 | | continue; |
| | 175 | | } |
| 0 | 176 | | backendAddressPool = DeserializeSubResource(property0.Value); |
| 0 | 177 | | continue; |
| | 178 | | } |
| 0 | 179 | | if (property0.NameEquals("provisioningState")) |
| | 180 | | { |
| 0 | 181 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 182 | | { |
| | 183 | | continue; |
| | 184 | | } |
| 0 | 185 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| 0 | 186 | | continue; |
| | 187 | | } |
| 0 | 188 | | if (property0.NameEquals("protocol")) |
| | 189 | | { |
| 0 | 190 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 191 | | { |
| | 192 | | continue; |
| | 193 | | } |
| 0 | 194 | | protocol = new LoadBalancerOutboundRuleProtocol(property0.Value.GetString()); |
| 0 | 195 | | continue; |
| | 196 | | } |
| 0 | 197 | | if (property0.NameEquals("enableTcpReset")) |
| | 198 | | { |
| 0 | 199 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 200 | | { |
| | 201 | | continue; |
| | 202 | | } |
| 0 | 203 | | enableTcpReset = property0.Value.GetBoolean(); |
| 0 | 204 | | continue; |
| | 205 | | } |
| 0 | 206 | | if (property0.NameEquals("idleTimeoutInMinutes")) |
| | 207 | | { |
| 0 | 208 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 209 | | { |
| | 210 | | continue; |
| | 211 | | } |
| 0 | 212 | | idleTimeoutInMinutes = property0.Value.GetInt32(); |
| | 213 | | continue; |
| | 214 | | } |
| | 215 | | } |
| | 216 | | continue; |
| | 217 | | } |
| | 218 | | } |
| 0 | 219 | | return new OutboundRule(id, name, etag, type, allocatedOutboundPorts, frontendIPConfigurations, backendAddre |
| | 220 | | } |
| | 221 | | } |
| | 222 | | } |