| | 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 VirtualNetworkPeering : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 16 | 17 | | writer.WriteStartObject(); |
| 16 | 18 | | if (Name != null) |
| | 19 | | { |
| 8 | 20 | | writer.WritePropertyName("name"); |
| 8 | 21 | | writer.WriteStringValue(Name); |
| | 22 | | } |
| 16 | 23 | | if (Etag != null) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("etag"); |
| 0 | 26 | | writer.WriteStringValue(Etag); |
| | 27 | | } |
| 16 | 28 | | if (Id != null) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("id"); |
| 0 | 31 | | writer.WriteStringValue(Id); |
| | 32 | | } |
| 16 | 33 | | writer.WritePropertyName("properties"); |
| 16 | 34 | | writer.WriteStartObject(); |
| 16 | 35 | | if (AllowVirtualNetworkAccess != null) |
| | 36 | | { |
| 8 | 37 | | writer.WritePropertyName("allowVirtualNetworkAccess"); |
| 8 | 38 | | writer.WriteBooleanValue(AllowVirtualNetworkAccess.Value); |
| | 39 | | } |
| 16 | 40 | | if (AllowForwardedTraffic != null) |
| | 41 | | { |
| 16 | 42 | | writer.WritePropertyName("allowForwardedTraffic"); |
| 16 | 43 | | writer.WriteBooleanValue(AllowForwardedTraffic.Value); |
| | 44 | | } |
| 16 | 45 | | if (AllowGatewayTransit != null) |
| | 46 | | { |
| 0 | 47 | | writer.WritePropertyName("allowGatewayTransit"); |
| 0 | 48 | | writer.WriteBooleanValue(AllowGatewayTransit.Value); |
| | 49 | | } |
| 16 | 50 | | if (UseRemoteGateways != null) |
| | 51 | | { |
| 0 | 52 | | writer.WritePropertyName("useRemoteGateways"); |
| 0 | 53 | | writer.WriteBooleanValue(UseRemoteGateways.Value); |
| | 54 | | } |
| 16 | 55 | | if (RemoteVirtualNetwork != null) |
| | 56 | | { |
| 16 | 57 | | writer.WritePropertyName("remoteVirtualNetwork"); |
| 16 | 58 | | writer.WriteObjectValue(RemoteVirtualNetwork); |
| | 59 | | } |
| 16 | 60 | | if (RemoteAddressSpace != null) |
| | 61 | | { |
| 0 | 62 | | writer.WritePropertyName("remoteAddressSpace"); |
| 0 | 63 | | writer.WriteObjectValue(RemoteAddressSpace); |
| | 64 | | } |
| 16 | 65 | | if (PeeringState != null) |
| | 66 | | { |
| 0 | 67 | | writer.WritePropertyName("peeringState"); |
| 0 | 68 | | writer.WriteStringValue(PeeringState.Value.ToString()); |
| | 69 | | } |
| 16 | 70 | | if (ProvisioningState != null) |
| | 71 | | { |
| 0 | 72 | | writer.WritePropertyName("provisioningState"); |
| 0 | 73 | | writer.WriteStringValue(ProvisioningState.Value.ToString()); |
| | 74 | | } |
| 16 | 75 | | writer.WriteEndObject(); |
| 16 | 76 | | writer.WriteEndObject(); |
| 16 | 77 | | } |
| | 78 | |
|
| | 79 | | internal static VirtualNetworkPeering DeserializeVirtualNetworkPeering(JsonElement element) |
| | 80 | | { |
| 24 | 81 | | string name = default; |
| 24 | 82 | | string etag = default; |
| 24 | 83 | | string id = default; |
| 24 | 84 | | bool? allowVirtualNetworkAccess = default; |
| 24 | 85 | | bool? allowForwardedTraffic = default; |
| 24 | 86 | | bool? allowGatewayTransit = default; |
| 24 | 87 | | bool? useRemoteGateways = default; |
| 24 | 88 | | SubResource remoteVirtualNetwork = default; |
| 24 | 89 | | AddressSpace remoteAddressSpace = default; |
| 24 | 90 | | VirtualNetworkPeeringState? peeringState = default; |
| 24 | 91 | | ProvisioningState? provisioningState = default; |
| 288 | 92 | | foreach (var property in element.EnumerateObject()) |
| | 93 | | { |
| 120 | 94 | | if (property.NameEquals("name")) |
| | 95 | | { |
| 24 | 96 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 97 | | { |
| | 98 | | continue; |
| | 99 | | } |
| 24 | 100 | | name = property.Value.GetString(); |
| 24 | 101 | | continue; |
| | 102 | | } |
| 96 | 103 | | if (property.NameEquals("etag")) |
| | 104 | | { |
| 24 | 105 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 106 | | { |
| | 107 | | continue; |
| | 108 | | } |
| 24 | 109 | | etag = property.Value.GetString(); |
| 24 | 110 | | continue; |
| | 111 | | } |
| 72 | 112 | | if (property.NameEquals("id")) |
| | 113 | | { |
| 24 | 114 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 115 | | { |
| | 116 | | continue; |
| | 117 | | } |
| 24 | 118 | | id = property.Value.GetString(); |
| 24 | 119 | | continue; |
| | 120 | | } |
| 48 | 121 | | if (property.NameEquals("properties")) |
| | 122 | | { |
| 576 | 123 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 124 | | { |
| 264 | 125 | | if (property0.NameEquals("allowVirtualNetworkAccess")) |
| | 126 | | { |
| 24 | 127 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| | 129 | | continue; |
| | 130 | | } |
| 24 | 131 | | allowVirtualNetworkAccess = property0.Value.GetBoolean(); |
| 24 | 132 | | continue; |
| | 133 | | } |
| 240 | 134 | | if (property0.NameEquals("allowForwardedTraffic")) |
| | 135 | | { |
| 24 | 136 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 137 | | { |
| | 138 | | continue; |
| | 139 | | } |
| 24 | 140 | | allowForwardedTraffic = property0.Value.GetBoolean(); |
| 24 | 141 | | continue; |
| | 142 | | } |
| 216 | 143 | | if (property0.NameEquals("allowGatewayTransit")) |
| | 144 | | { |
| 24 | 145 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 146 | | { |
| | 147 | | continue; |
| | 148 | | } |
| 24 | 149 | | allowGatewayTransit = property0.Value.GetBoolean(); |
| 24 | 150 | | continue; |
| | 151 | | } |
| 192 | 152 | | if (property0.NameEquals("useRemoteGateways")) |
| | 153 | | { |
| 24 | 154 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 24 | 158 | | useRemoteGateways = property0.Value.GetBoolean(); |
| 24 | 159 | | continue; |
| | 160 | | } |
| 168 | 161 | | if (property0.NameEquals("remoteVirtualNetwork")) |
| | 162 | | { |
| 24 | 163 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 164 | | { |
| | 165 | | continue; |
| | 166 | | } |
| 24 | 167 | | remoteVirtualNetwork = DeserializeSubResource(property0.Value); |
| 24 | 168 | | continue; |
| | 169 | | } |
| 144 | 170 | | if (property0.NameEquals("remoteAddressSpace")) |
| | 171 | | { |
| 24 | 172 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 173 | | { |
| | 174 | | continue; |
| | 175 | | } |
| 24 | 176 | | remoteAddressSpace = AddressSpace.DeserializeAddressSpace(property0.Value); |
| 24 | 177 | | continue; |
| | 178 | | } |
| 120 | 179 | | if (property0.NameEquals("peeringState")) |
| | 180 | | { |
| 24 | 181 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 182 | | { |
| | 183 | | continue; |
| | 184 | | } |
| 24 | 185 | | peeringState = new VirtualNetworkPeeringState(property0.Value.GetString()); |
| 24 | 186 | | continue; |
| | 187 | | } |
| 96 | 188 | | if (property0.NameEquals("provisioningState")) |
| | 189 | | { |
| 24 | 190 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 191 | | { |
| | 192 | | continue; |
| | 193 | | } |
| 24 | 194 | | provisioningState = new ProvisioningState(property0.Value.GetString()); |
| | 195 | | continue; |
| | 196 | | } |
| | 197 | | } |
| | 198 | | continue; |
| | 199 | | } |
| | 200 | | } |
| 24 | 201 | | return new VirtualNetworkPeering(id, name, etag, allowVirtualNetworkAccess, allowForwardedTraffic, allowGate |
| | 202 | | } |
| | 203 | | } |
| | 204 | | } |