Skip to content

Commit dc6b3b6

Browse files
committed
feedback
1 parent 6004600 commit dc6b3b6

File tree

4 files changed

+74
-52
lines changed

4 files changed

+74
-52
lines changed

src/ResourceManager/Network/Commands.Network/NetworkInterface/NewAzureNetworkInterfaceCommand.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,6 @@ public class NewAzureNetworkInterfaceCommand : NetworkInterfaceBaseCmdlet
6666
[ValidateNotNullOrEmpty]
6767
public List<PSNetworkInterfaceIPConfiguration> IpConfiguration { get; set; }
6868

69-
//[Parameter(
70-
// Mandatory = true,
71-
// ValueFromPipelineByPropertyName = true,
72-
// ParameterSetName = "SetByIpConfigurationResourceId",
73-
// HelpMessage = "List of IpConfigurations")]
74-
//public List<PSNetworkInterfaceTapConfiguration> TapConfigurationId { get; set; }
75-
76-
//[Parameter(
77-
// Mandatory = true,
78-
// ValueFromPipelineByPropertyName = true,
79-
// ParameterSetName = "SetByResource",
80-
// HelpMessage = "List of IpConfigurations")]
81-
//[ValidateNotNullOrEmpty]
82-
//public List<PSNetworkInterfaceTapConfiguration> TapConfiguration { get; set; }
83-
8469
[Parameter(
8570
Mandatory = true,
8671
ValueFromPipelineByPropertyName = true,
@@ -299,23 +284,6 @@ private PSNetworkInterface CreateNetworkInterface()
299284
{
300285
this.NetworkSecurityGroupId = this.NetworkSecurityGroup.Id;
301286
}
302-
303-
//if (TapConfigurationId != null &&
304-
// TapConfigurationId.Count > 0)
305-
//{
306-
// if (TapConfiguration != null)
307-
// {
308-
// TapConfiguration = new List<PSNetworkInterfaceTapConfiguration>();
309-
// }
310-
311-
// foreach (PSNetworkInterfaceTapConfiguration tapConfiguration in TapConfigurationId)
312-
// {
313-
// var nicTapConfiguration = new PSNetworkInterfaceTapConfiguration();
314-
// nicTapConfiguration.Id = tapConfiguration.Id;
315-
316-
// TapConfiguration.Add(nicTapConfiguration);
317-
// }
318-
//}
319287
}
320288
}
321289
else
@@ -453,11 +421,6 @@ private PSNetworkInterface CreateNetworkInterface()
453421
networkInterface.NetworkSecurityGroup.Id = this.NetworkSecurityGroupId;
454422
}
455423

456-
//if (this.TapConfiguration != null)
457-
//{
458-
// networkInterface.TapConfigurations = TapConfiguration;
459-
//}
460-
461424
var networkInterfaceModel = NetworkResourceManagerProfile.Mapper.Map<MNM.NetworkInterface>(networkInterface);
462425

463426
this.NullifyApplicationSecurityGroupIfAbsent(networkInterfaceModel);

src/ResourceManager/Network/Commands.Network/NetworkInterface/TapConfiguration/RemoveAzureRmNetworkInterfaceTapConfigCommand.cs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
using System.Linq;
1717
using System.Management.Automation;
1818
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
19+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
20+
using System;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1922

