Skip to content

Commit aef2edd

Browse files
committed
Changes based on code review
1 parent 01e2e4e commit aef2edd

File tree

8 files changed

+2255
-1259
lines changed

8 files changed

+2255
-1259
lines changed

src/ResourceManager/Network/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
## Current Release
2121

2222
## Version 4.4.1
23+
* Added cmdlet to list available internet service providers for a specified Azure region
24+
- Get-AzureRmNetworkWatcherReachabilityProvidersList
25+
* Added cmdlet to get the relative latency score for internet service providers from a specified location to Azure regions
26+
- Get-AzureRmNetworkWatcherReachabilityReport
2327

2428
## Version 4.4.0
2529
* Added support for endpoint services to Virtual Network Subnets

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkWatcherAPITests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,9 @@ function Test-ReachabilityReport
640640
$tags = @{"key1" = "value1"; "key2" = "value2"}
641641
$nw = New-AzureRmNetworkWatcher -Name $nwName -ResourceGroupName $rgname -Location $location -Tag $tags
642642

643-
$report1 = Get-AzureRmNetworkWatcherReachabilityReport -NetworkWatcher $nw -AzureLocations "West US" -Country "United States" -StartTime "2017-10-05" -EndTime "2017-10-10"
644-
$report2 = Get-AzureRmNetworkWatcherReachabilityReport -NetworkWatcher $nw -AzureLocations "West US" -Country "United States" -State "washington" -StartTime "2017-10-05" -EndTime "2017-10-10"
645-
$report3 = Get-AzureRmNetworkWatcherReachabilityReport -NetworkWatcher $nw -AzureLocations "West US" -Country "United States" -State "washington" -City "seattle" -StartTime "2017-10-05" -EndTime "2017-10-10"
643+
$report1 = Get-AzureRmNetworkWatcherReachabilityReport -NetworkWatcher $nw -Location "West US" -Country "United States" -StartTime "2017-10-05" -EndTime "2017-10-10"
644+
$report2 = Get-AzureRmNetworkWatcherReachabilityReport -NetworkWatcher $nw -Location "West US" -Country "United States" -State "washington" -StartTime "2017-10-05" -EndTime "2017-10-10"
645+
$report3 = Get-AzureRmNetworkWatcherReachabilityReport -NetworkWatcher $nw -Location "West US" -Country "United States" -State "washington" -City "seattle" -StartTime "2017-10-05" -EndTime "2017-10-10"
646646

647647
Assert-AreEqual $report1.AggregationLevel "Country"
648648
Assert-AreEqual $report1.ProviderLocation.Country "United States"
@@ -683,9 +683,9 @@ function Test-ProvidersList
683683
$tags = @{"key1" = "value1"; "key2" = "value2"}
684684
$nw = New-AzureRmNetworkWatcher -Name $nwName -ResourceGroupName $rgname -Location $location -Tag $tags
685685

686-
$list1 = Get-AzureRmNetworkWatcherReachabilityProvidersList -NetworkWatcher $nw -AzureLocations "West US" -Country "United States"
687-
$list2 = Get-AzureRmNetworkWatcherReachabilityProvidersList -NetworkWatcher $nw -AzureLocations "West US" -Country "United States" -State "washington"
688-
$list3 = Get-AzureRmNetworkWatcherReachabilityProvidersList -NetworkWatcher $nw -AzureLocations "West US" -Country "United States" -State "washington" -City "seattle"
686+
$list1 = Get-AzureRmNetworkWatcherReachabilityProvidersList -NetworkWatcher $nw -Location "West US" -Country "United States"
687+
$list2 = Get-AzureRmNetworkWatcherReachabilityProvidersList -NetworkWatcher $nw -Location "West US" -Country "United States" -State "washington"
688+
$list3 = Get-AzureRmNetworkWatcherReachabilityProvidersList -NetworkWatcher $nw -Location "West US" -Country "United States" -State "washington" -City "seattle"
689689

690690
Assert-AreEqual $list1.Countries.CountryName "United States"
691691
Assert-AreEqual $list2.Countries.CountryName "United States"

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkWatcherAPITests/TestProvidersList.json

Lines changed: 143 additions & 1058 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkWatcherAPITests/TestReachabilityReport.json

Lines changed: 1502 additions & 153 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network/NetworkWatcher/GetAzureNetworkWatcherReachabilityProvidersListCommand.cs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@
2020
// code is regenerated.
2121

2222
using Microsoft.Azure.Commands.Network.Models;
23+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2324
using Microsoft.Azure.Management.Network;
2425
using Microsoft.Azure.Management.Network.Models;
2526
using System;
26-
using System.Collections;
2727
using System.Collections.Generic;
28-
using System.Linq;
2928
using System.Management.Automation;
30-
using AutoMapper;
31-
using CNM = Microsoft.Azure.Commands.Network.Models;
3229

