Skip to content

Commit bdb97bf

Browse files
authored
Test removing automapper (#21135)
1 parent b9d947b commit bdb97bf

11 files changed

+37
-57
lines changed

src/Monitor/Monitor/Az.Monitor.psd1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ DotNetFrameworkVersion = '4.7.2'
5656
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.11.2'; })
5757

5858
# Assemblies that must be loaded prior to importing this module
59-
RequiredAssemblies = 'Microsoft.Azure.Management.Monitor.dll',
60-
'Microsoft.Azure.PowerShell.AutoMapper.dll',
59+
RequiredAssemblies = 'Microsoft.Azure.Management.Monitor.dll',
6160
'ActivityLogAlert.Autorest\bin\Az.ActivityLogAlert.private.dll',
6261
'DiagnosticSetting.Autorest\bin\Az.DiagnosticSetting.private.dll',
6362
'ScheduledQueryRule.Autorest\bin\Az.ScheduledQueryRule.private.dll',

src/Monitor/Monitor/Monitor.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.28.0-preview" />
15-
<PackageReference Include="Microsoft.Azure.PowerShell.AutoMapper" Version="6.2.2" />
1615
</ItemGroup>
1716

1817
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., build.proj))\src\Az.Post.props" />

src/Monitor/Monitor/OutputClasses/PSMonitorPrivateLinkScope.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System.Collections.Generic;
16+
using Microsoft.Azure.Management.Monitor.Models;
1617
using Newtonsoft.Json;
1718

1819
namespace Microsoft.Azure.Commands.Insights.OutputClasses
@@ -34,6 +35,19 @@ public PSMonitorPrivateLinkScope() { }
3435
this.ProvisioningState = provisioningState;
3536
}
3637

38+
internal static PSMonitorPrivateLinkScope ToPSMonitorPrivateLinkScope(AzureMonitorPrivateLinkScope scope)
39+
{
40+
return new PSMonitorPrivateLinkScope
41+
{
42+
Id = scope.Id,
43+
Name = scope.Name,
44+
Type = scope.Type,
45+
Location = scope.Location,
46+
Tags = scope.Tags,
47+
ProvisioningState = scope.ProvisioningState
48+
};
49+
}
50+
3751
/// <summary>
3852
/// Gets azure resource Id
3953
/// </summary>

src/Monitor/Monitor/OutputClasses/PSMonitorPrivateLinkScopedResource.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System.Collections.Generic;
16+
using System.Net.Mail;
17+
using Microsoft.Azure.Management.Monitor.Models;
1618
using Newtonsoft.Json;
1719

1820
namespace Microsoft.Azure.Commands.Insights.OutputClasses
@@ -57,5 +59,17 @@ public class PSMonitorPrivateLinkScopedResource
5759
/// </summary>
5860
[JsonProperty(PropertyName = "properties.provisioningState")]
5961
public string ProvisioningState { get; private set; }
62+
63+
internal static PSMonitorPrivateLinkScopedResource ToPSMonitorPrivateLinkScopedResource(ScopedResource scope)
64+
{
65+
return new PSMonitorPrivateLinkScopedResource
66+
{
67+
Id = scope.Id,
68+
Name = scope.Name,
69+
Type = scope.Type,
70+
LinkedResourceId = scope.LinkedResourceId,
71+
ProvisioningState = scope.ProvisioningState
72+
};
73+
}
6074
}
6175
}

src/Monitor/Monitor/PrivateLinkScopes/AzureInsightsPrivateLinkScopeCreateOrUpdateCmdletBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1818
using Microsoft.Azure.Management.Monitor.Models;
1919
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20-
using Microsoft.Azure.Commands.Insights.Utils;
2120
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2221
using System.Collections.Generic;
2322
using System.Linq;

src/Monitor/Monitor/PrivateLinkScopes/GetAzureInsightsPrivateLinkScope.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using Microsoft.Azure.Commands.Insights.OutputClasses;
1818
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1919
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20-
using Microsoft.Azure.Commands.Insights.Utils;
2120
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2221
using System.Linq;
2322

@@ -72,14 +71,14 @@ protected override void ProcessRecordInternal()
7271
.PrivateLinkScopes
7372
.ListByResourceGroupWithHttpMessagesAsync(this.ResourceGroupName)
7473
.Result;
75-
WriteObject(response.Body.Select(scope => PSMapper.Instance.Map<PSMonitorPrivateLinkScope>(scope)).ToList(), true);
74+
WriteObject(response.Body.Select(scope => PSMonitorPrivateLinkScope.ToPSMonitorPrivateLinkScope(scope)).ToList(), true);
7675
}
7776
else
7877
{
7978
var response = this.MonitorManagementClient
8079
.PrivateLinkScopes.ListWithHttpMessagesAsync()
8180
.Result;
82-
WriteObject(response.Body.Select(scope => PSMapper.Instance.Map<PSMonitorPrivateLinkScope>(scope)).ToList(), true);
81+
WriteObject(response.Body.Select(scope => PSMonitorPrivateLinkScope.ToPSMonitorPrivateLinkScope(scope)).ToList(), true);
8382
}
8483
}
8584
else if (ParameterSetName.Equals(ByResourceNameParameterSet) || ParameterSetName.Equals(ResourceId))
@@ -95,7 +94,7 @@ protected override void ProcessRecordInternal()
9594
.PrivateLinkScopes
9695
.GetWithHttpMessagesAsync(this.ResourceGroupName, this.Name)
9796
.Result;
98-
WriteObject(PSMapper.Instance.Map<PSMonitorPrivateLinkScope>(response.Body));
97+
WriteObject(PSMonitorPrivateLinkScope.ToPSMonitorPrivateLinkScope(response.Body));
9998
}
10099
}
101100
}

