| | 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 BgpServiceCommunity : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Id != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("id"); |
| 0 | 22 | | writer.WriteStringValue(Id); |
| | 23 | | } |
| 0 | 24 | | if (Name != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("name"); |
| 0 | 27 | | writer.WriteStringValue(Name); |
| | 28 | | } |
| 0 | 29 | | if (Type != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("type"); |
| 0 | 32 | | writer.WriteStringValue(Type); |
| | 33 | | } |
| 0 | 34 | | if (Location != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("location"); |
| 0 | 37 | | writer.WriteStringValue(Location); |
| | 38 | | } |
| 0 | 39 | | if (Tags != null) |
| | 40 | | { |
| 0 | 41 | | writer.WritePropertyName("tags"); |
| 0 | 42 | | writer.WriteStartObject(); |
| 0 | 43 | | foreach (var item in Tags) |
| | 44 | | { |
| 0 | 45 | | writer.WritePropertyName(item.Key); |
| 0 | 46 | | writer.WriteStringValue(item.Value); |
| | 47 | | } |
| 0 | 48 | | writer.WriteEndObject(); |
| | 49 | | } |
| 0 | 50 | | writer.WritePropertyName("properties"); |
| 0 | 51 | | writer.WriteStartObject(); |
| 0 | 52 | | if (ServiceName != null) |
| | 53 | | { |
| 0 | 54 | | writer.WritePropertyName("serviceName"); |
| 0 | 55 | | writer.WriteStringValue(ServiceName); |
| | 56 | | } |
| 0 | 57 | | if (BgpCommunities != null) |
| | 58 | | { |
| 0 | 59 | | writer.WritePropertyName("bgpCommunities"); |
| 0 | 60 | | writer.WriteStartArray(); |
| 0 | 61 | | foreach (var item in BgpCommunities) |
| | 62 | | { |
| 0 | 63 | | writer.WriteObjectValue(item); |
| | 64 | | } |
| 0 | 65 | | writer.WriteEndArray(); |
| | 66 | | } |
| 0 | 67 | | writer.WriteEndObject(); |
| 0 | 68 | | writer.WriteEndObject(); |
| 0 | 69 | | } |
| | 70 | |
|
| | 71 | | internal static BgpServiceCommunity DeserializeBgpServiceCommunity(JsonElement element) |
| | 72 | | { |
| 716 | 73 | | string id = default; |
| 716 | 74 | | string name = default; |
| 716 | 75 | | string type = default; |
| 716 | 76 | | string location = default; |
| 716 | 77 | | IDictionary<string, string> tags = default; |
| 716 | 78 | | string serviceName = default; |
| 716 | 79 | | IList<BGPCommunity> bgpCommunities = default; |
| 7160 | 80 | | foreach (var property in element.EnumerateObject()) |
| | 81 | | { |
| 2864 | 82 | | if (property.NameEquals("id")) |
| | 83 | | { |
| 716 | 84 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 85 | | { |
| | 86 | | continue; |
| | 87 | | } |
| 716 | 88 | | id = property.Value.GetString(); |
| 716 | 89 | | continue; |
| | 90 | | } |
| 2148 | 91 | | if (property.NameEquals("name")) |
| | 92 | | { |
| 716 | 93 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 94 | | { |
| | 95 | | continue; |
| | 96 | | } |
| 716 | 97 | | name = property.Value.GetString(); |
| 716 | 98 | | continue; |
| | 99 | | } |
| 1432 | 100 | | if (property.NameEquals("type")) |
| | 101 | | { |
| 716 | 102 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 103 | | { |
| | 104 | | continue; |
| | 105 | | } |
| 716 | 106 | | type = property.Value.GetString(); |
| 716 | 107 | | continue; |
| | 108 | | } |
| 716 | 109 | | if (property.NameEquals("location")) |
| | 110 | | { |
| 0 | 111 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 112 | | { |
| | 113 | | continue; |
| | 114 | | } |
| 0 | 115 | | location = property.Value.GetString(); |
| 0 | 116 | | continue; |
| | 117 | | } |
| 716 | 118 | | if (property.NameEquals("tags")) |
| | 119 | | { |
| 0 | 120 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 121 | | { |
| | 122 | | continue; |
| | 123 | | } |
| 0 | 124 | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| 0 | 125 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 126 | | { |
| 0 | 127 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| 0 | 129 | | dictionary.Add(property0.Name, null); |
| | 130 | | } |
| | 131 | | else |
| | 132 | | { |
| 0 | 133 | | dictionary.Add(property0.Name, property0.Value.GetString()); |
| | 134 | | } |
| | 135 | | } |
| 0 | 136 | | tags = dictionary; |
| 0 | 137 | | continue; |
| | 138 | | } |
| 716 | 139 | | if (property.NameEquals("properties")) |
| | 140 | | { |
| 4296 | 141 | | foreach (var property0 in property.Value.EnumerateObject()) |
| | 142 | | { |
| 1432 | 143 | | if (property0.NameEquals("serviceName")) |
| | 144 | | { |
| 716 | 145 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 146 | | { |
| | 147 | | continue; |
| | 148 | | } |
| 716 | 149 | | serviceName = property0.Value.GetString(); |
| 716 | 150 | | continue; |
| | 151 | | } |
| 716 | 152 | | if (property0.NameEquals("bgpCommunities")) |
| | 153 | | { |
| 716 | 154 | | if (property0.Value.ValueKind == JsonValueKind.Null) |
| | 155 | | { |
| | 156 | | continue; |
| | 157 | | } |
| 716 | 158 | | List<BGPCommunity> array = new List<BGPCommunity>(); |
| 2864 | 159 | | foreach (var item in property0.Value.EnumerateArray()) |
| | 160 | | { |
| 716 | 161 | | if (item.ValueKind == JsonValueKind.Null) |
| | 162 | | { |
| 0 | 163 | | array.Add(null); |
| | 164 | | } |
| | 165 | | else |
| | 166 | | { |
| 716 | 167 | | array.Add(BGPCommunity.DeserializeBGPCommunity(item)); |
| | 168 | | } |
| | 169 | | } |
| 716 | 170 | | bgpCommunities = array; |
| | 171 | | continue; |
| | 172 | | } |
| | 173 | | } |
| | 174 | | continue; |
| | 175 | | } |
| | 176 | | } |
| 716 | 177 | | return new BgpServiceCommunity(id, name, type, location, tags, serviceName, bgpCommunities); |
| | 178 | | } |
| | 179 | | } |
| | 180 | | } |