From f892638b0c1f1ffc46039f0fd91cdc94c1d7a5a6 Mon Sep 17 00:00:00 2001 From: Dapeng Zhang Date: Wed, 22 Feb 2023 13:11:21 +0800 Subject: [PATCH] Fix network SDK issue https://github.com/Azure/azure-sdk-for-net/issues/34094 (#34227) * initial attempt * mitigate the breaking change * resolve comments * update changelog --- .../CHANGELOG.md | 2 ++ ....ResourceManager.Network.netstandard2.0.cs | 3 +++ .../Models/EffectiveNetworkSecurityGroup.cs | 18 ++++++++++++++++ ...ctiveNetworkSecurityGroup.Serialization.cs | 21 ++++++++++++++++--- .../Models/EffectiveNetworkSecurityGroup.cs | 9 ++++---- .../src/autorest.md | 4 ++++ 6 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 sdk/network/Azure.ResourceManager.Network/src/Customization/Models/EffectiveNetworkSecurityGroup.cs diff --git a/sdk/network/Azure.ResourceManager.Network/CHANGELOG.md b/sdk/network/Azure.ResourceManager.Network/CHANGELOG.md index f82bd37b654c5..ca6728a8db2a4 100644 --- a/sdk/network/Azure.ResourceManager.Network/CHANGELOG.md +++ b/sdk/network/Azure.ResourceManager.Network/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Fixed issue https://github.com/Azure/azure-sdk-for-net/issues/34094. Please use `EffectiveNetworkSecurityGroup.TagToIPAddresses` instead of `EffectiveNetworkSecurityGroup.TagMap`. + ### Other Changes ## 1.1.1 (2023-02-13) diff --git a/sdk/network/Azure.ResourceManager.Network/api/Azure.ResourceManager.Network.netstandard2.0.cs b/sdk/network/Azure.ResourceManager.Network/api/Azure.ResourceManager.Network.netstandard2.0.cs index edb715c80e533..fbe49da70de1a 100644 --- a/sdk/network/Azure.ResourceManager.Network/api/Azure.ResourceManager.Network.netstandard2.0.cs +++ b/sdk/network/Azure.ResourceManager.Network/api/Azure.ResourceManager.Network.netstandard2.0.cs @@ -6319,7 +6319,10 @@ internal EffectiveNetworkSecurityGroup() { } public Azure.ResourceManager.Network.Models.EffectiveNetworkSecurityGroupAssociation Association { get { throw null; } } public System.Collections.Generic.IReadOnlyList EffectiveSecurityRules { get { throw null; } } public Azure.Core.ResourceIdentifier NetworkSecurityGroupId { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This property is obsolete and might be removed in a future version, please use `TagToIPAddresses` instead", false)] public string TagMap { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary> TagToIPAddresses { get { throw null; } } } public partial class EffectiveNetworkSecurityGroupAssociation { diff --git a/sdk/network/Azure.ResourceManager.Network/src/Customization/Models/EffectiveNetworkSecurityGroup.cs b/sdk/network/Azure.ResourceManager.Network/src/Customization/Models/EffectiveNetworkSecurityGroup.cs new file mode 100644 index 0000000000000..cbe76dcb94056 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Customization/Models/EffectiveNetworkSecurityGroup.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Network.Models +{ + public partial class EffectiveNetworkSecurityGroup + { + /// Mapping of tags to list of IP Addresses included within the tag. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This property is obsolete and might be removed in a future version, please use `TagToIPAddresses` instead", false)] + public string TagMap { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.Serialization.cs index be409a98260ff..ebc41d8cede22 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.Serialization.cs +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.Serialization.cs @@ -19,7 +19,7 @@ internal static EffectiveNetworkSecurityGroup DeserializeEffectiveNetworkSecurit Optional networkSecurityGroup = default; Optional association = default; Optional> effectiveSecurityRules = default; - Optional tagMap = default; + Optional>> tagMap = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("networkSecurityGroup"u8)) @@ -59,11 +59,26 @@ internal static EffectiveNetworkSecurityGroup DeserializeEffectiveNetworkSecurit } if (property.NameEquals("tagMap"u8)) { - tagMap = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + Dictionary> dictionary = new Dictionary>(); + foreach (var property0 in property.Value.EnumerateObject()) + { + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dictionary.Add(property0.Name, array); + } + tagMap = dictionary; continue; } } - return new EffectiveNetworkSecurityGroup(networkSecurityGroup, association.Value, Optional.ToList(effectiveSecurityRules), tagMap.Value); + return new EffectiveNetworkSecurityGroup(networkSecurityGroup, association.Value, Optional.ToList(effectiveSecurityRules), Optional.ToDictionary(tagMap)); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.cs index dd39ddb989523..1b7cef0f1d4a2 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.cs +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/EffectiveNetworkSecurityGroup.cs @@ -18,19 +18,20 @@ public partial class EffectiveNetworkSecurityGroup internal EffectiveNetworkSecurityGroup() { EffectiveSecurityRules = new ChangeTrackingList(); + TagToIPAddresses = new ChangeTrackingDictionary>(); } /// Initializes a new instance of EffectiveNetworkSecurityGroup. /// The ID of network security group that is applied. /// Associated resources. /// A collection of effective security rules. - /// Mapping of tags to list of IP Addresses included within the tag. - internal EffectiveNetworkSecurityGroup(WritableSubResource networkSecurityGroup, EffectiveNetworkSecurityGroupAssociation association, IReadOnlyList effectiveSecurityRules, string tagMap) + /// Mapping of tags to list of IP Addresses included within the tag. + internal EffectiveNetworkSecurityGroup(WritableSubResource networkSecurityGroup, EffectiveNetworkSecurityGroupAssociation association, IReadOnlyList effectiveSecurityRules, IReadOnlyDictionary> tagToIPAddresses) { NetworkSecurityGroup = networkSecurityGroup; Association = association; EffectiveSecurityRules = effectiveSecurityRules; - TagMap = tagMap; + TagToIPAddresses = tagToIPAddresses; } /// The ID of network security group that is applied. @@ -46,6 +47,6 @@ public ResourceIdentifier NetworkSecurityGroupId /// A collection of effective security rules. public IReadOnlyList EffectiveSecurityRules { get; } /// Mapping of tags to list of IP Addresses included within the tag. - public string TagMap { get; } + public IReadOnlyDictionary> TagToIPAddresses { get; } } } diff --git a/sdk/network/Azure.ResourceManager.Network/src/autorest.md b/sdk/network/Azure.ResourceManager.Network/src/autorest.md index d5b87da0f8daf..c593c48137282 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/autorest.md +++ b/sdk/network/Azure.ResourceManager.Network/src/autorest.md @@ -100,6 +100,7 @@ rename-mapping: EndpointType: ConnectionMonitorEndpointType ConnectionState: NetworkConnectionState ApplicationGatewayAvailableSslOptions: ApplicationGatewayAvailableSslOptionsInfo + EffectiveNetworkSecurityGroup.tagMap: tagToIPAddresses format-by-name-rules: 'tenantId': 'uuid' @@ -382,6 +383,9 @@ directive: transform: > $.ResourceNavigationLinkFormat.properties.link['x-ms-format'] = 'arm-id'; $.ServiceAssociationLinkPropertiesFormat.properties.link['x-ms-format'] = 'arm-id'; + - from: networkInterface.json # a temporary fix for issue https://github.com/Azure/azure-sdk-for-net/issues/34094 + where: $.definitions.EffectiveNetworkSecurityGroup.properties.tagMap.type + transform: return "object"; ``` ### Tag: package-track2-preview