3330
namespace Microsoft.Azure.Commands.Network.Automation
3431
{
35-
[Cmdlet(VerbsCommon.Get, "AzureRmNetworkWatcherReachabilityProvidersList", DefaultParameterSetName = "SetByResource"), OutputType(typeof(PSAvailableProvidersList))]
32+
[Cmdlet(VerbsCommon.Get, "AzureRmNetworkWatcherReachabilityProvidersList", DefaultParameterSetName = "SetByName"), OutputType(typeof(PSAvailableProvidersList))]
3633
public class GetAzureRmNetworkWatcherAvailableProviders : NetworkBaseCmdlet
3734
{
3835
[Parameter(
@@ -46,30 +43,33 @@ public class GetAzureRmNetworkWatcherAvailableProviders : NetworkBaseCmdlet
4643
[Parameter(
4744
Mandatory = true,
4845
HelpMessage = "The name of network watcher.",
49-
ParameterSetName = "SetByName",
50-
ValueFromPipeline = true,
51-
ValueFromPipelineByPropertyName = true)]
46+
ParameterSetName = "SetByName")]
5247
[ValidateNotNullOrEmpty]
5348
public string NetworkWatcherName { get; set; }
5449

5550
[Parameter(
5651
Mandatory = true,
5752
HelpMessage = "The name of the network watcher resource group.",
58-
ParameterSetName = "SetByName",
59-
ValueFromPipelineByPropertyName = true)]
53+
ParameterSetName = "SetByName")]
6054
[ValidateNotNullOrEmpty]
6155
public string ResourceGroupName { get; set; }
6256

57+
[Parameter(
58+
Mandatory = true,
59+
ValueFromPipelineByPropertyName = true,
60+
HelpMessage = "The Id of network watcher resource.",
61+
ParameterSetName = "SetByResourceId")]
62+
public string ResourceId { get; set; }
63+
6364
[Parameter(
6465
Mandatory = false,
6566
HelpMessage = "Optional Azure regions to scope the query to.",
6667
ValueFromPipelineByPropertyName = true)]
67-
public List<string> AzureLocations { get; set; }
68+
public List<string> Location { get; set; }
6869

6970
[Parameter(
7071
Mandatory = false,
71-
HelpMessage = "The name of the country.",
72-
ValueFromPipelineByPropertyName = true)]
72+
HelpMessage = "The name of the country.")]
7373
public string Country { get; set; }
7474

7575
[Parameter(
@@ -80,8 +80,7 @@ public class GetAzureRmNetworkWatcherAvailableProviders : NetworkBaseCmdlet
8080

8181
[Parameter(
8282
Mandatory = false,
83-
HelpMessage = "The name of the city.",
84-
ValueFromPipelineByPropertyName = true)]
83+
HelpMessage = "The name of the city.")]
8584
public string City { get; set; }
8685

8786
public override void Execute()
@@ -90,17 +89,25 @@ public override void Execute()
9089

9190
var vAvailableProvidersListParameters = new AvailableProvidersListParameters
9291
{
93-
AzureLocations = this.AzureLocations,
92+
AzureLocations = this.Location,
9493
Country = this.Country,
9594
State = this.State,
9695
City = this.City,
9796
};
9897

99-
if (ParameterSetName.Contains("SetByResource"))
98+
if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase))
10099
{
101100
ResourceGroupName = this.NetworkWatcher.ResourceGroupName;
102101
NetworkWatcherName = this.NetworkWatcher.Name;
103102
}
103+
104+
if (string.Equals(this.ParameterSetName, "SetByResourceId", StringComparison.OrdinalIgnoreCase))
105+
{
106+
var resourceInfo = new ResourceIdentifier(this.ResourceId);
107+
ResourceGroupName = resourceInfo.ResourceGroupName;
108+
NetworkWatcherName = resourceInfo.ResourceName;
109+
}
110+
104111
var vNetworkWatcherResult = this.NetworkClient.NetworkManagementClient.NetworkWatchers.ListAvailableProviders(ResourceGroupName, NetworkWatcherName, vAvailableProvidersListParameters);
105112
var vNetworkWatcherModel = NetworkResourceManagerProfile.Mapper.Map<PSAvailableProvidersList>(vNetworkWatcherResult);
106113
WriteObject(vNetworkWatcherModel);

src/ResourceManager/Network/Commands.Network/NetworkWatcher/GetAzureRMNetworkWatcherReachabilityReportCommand.cs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// code is regenerated.
2121

2222
using Microsoft.Azure.Commands.Network.Models;
23+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2324
using Microsoft.Azure.Management.Network;
2425
using Microsoft.Azure.Management.Network.Models;
2526
using System;
@@ -33,7 +34,7 @@
3334

