| | 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 BGPCommunity : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (ServiceSupportedRegion != null) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("serviceSupportedRegion"); |
| 0 | 22 | | writer.WriteStringValue(ServiceSupportedRegion); |
| | 23 | | } |
| 0 | 24 | | if (CommunityName != null) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("communityName"); |
| 0 | 27 | | writer.WriteStringValue(CommunityName); |
| | 28 | | } |
| 0 | 29 | | if (CommunityValue != null) |
| | 30 | | { |
| 0 | 31 | | writer.WritePropertyName("communityValue"); |
| 0 | 32 | | writer.WriteStringValue(CommunityValue); |
| | 33 | | } |
| 0 | 34 | | if (CommunityPrefixes != null) |
| | 35 | | { |
| 0 | 36 | | writer.WritePropertyName("communityPrefixes"); |
| 0 | 37 | | writer.WriteStartArray(); |
| 0 | 38 | | foreach (var item in CommunityPrefixes) |
| | 39 | | { |
| 0 | 40 | | writer.WriteStringValue(item); |
| | 41 | | } |
| 0 | 42 | | writer.WriteEndArray(); |
| | 43 | | } |
| 0 | 44 | | if (IsAuthorizedToUse != null) |
| | 45 | | { |
| 0 | 46 | | writer.WritePropertyName("isAuthorizedToUse"); |
| 0 | 47 | | writer.WriteBooleanValue(IsAuthorizedToUse.Value); |
| | 48 | | } |
| 0 | 49 | | if (ServiceGroup != null) |
| | 50 | | { |
| 0 | 51 | | writer.WritePropertyName("serviceGroup"); |
| 0 | 52 | | writer.WriteStringValue(ServiceGroup); |
| | 53 | | } |
| 0 | 54 | | writer.WriteEndObject(); |
| 0 | 55 | | } |
| | 56 | |
|
| | 57 | | internal static BGPCommunity DeserializeBGPCommunity(JsonElement element) |
| | 58 | | { |
| 716 | 59 | | string serviceSupportedRegion = default; |
| 716 | 60 | | string communityName = default; |
| 716 | 61 | | string communityValue = default; |
| 716 | 62 | | IList<string> communityPrefixes = default; |
| 716 | 63 | | bool? isAuthorizedToUse = default; |
| 716 | 64 | | string serviceGroup = default; |
| 10024 | 65 | | foreach (var property in element.EnumerateObject()) |
| | 66 | | { |
| 4296 | 67 | | if (property.NameEquals("serviceSupportedRegion")) |
| | 68 | | { |
| 716 | 69 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 70 | | { |
| | 71 | | continue; |
| | 72 | | } |
| 716 | 73 | | serviceSupportedRegion = property.Value.GetString(); |
| 716 | 74 | | continue; |
| | 75 | | } |
| 3580 | 76 | | if (property.NameEquals("communityName")) |
| | 77 | | { |
| 716 | 78 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 79 | | { |
| | 80 | | continue; |
| | 81 | | } |
| 716 | 82 | | communityName = property.Value.GetString(); |
| 716 | 83 | | continue; |
| | 84 | | } |
| 2864 | 85 | | if (property.NameEquals("communityValue")) |
| | 86 | | { |
| 716 | 87 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 88 | | { |
| | 89 | | continue; |
| | 90 | | } |
| 716 | 91 | | communityValue = property.Value.GetString(); |
| 716 | 92 | | continue; |
| | 93 | | } |
| 2148 | 94 | | if (property.NameEquals("communityPrefixes")) |
| | 95 | | { |
| 716 | 96 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 97 | | { |
| | 98 | | continue; |
| | 99 | | } |
| 716 | 100 | | List<string> array = new List<string>(); |
| 33712 | 101 | | foreach (var item in property.Value.EnumerateArray()) |
| | 102 | | { |
| 16140 | 103 | | if (item.ValueKind == JsonValueKind.Null) |
| | 104 | | { |
| 0 | 105 | | array.Add(null); |
| | 106 | | } |
| | 107 | | else |
| | 108 | | { |
| 16140 | 109 | | array.Add(item.GetString()); |
| | 110 | | } |
| | 111 | | } |
| 716 | 112 | | communityPrefixes = array; |
| 716 | 113 | | continue; |
| | 114 | | } |
| 1432 | 115 | | if (property.NameEquals("isAuthorizedToUse")) |
| | 116 | | { |
| 716 | 117 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 118 | | { |
| | 119 | | continue; |
| | 120 | | } |
| 716 | 121 | | isAuthorizedToUse = property.Value.GetBoolean(); |
| 716 | 122 | | continue; |
| | 123 | | } |
| 716 | 124 | | if (property.NameEquals("serviceGroup")) |
| | 125 | | { |
| 716 | 126 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 127 | | { |
| | 128 | | continue; |
| | 129 | | } |
| 716 | 130 | | serviceGroup = property.Value.GetString(); |
| | 131 | | continue; |
| | 132 | | } |
| | 133 | | } |
| 716 | 134 | | return new BGPCommunity(serviceSupportedRegion, communityName, communityValue, communityPrefixes, isAuthoriz |
| | 135 | | } |
| | 136 | | } |
| | 137 | | } |