2023
namespace Microsoft.Azure.Commands.Network
2124
{
22-
[Cmdlet(VerbsCommon.Remove, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "NetworkInterfaceTapConfig", SupportsShouldProcess = true), OutputType(typeof(PSNetworkInterface))]
25+
[Cmdlet(VerbsCommon.Remove, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "NetworkInterfaceTapConfig", SupportsShouldProcess = true, DefaultParameterSetName = "RemoveByNameParameterSet"), OutputType(typeof(PSNetworkInterface))]
2326
public partial class RemoveAzureRmNetworkInterfaceTapConfigCommand : NetworkInterfaceTapConfigBase
2427
{
2528
[Parameter(
2629
Mandatory = true,
30+
ParameterSetName = "RemoveByNameParameterSet",
2731
ValueFromPipelineByPropertyName = true,
2832
HelpMessage = "The resource group name.")]
2933
[ResourceGroupCompleter]
@@ -32,18 +36,37 @@ public partial class RemoveAzureRmNetworkInterfaceTapConfigCommand : NetworkInte
3236

3337
[Parameter(
3438
Mandatory = true,
39+
ParameterSetName = "RemoveByNameParameterSet",
3540
ValueFromPipelineByPropertyName = true,
3641
HelpMessage = "The virtual network name.")]
3742
[ValidateNotNullOrEmpty]
3843
public string NetworkInterfaceName { get; set; }
3944

4045
[Parameter(
4146
Mandatory = true,
47+
ParameterSetName = "RemoveByNameParameterSet",
4248
ValueFromPipelineByPropertyName = true,
4349
HelpMessage = "The virtual network peering name.")]
4450
[ValidateNotNullOrEmpty]
4551
public string Name { get; set; }
4652

53+
[Parameter(
54+
Mandatory = true,
55+
ValueFromPipelineByPropertyName = true,
56+
ParameterSetName = "DeleteByResourceIdParameterSet")]
57+
[ValidateNotNullOrEmpty]
58+
public virtual string ResourceId { get; set; }
59+
60+
[Parameter(
61+
Mandatory = true,
62+
ValueFromPipeline = true,
63+
ParameterSetName = "DeleteByInputObjectParameterSet")]
64+
[ValidateNotNullOrEmpty]
65+
public PSNetworkInterfaceTapConfiguration InputObject
66+
{
67+
get; set;
68+
}
69+
4770
[Parameter(
4871
Mandatory = false,
4972
HelpMessage = "Do not ask for confirmation.")]
@@ -54,6 +77,21 @@ public partial class RemoveAzureRmNetworkInterfaceTapConfigCommand : NetworkInte
5477

5578
public override void Execute()
5679
{
80+
if (this.IsParameterBound(c => c.InputObject))
81+
{
82+
this.ResourceGroupName = this.InputObject.ResourceGroupName;
83+
this.Name = this.InputObject.Name;
84+
this.NetworkInterfaceName = this.InputObject.NetworkInterfaceName;
85+
}
86+
87+
if (ParameterSetName.Equals("DeleteByResourceIdParameterSet", StringComparison.OrdinalIgnoreCase))
88+
{
89+
var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
90+
this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
91+
this.NetworkInterfaceName = resourceIdentifier.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
92+
this.Name = resourceIdentifier.ResourceName;
93+
}
94+
5795
base.Execute();
5896
ConfirmAction(
5997
Force.IsPresent,

src/ResourceManager/Network/Commands.Network/NetworkInterface/TapConfiguration/SetAzureRmNetworkInterfaceTapConfigCommand.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ public override void Execute()
6363
// Map to the sdk object
6464
var tapConfigModel = NetworkResourceManagerProfile.Mapper.Map<MNM.NetworkInterfaceTapConfiguration>(this.NetworkInterfaceTapConfig);
6565

66-
//var remoteVirtualNetworkTap = this.NetworkInterfaceTapConfig.VirtualNetworkTap;
67-
//Dictionary<string, List<string>> auxAuthHeader = null;
68-
//if (remoteVirtualNetworkTap != null)
69-
//{
70-
// List<string> resourceIds = new List<string>();
71-
// resourceIds.Add(remoteVirtualNetworkTap.Id);
72-
// var auxHeaderDictionary = GetAuxilaryAuthHeaderFromResourceIds(resourceIds);
73-
// if (auxHeaderDictionary != null && auxHeaderDictionary.Count > 0)
74-
// {
75-
// auxAuthHeader = new Dictionary<string, List<string>>(auxHeaderDictionary);
76-
// }
77-
//}
78-
7966
// Execute the Create VirtualNetwork call
8067
this.NetworkInterfaceTapClient.CreateOrUpdateWithHttpMessagesAsync(this.NetworkInterfaceTapConfig.ResourceGroupName, this.NetworkInterfaceTapConfig.NetworkInterfaceName, this.NetworkInterfaceTapConfig.Name, tapConfigModel).GetAwaiter().GetResult();
8168
var getTapconfig = this.GetNetworkInterfaceTapConfiguration(this.NetworkInterfaceTapConfig.ResourceGroupName, this.NetworkInterfaceTapConfig.NetworkInterfaceName, this.NetworkInterfaceTapConfig.Name);

src/ResourceManager/Network/Commands.Network/VirtualNetworkTap/RemoveAzureRmVirtualNetworkTapCommand.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222
using System.Management.Automation;
2323
using AutoMapper;
2424
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
25+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
26+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2527

2628
namespace Microsoft.Azure.Commands.Network
2729
{
28-
[Cmdlet(VerbsCommon.Remove, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkTap", SupportsShouldProcess = true), OutputType(typeof(bool))]
30+
[Cmdlet(VerbsCommon.Remove, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkTap", SupportsShouldProcess = true, DefaultParameterSetName = "RemoveByNameParameterSet"), OutputType(typeof(bool))]
2931
public partial class RemoveAzureRmVirtualNetworkTap : NetworkBaseCmdlet
3032
{
3133
[Parameter(
3234
Mandatory = true,
35+
ParameterSetName = "RemoveByNameParameterSet",
3336
HelpMessage = "The resource group name of the virtual network tap.",
3437
ValueFromPipelineByPropertyName = true)]
3538
[ResourceGroupCompleter]
@@ -38,11 +41,29 @@ public partial class RemoveAzureRmVirtualNetworkTap : NetworkBaseCmdlet
3841

3942
[Parameter(
4043
Mandatory = true,
44+
ParameterSetName = "RemoveByNameParameterSet",
4145
HelpMessage = "The name of the tap.",
4246
ValueFromPipelineByPropertyName = true)]
4347
[ValidateNotNullOrEmpty]
4448
public string Name { get; set; }
4549

50+
[Parameter(
51+
Mandatory = true,
52+
ValueFromPipelineByPropertyName = true,
53+
ParameterSetName = "DeleteByResourceIdParameterSet")]
54+
[ValidateNotNullOrEmpty]
55+
public virtual string ResourceId { get; set; }
56+
57+
[Parameter(
58+
Mandatory = true,
59+
ValueFromPipeline = true,
60+
ParameterSetName = "DeleteByInputObjectParameterSet")]
61+
[ValidateNotNullOrEmpty]
62+
public PSVirtualNetworkTap InputObject
63+
{
64+
get; set;
65+
}
66+
4667
[Parameter(
4768
Mandatory = false,
4869
HelpMessage = "Do not ask for confirmation if you want to delete resource")]
@@ -57,6 +78,19 @@ public partial class RemoveAzureRmVirtualNetworkTap : NetworkBaseCmdlet
5778

5879
public override void Execute()
5980
{
81+
if (this.IsParameterBound(c => c.InputObject))
82+
{
83+
this.ResourceGroupName = this.InputObject.ResourceGroupName;
84+
this.Name = this.InputObject.Name;
85+
}
86+
87+
if (this.IsParameterBound(c => c.ResourceId))
88+
{
89+
var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
90+
this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
91+
this.Name = resourceIdentifier.ResourceName;
92+
}
93+
6094
base.Execute();
6195

6296
ConfirmAction(

0 commit comments

Comments
 (0)