src/Monitor/Monitor/PrivateLinkScopes/GetAzureInsightsPrivateLinkScopedResource.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using Microsoft.Azure.Commands.Insights.OutputClasses;
1717
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1818
using Microsoft.WindowsAzure.Commands.Utilities.Common;
19-
using Microsoft.Azure.Commands.Insights.Utils;
2019
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2120
using System.Linq;
2221

@@ -98,15 +97,15 @@ protected override void ProcessRecordInternal()
9897
.PrivateLinkScopedResources
9998
.ListByPrivateLinkScopeWithHttpMessagesAsync(this.ResourceGroupName, this.ScopeName)
10099
.Result;
101-
WriteObject(response.Body.Select(scope => PSMapper.Instance.Map<PSMonitorPrivateLinkScopedResource>(scope)).ToList(), true);
100+
WriteObject(response.Body.Select(scope => PSMonitorPrivateLinkScopedResource.ToPSMonitorPrivateLinkScopedResource(scope)).ToList(), true);
102101
}
103102
else if (this.IsParameterBound(c => c.Name))
104103
{
105104
var response = this.MonitorManagementClient
106105
.PrivateLinkScopedResources
107106
.GetWithHttpMessagesAsync(this.ResourceGroupName, this.ScopeName, this.Name)
108107
.Result;
109-
WriteObject(PSMapper.Instance.Map<PSMonitorPrivateLinkScopedResource>(response.Body));
108+
WriteObject(PSMonitorPrivateLinkScopedResource.ToPSMonitorPrivateLinkScopedResource(response.Body));
110109
}
111110
}
112111
}

src/Monitor/Monitor/PrivateLinkScopes/NewAzureInsightsPrivateLinkScope.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.Management.Automation;
1717
using Microsoft.Azure.Commands.Insights.OutputClasses;
1818
using Microsoft.Azure.Management.Monitor.Models;
19-
using Microsoft.Azure.Commands.Insights.Utils;
2019
using System.Linq;
2120
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2221

@@ -67,7 +66,7 @@ protected override void ProcessRecordInternal()
6766
.PrivateLinkScopes
6867
.CreateOrUpdateWithHttpMessagesAsync(this.ResourceGroupName, this.Name, payLoad)
6968
.Result;
70-
WriteObject(PSMapper.Instance.Map<PSMonitorPrivateLinkScope>(response.Body));
69+
WriteObject(PSMonitorPrivateLinkScope.ToPSMonitorPrivateLinkScope(response.Body));
7170
}
7271
}
7372
}

src/Monitor/Monitor/PrivateLinkScopes/NewAzureInsightsPrivateLinkScopedResource.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System.Management.Automation;
1616
using Microsoft.Azure.Commands.Insights.OutputClasses;
1717
using Microsoft.WindowsAzure.Commands.Utilities.Common;
18-
using Microsoft.Azure.Commands.Insights.Utils;
1918
using Microsoft.Azure.Management.Monitor.Models;
2019

2120
namespace Microsoft.Azure.Commands.Insights.PrivateLinkScopes
@@ -56,7 +55,7 @@ protected override void ProcessRecordInternal()
5655
.PrivateLinkScopedResources
5756
.CreateOrUpdateWithHttpMessagesAsync(this.ResourceGroupName, this.ScopeName, this.Name, this.LinkedResourceId)
5857
.Result;
59-
WriteObject(PSMapper.Instance.Map<PSMonitorPrivateLinkScopedResource>(response.Body));
58+
WriteObject(PSMonitorPrivateLinkScopedResource.ToPSMonitorPrivateLinkScopedResource(response.Body));
6059
}
6160
}
6261

src/Monitor/Monitor/PrivateLinkScopes/UpdateAzureInsightsPrivateLinkScope.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1818
using Microsoft.Azure.Management.Monitor.Models;
1919
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20-
using Microsoft.Azure.Commands.Insights.Utils;
2120
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2221
using System.Collections.Generic;
2322
using System.Linq;
@@ -71,7 +70,7 @@ protected override void ProcessRecordInternal()
7170
.PrivateLinkScopes
7271
.UpdateTagsWithHttpMessagesAsync(this.ResourceGroupName, this.Name, this.Tags.ToDictionary(s => s.Split(':')[0], s => s.Split(':')[1]))
7372
.Result;
74-
WriteObject(PSMapper.Instance.Map<PSMonitorPrivateLinkScope>(response.Body));
73+
WriteObject(PSMonitorPrivateLinkScope.ToPSMonitorPrivateLinkScope(response.Body));
7574
}
7675
}
7776
}

0 commit comments

Comments
 (0)