3435
namespace Microsoft.Azure.Commands.Network.Automation
3536
{
36-
[Cmdlet(VerbsCommon.Get, "AzureRMNetworkWatcherReachabilityReport", DefaultParameterSetName = "SetByResource"), OutputType(typeof(PSAzureReachabilityReport))]
37+
[Cmdlet(VerbsCommon.Get, "AzureRMNetworkWatcherReachabilityReport", DefaultParameterSetName = "SetByName"), OutputType(typeof(PSAzureReachabilityReport))]
3738
public partial class GetAzureRMNetworkWatcherReachabilityReport : NetworkBaseCmdlet
3839
{
3940
[Parameter(
@@ -47,61 +48,58 @@ public partial class GetAzureRMNetworkWatcherReachabilityReport : NetworkBaseCmd
4748
[Parameter(
4849
Mandatory = true,
4950
HelpMessage = "The name of network watcher.",
50-
ParameterSetName = "SetByName",
51-
ValueFromPipeline = true,
52-
ValueFromPipelineByPropertyName = true)]
51+
ParameterSetName = "SetByName")]
5352
[ValidateNotNullOrEmpty]
5453
public string NetworkWatcherName { get; set; }
5554

5655

5756
[Parameter(
5857
Mandatory = true,
5958
HelpMessage = "The name of the network watcher resource group.",
60-
ParameterSetName = "SetByName",
61-
ValueFromPipelineByPropertyName = true)]
59+
ParameterSetName = "SetByName")]
6260
[ValidateNotNullOrEmpty]
6361
public string ResourceGroupName { get; set; }
6462

63+
[Parameter(
64+
Mandatory = true,
65+
ValueFromPipelineByPropertyName = true,
66+
HelpMessage = "The Id of network watcher resource.",
67+
ParameterSetName = "SetByResourceId")]
68+
public string ResourceId { get; set; }
69+
6570
[Parameter(
6671
Mandatory = false,
67-
HelpMessage = "List of Internet service providers.",
68-
ValueFromPipelineByPropertyName = true)]
69-
public List<string> Providers { get; set; }
72+
HelpMessage = "List of Internet service providers.")]
73+
public List<string> Provider { get; set; }
7074

7175
[Parameter(
7276
Mandatory = false,
73-
HelpMessage = "Optional Azure regions to scope the query to.",
74-
ValueFromPipelineByPropertyName = true)]
75-
public List<string> AzureLocations { get; set; }
77+
HelpMessage = "Optional Azure regions to scope the query to.")]
78+
public List<string> Location { get; set; }
7679

7780
[Parameter(
7881
Mandatory = true,
79-
HelpMessage = "The start time for the Azure reachability report.",
80-
ValueFromPipelineByPropertyName = true)]
82+
HelpMessage = "The start time for the Azure reachability report.")]
8183
public DateTime StartTime { get; set; }
8284

8385
[Parameter(
8486
Mandatory = true,
85-
HelpMessage = "The end time for the Azure reachability report.",
86-
ValueFromPipelineByPropertyName = true)]
87+
HelpMessage = "The end time for the Azure reachability report.")]
8788
public DateTime EndTime { get; set; }
8889

8990
[Parameter(
9091
Mandatory = false,
91-
HelpMessage = "The name of the country.",
92-
ValueFromPipelineByPropertyName = true)]
92+
HelpMessage = "The name of the country.")]
9393
public string Country { get; set; }
9494

9595
[Parameter(
9696
Mandatory = false,
97-
HelpMessage = "The name of the state.",
98-
ValueFromPipelineByPropertyName = true)]
97+
HelpMessage = "The name of the state.")]
9998
public string State { get; set; }
10099

101100
[Parameter(
102101
Mandatory = false,
103-
HelpMessage = "The name of the city.",
104-
ValueFromPipelineByPropertyName = true)]
102+
HelpMessage = "The name of the city.")]
105103
public string City { get; set; }
106104

107105
public override void Execute()
@@ -140,18 +138,26 @@ public override void Execute()
140138

141139
var vAzureReachabilityReportParameters = new AzureReachabilityReportParameters
142140
{
143-
Providers = this.Providers,
144-
AzureLocations = this.AzureLocations,
141+
Providers = this.Provider,
142+
AzureLocations = this.Location,
145143
StartTime = this.StartTime,
146144
EndTime = this.EndTime,
147145
ProviderLocation = NetworkResourceManagerProfile.Mapper.Map < MNM.AzureReachabilityReportLocation >(vProviderLocation),
148146
};
149147

150-
if (ParameterSetName.Contains("SetByResource"))
148+
if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase))
151149
{
152150
ResourceGroupName = this.NetworkWatcher.ResourceGroupName;
153151
NetworkWatcherName = this.NetworkWatcher.Name;
154152
}
153+
154+
if (string.Equals(this.ParameterSetName, "SetByResourceId", StringComparison.OrdinalIgnoreCase))
155+
{
156+
var resourceInfo = new ResourceIdentifier(this.ResourceId);
157+
ResourceGroupName = resourceInfo.ResourceGroupName;
158+
NetworkWatcherName = resourceInfo.ResourceName;
159+
}
160+
155161
var vNetworkWatcherResult = this.NetworkClient.NetworkManagementClient.NetworkWatchers.GetAzureReachabilityReport(ResourceGroupName, NetworkWatcherName, vAzureReachabilityReportParameters);
156162
var vNetworkWatcherModel = NetworkResourceManagerProfile.Mapper.Map<PSAzureReachabilityReport>(vNetworkWatcherResult);
157163
WriteObject(vNetworkWatcherModel);

0 commit comments

Comments
 (0)