Skip to content

Commit

Permalink
Fixed bug in New-AzConnectionMonitorEndpoint cmdlet. Updated help file (
Browse files Browse the repository at this point in the history
Azure#13001)

* Fixed bug in New-AzConnectionMonitorEndpoint cmdlet. Updated help file

* Fixed typo and add online version in help file
  • Loading branch information
irrogozh authored Sep 18, 2020
1 parent 0dd8333 commit a586571
Show file tree
Hide file tree
Showing 2 changed files with 270 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,127 @@ namespace Microsoft.Azure.Commands.Network
public class NewAzureNetworkWatcherConnectionMonitorEndpointObjectCommand : ConnectionMonitorBaseCmdlet
{
[Parameter(
Mandatory = false,
Mandatory = true,
HelpMessage = "The name of the connection monitor endpoint.")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "The type of the connection monitor endpoint. Supported types are AzureVM, AzureVNet, AzureSubnet, ExternalAddress, MMAWorkspaceMachine, MMAWorkspaceNetwork.")]
[ValidateNotNullOrEmpty]
[PSArgumentCompleter("AzureVM", "AzureVNet", "AzureSubnet", "ExternalAddress", "MMAWorkspaceMachine", "MMAWorkspaceNetwork")]
public string Type { get; set; }
HelpMessage = "Azure VM endpoint switch.",
ParameterSetName = "AzureVM")]
public SwitchParameter AzureVM { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "Azure Vnet endpoint switch.",
ParameterSetName = "AzureVNet")]
public SwitchParameter AzureVNet { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "Azure Subnet endpoint switch.",
ParameterSetName = "AzureSubnet")]
public SwitchParameter AzureSubnet { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "External Address endpoint switch.",
ParameterSetName = "ExternalAddress")]
public SwitchParameter ExternalAddress { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "MMA Workspace Machine endpoint switch.",
ParameterSetName = "MMAWorkspaceMachine")]
public SwitchParameter MMAWorkspaceMachine { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "MMA Workspace Network endpoint switch.",
ParameterSetName = "MMAWorkspaceNetwork")]
public SwitchParameter MMAWorkspaceNetwork { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "Resource ID of the connection monitor endpoint.",
ParameterSetName = "AzureVM")]
[Parameter(
Mandatory = true,
HelpMessage = "Resource ID of the connection monitor endpoint.",
ParameterSetName = "AzureVNet")]
[Parameter(
Mandatory = true,
HelpMessage = "Resource ID of the connection monitor endpoint.",
ParameterSetName = "SetByResourceId")]
ParameterSetName = "AzureSubnet")]
[Parameter(
Mandatory = true,
HelpMessage = "Resource ID of the connection monitor endpoint.",
ParameterSetName = "MMAWorkspaceMachine")]
[Parameter(
Mandatory = true,
HelpMessage = "Resource ID of the connection monitor endpoint.",
ParameterSetName = "MMAWorkspaceNetwork")]
[ValidateNotNullOrEmpty]
public string ResourceId { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "Address of the connection monitor endpoint (IP or domain name).",
ParameterSetName = "ExternalAddress")]
[Parameter(
Mandatory = true,
HelpMessage = "Address of the connection monitor endpoint (IP or domain name).",
ParameterSetName = "MMAWorkspaceMachine")]
[Parameter(
Mandatory = false,
HelpMessage = "Address of the connection monitor endpoint (IP or domain name).",
ParameterSetName = "SetByAddress")]
ParameterSetName = "AzureVM")]
[ValidateNotNullOrEmpty]
public string Address { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of items which need to be included into endpont scope.",
ParameterSetName = "SetByResourceId")]
ParameterSetName = "AzureVNet")]
[Parameter(
Mandatory = false,
HelpMessage = "List of items which need to be included into endpont scope.",
ParameterSetName = "MMAWorkspaceMachine")]
[Parameter(
Mandatory = true,
HelpMessage = "List of items which need to be included into endpont scope.",
ParameterSetName = "MMAWorkspaceNetwork")]
[ValidateNotNullOrEmpty]
public PSNetworkWatcherConnectionMonitorEndpointScopeItem[] IncludeItem { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "List of items which need to be excluded from endpoint scope.",
ParameterSetName = "SetByResourceId")]
ParameterSetName = "AzureVNet")]
[Parameter(
Mandatory = false,
HelpMessage = "List of items which need to be excluded from endpoint scope.",
ParameterSetName = "AzureSubnet")]
[Parameter(
Mandatory = false,
HelpMessage = "List of items which need to be excluded from endpoint scope.",
ParameterSetName = "MMAWorkspaceNetwork")]
[ValidateNotNullOrEmpty]
public PSNetworkWatcherConnectionMonitorEndpointScopeItem[] ExcludeItem { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Test coverage for the endpoint. Supported values are Default, Low, BelowAverage, Average, AboveAvergae, Full.")]
HelpMessage = "Test coverage for the endpoint. Supported values are Default, Low, BelowAverage, Average, AboveAverage, Full.",
ParameterSetName = "AzureVNet")]
[Parameter(
Mandatory = false,
HelpMessage = "Test coverage for the endpoint. Supported values are Default, Low, BelowAverage, Average, AboveAverage, Full.",
ParameterSetName = "AzureSubnet")]
[Parameter(
Mandatory = false,
HelpMessage = "Test coverage for the endpoint. Supported values are Default, Low, BelowAverage, Average, AboveAverage, Full.",
ParameterSetName = "MMAWorkspaceNetwork")]
[ValidateNotNullOrEmpty]
[PSArgumentCompleter("Default", "Low", "BelowAverage", "Average", "AboveAverage", "Full")]
public string CoverageLevel { get; set; }
Expand All @@ -76,24 +154,10 @@ public override void Execute()
{
base.Execute();

if (string.IsNullOrEmpty(this.Name))
{
if (!string.IsNullOrEmpty(this.ResourceId))
{
string[] SplittedName = ResourceId.Split('/');
// Name is in the form resourceName(ResourceGroupName)
this.Name = SplittedName[8] + "(" + SplittedName[4] + ")";
}
else if (!string.IsNullOrEmpty(this.Address))
{
this.Name = this.Address;
}
}

PSNetworkWatcherConnectionMonitorEndpointObject endpoint = new PSNetworkWatcherConnectionMonitorEndpointObject()
{
Name = this.Name,
Type = this.Type,
Type = this.GetEndpointType(),
ResourceId = this.ResourceId,
Address = this.Address,
CoverageLevel = this.CoverageLevel
Expand Down Expand Up @@ -132,5 +196,35 @@ public override void Execute()

WriteObject(endpoint);
}

private string GetEndpointType()
{
if (AzureVM.IsPresent)
{
return "AzureVM";
}
else if (AzureVNet.IsPresent)
{
return "AzureVNet";
}
else if (AzureSubnet.IsPresent)
{
return "AzureSubnet";
}
else if (ExternalAddress.IsPresent)
{
return "ExternalAddress";
}
else if (MMAWorkspaceMachine.IsPresent)
{
return "MMAWorkspaceMachine";
}
else if (MMAWorkspaceNetwork.IsPresent)
{
return "MMAWorkspaceNetwork";
}

return string.Empty;
}
}
}
Loading

0 comments on commit a586571

Please sign in to comment.