Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace Microsoft.Azure.Commands.Network
{
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "PrivateEndpointConnection", DefaultParameterSetName = "ByResourceId"), OutputType(typeof(PSPrivateEndpointConnection))]
public class GetAzurePrivateEndpointConnection : PrivateEndpointConnectionBaseCmdlet
public class GetAzurePrivateEndpointConnection : PrivateEndpointConnectionBaseCmdlet, IDynamicParameters
{
[Parameter(
Mandatory = true,
Expand Down Expand Up @@ -60,6 +60,11 @@ public override void Execute()
this.PrivateLinkResourceType = resourceIdentifier.ResourceType;
this.ServiceName = resourceIdentifier.ResourceName;
}
else if (this.IsParameterBound(c => c.PrivateLinkResourceType))
{
this.Subscription = DefaultProfile.DefaultContext.Subscription.Id;
this.PrivateLinkResourceType = DynamicParameters[privateEndpointTypeName].Value as string;
}

IPrivateLinkProvider provider = BuildProvider(this.Subscription, this.PrivateLinkResourceType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Microsoft.Azure.Commands.Network
{
public abstract class PrivateEndpointConnectionBaseCmdlet : NetworkBaseCmdlet
public abstract class PrivateEndpointConnectionBaseCmdlet : NetworkBaseCmdlet, IDynamicParameters
{
[Parameter(
Mandatory = true,
Expand All @@ -37,14 +37,6 @@ public abstract class PrivateEndpointConnectionBaseCmdlet : NetworkBaseCmdlet
[SupportsWildcards]
public virtual string Name { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The private link service name.",
ParameterSetName = "ByResource")]
[ValidateNotNullOrEmpty]
public string ServiceName { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
Expand All @@ -55,10 +47,29 @@ public abstract class PrivateEndpointConnectionBaseCmdlet : NetworkBaseCmdlet
public virtual string ResourceGroupName { get; set; }

[Parameter(
Mandatory = false,
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The private link resource type.",
ParameterSetName = "ByResource")]
HelpMessage = "The private link service name.",
ParameterSetName = "ByResource")]
[ValidateNotNullOrEmpty]
public string ServiceName { get; set; }

protected RuntimeDefinedParameterDictionary DynamicParameters;

public const string privateEndpointTypeName = "PrivateLinkResourceType";
string NamedContextParameterSet = "ByResource";
public object GetDynamicParameters()
{
var parameters = new RuntimeDefinedParameterDictionary();
RuntimeDefinedParameter namedParameter;
if (ProviderConfiguration.TryGetProvideServiceParameter(privateEndpointTypeName, NamedContextParameterSet, out namedParameter))
{
parameters.Add(privateEndpointTypeName, namedParameter);
}
DynamicParameters = parameters;
return parameters;
}

public string PrivateLinkResourceType { get; set; }

public string Subscription { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
using Microsoft.Azure.Commands.Network.PrivateLinkService.PrivateLinkServiceProvider;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "PrivateLinkResource", DefaultParameterSetName = "ByPrivateLinkResourceId"), OutputType(typeof(PSPrivateLinkResource))]
public class GetAzurePrivateLinkResourceCommand : NetworkBaseCmdlet
public class GetAzurePrivateLinkResourceCommand : NetworkBaseCmdlet, IDynamicParameters
{
[Parameter(
Mandatory = true,
Expand All @@ -31,22 +32,63 @@ public class GetAzurePrivateLinkResourceCommand : NetworkBaseCmdlet
[ValidateNotNullOrEmpty]
public string PrivateLinkResourceId { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The resource group name.",
ParameterSetName = "ByResource")]
[ValidateNotNullOrEmpty]
public virtual string ResourceGroupName { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The private link service name.",
ParameterSetName = "ByResource")]
[ValidateNotNullOrEmpty]
public string ServiceName { get; set; }

public string PrivateLinkResourceType { get; set; }
string NamedContextParameterSet = "ByResource";
private RuntimeDefinedParameterDictionary DynamicParameters;
public const string privateEndpointTypeName = "PrivateLinkResourceType";
public string Subscription { get; set; }

public object GetDynamicParameters()
{
var parameters = new RuntimeDefinedParameterDictionary();
RuntimeDefinedParameter namedParameter;
if (ProviderConfiguration.TryGetProvideServiceParameter(privateEndpointTypeName, NamedContextParameterSet, out namedParameter))
{
parameters.Add(privateEndpointTypeName, namedParameter);
}
DynamicParameters = parameters;
return parameters;
}

public override void Execute()
{
base.Execute();

var resourceIdentifier = new ResourceIdentifier(this.PrivateLinkResourceId);
string ResourceGroupName = resourceIdentifier.ResourceGroupName;
string Name = resourceIdentifier.ResourceName;
string ResourceType = resourceIdentifier.ResourceType;

IPrivateLinkProvider provider = PrivateLinkProviderFactory.CreatePrivateLinkProvder(this, resourceIdentifier.Subscription, ResourceType);
if (this.IsParameterBound(c => c.PrivateLinkResourceId))
{
var resourceIdentifier = new ResourceIdentifier(this.PrivateLinkResourceId);
this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
this.ServiceName = resourceIdentifier.ResourceName;
this.PrivateLinkResourceType = resourceIdentifier.ResourceType;
this.Subscription = resourceIdentifier.Subscription;
}
else
{
this.Subscription = DefaultProfile.DefaultContext.Subscription.Id;
this.PrivateLinkResourceType = DynamicParameters[privateEndpointTypeName].Value as string;
}
IPrivateLinkProvider provider = PrivateLinkProviderFactory.CreatePrivateLinkProvder(this, Subscription, PrivateLinkResourceType);
if (provider == null)
{
throw new ArgumentException(string.Format(Properties.Resources.InvalidResourceId, this.PrivateLinkResourceId));
}
var plrs = provider.ListPrivateLinkResource(ResourceGroupName, Name);

var plrs = provider.ListPrivateLinkResource(ResourceGroupName, ServiceName);
WriteObject(plrs, true);

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management.Automation;
using System.Text;

namespace Microsoft.Azure.Commands.Network.PrivateLinkService.PrivateLinkServiceProvider
Expand Down Expand Up @@ -50,5 +53,35 @@ public static ProviderConfiguration GetProviderConfiguration(string type)
{
return _configurations[type];
}

/// <summary>
/// Generate a runtime parameter with ValidateSet matching the current context
/// </summary>
/// <param name="name">The name of the parameter</param>
/// <param name="runtimeParameter">The returned runtime parameter for context, with appropriate validate set</param>
/// <returns>True if one or more contexts were found, otherwise false</returns>
public static bool TryGetProvideServiceParameter(string name, string parameterSetName, out RuntimeDefinedParameter runtimeParameter)
{
var result = false;
runtimeParameter = null;
if (_configurations != null && _configurations.Values != null)
{
var ObjArray = _configurations.Values.ToArray();
var ProvideTypeList = ObjArray.Select(c => c.Type).ToArray();
runtimeParameter = new RuntimeDefinedParameter(
name, typeof(string),
new Collection<Attribute>()
{
new ParameterAttribute { Mandatory = false,
ValueFromPipeline = true,
HelpMessage = "The private link resource type.",
ParameterSetName = parameterSetName },
new ValidateSetAttribute(ProvideTypeList)
}
);
result = true;
}
return result;
}
}
}
32 changes: 24 additions & 8 deletions src/Network/Network/help/Get-AzPrivateEndpointConnection.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ Gets a private endpoint connection resource.

## SYNTAX

### ByPrivateLinkResourceId (Default)
### ByResourceId (Default)
```
Get-AzPrivateEndpointConnection -PrivateLinkResourceId <String>
Get-AzPrivateEndpointConnection [-Description <String>] -ResourceId <String>
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### ByResourceId
### ByPrivateLinkResourceId
```
Get-AzPrivateEndpointConnection -ResourceId <String>
Get-AzPrivateEndpointConnection -PrivateLinkResourceId <String> [-Description <String>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### ByResource
```
Get-AzPrivateEndpointConnection -ServiceName <String> -ResourceGroupName <String>
[-Name <String>] [-PrivateLinkResourceType <String>] [-Description <String>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
Get-AzPrivateEndpointConnection [-Description <String>] [-Name <String>] -ResourceGroupName <String>
-ServiceName <String> [-DefaultProfile <IAzureContextContainer>] [-PrivateLinkResourceType <String>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -67,6 +67,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Description
The reason of action.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Name
The name of the private endpoint connection.

Expand Down Expand Up @@ -104,11 +119,12 @@ The private link resource type.
Type: System.String
Parameter Sets: ByResource
Aliases:
Accepted values:

Required: False
Position: Named
Default value: 'Microsoft.Network/privateLinkServices'
Accept pipeline input: True (ByPropertyName)
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

Expand Down
56 changes: 54 additions & 2 deletions src/Network/Network/help/Get-AzPrivateLinkResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ Gets a private link resource.

### ByPrivateLinkResourceId (Default)
```
Get-AzPrivateLinkResource -PrivateLinkResourceId <String>
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
Get-AzPrivateLinkResource -PrivateLinkResourceId <String> [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

### ByResource
```
Get-AzPrivateLinkResource -ResourceGroupName <String> -ServiceName <String>
[-DefaultProfile <IAzureContextContainer>] [-PrivateLinkResourceType <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -62,6 +68,52 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -PrivateLinkResourceType
The private link resource type.

```yaml
Type: System.String
Parameter Sets: ByResource
Aliases:
Accepted values:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

### -ResourceGroupName
The resource group name.

```yaml
Type: System.String
Parameter Sets: ByResource
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ServiceName
The private link service name.

```yaml
Type: System.String
Parameter Sets: ByResource
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,16 @@
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.RemoveAzureVirtualRouterCommand","Remove-AzVirtualRouter","0","3010","The property 'HostedGateway' of type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouter' has been removed.","Add the property 'HostedGateway' back to type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouter'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.RemoveAzureVirtualRouterCommand","Remove-AzVirtualRouter","0","3010","The property 'HostedGatewayText' of type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouter' has been removed.","Add the property 'HostedGatewayText' back to type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouter'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.GetAzureRmVirtualRouterPeer","Get-AzVirtualRouterPeer","0","3010","The property 'Type' of type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouterPeer' has been removed.","Add the property 'Type' back to type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouterPeer'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.ApproveAzurePrivateEndpointConnection","Approve-AzPrivateEndpointConnection","0","2000","The cmdlet 'Approve-AzPrivateEndpointConnection' no longer supports the parameter 'PrivateLinkResourceType' and no alias was found for the original parameter name.","Add the parameter 'PrivateLinkResourceType' back to the cmdlet 'Approve-AzPrivateEndpointConnection', or add an alias to the original parameter name."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.ApproveAzurePrivateEndpointConnection","Approve-AzPrivateEndpointConnection","0","1050","The parameter set 'ByResource' for cmdlet 'Approve-AzPrivateEndpointConnection' has been removed.","Add parameter set 'ByResource' back to cmdlet 'Approve-AzPrivateEndpointConnection'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.DenyAzurePrivateEndpointConnection","Deny-AzPrivateEndpointConnection","0","2000","The cmdlet 'Deny-AzPrivateEndpointConnection' no longer supports the parameter 'PrivateLinkResourceType' and no alias was found for the original parameter name.","Add the parameter 'PrivateLinkResourceType' back to the cmdlet 'Deny-AzPrivateEndpointConnection', or add an alias to the original parameter name."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.DenyAzurePrivateEndpointConnection","Deny-AzPrivateEndpointConnection","0","1050","The parameter set 'ByResource' for cmdlet 'Deny-AzPrivateEndpointConnection' has been removed.","Add parameter set 'ByResource' back to cmdlet 'Deny-AzPrivateEndpointConnection'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.GetAzurePrivateEndpointConnection","Get-AzPrivateEndpointConnection","0","2000","The cmdlet 'Get-AzPrivateEndpointConnection' no longer supports the parameter 'PrivateLinkResourceType' and no alias was found for the original parameter name.","Add the parameter 'PrivateLinkResourceType' back to the cmdlet 'Get-AzPrivateEndpointConnection', or add an alias to the original parameter name."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.GetAzurePrivateEndpointConnection","Get-AzPrivateEndpointConnection","0","1050","The parameter set 'ByResource' for cmdlet 'Get-AzPrivateEndpointConnection' has been removed.","Add parameter set 'ByResource' back to cmdlet 'Get-AzPrivateEndpointConnection'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.RemoveAzurePrivateEndpointConnection","Remove-AzPrivateEndpointConnection","0","2000","The cmdlet 'Remove-AzPrivateEndpointConnection' no longer supports the parameter 'PrivateLinkResourceType' and no alias was found for the original parameter name.","Add the parameter 'PrivateLinkResourceType' back to the cmdlet 'Remove-AzPrivateEndpointConnection', or add an alias to the original parameter name."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.RemoveAzurePrivateEndpointConnection","Remove-AzPrivateEndpointConnection","0","1050","The parameter set 'ByResource' for cmdlet 'Remove-AzPrivateEndpointConnection' has been removed.","Add parameter set 'ByResource' back to cmdlet 'Remove-AzPrivateEndpointConnection'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.SetAzurePrivateEndpointConnection","Set-AzPrivateEndpointConnection","0","2000","The cmdlet 'Set-AzPrivateEndpointConnection' no longer supports the parameter 'PrivateLinkResourceType' and no alias was found for the original parameter name.","Add the parameter 'PrivateLinkResourceType' back to the cmdlet 'Set-AzPrivateEndpointConnection', or add an alias to the original parameter name."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.SetAzurePrivateEndpointConnection","Set-AzPrivateEndpointConnection","0","1050","The parameter set 'ByResource' for cmdlet 'Set-AzPrivateEndpointConnection' has been removed.","Add parameter set 'ByResource' back to cmdlet 'Set-AzPrivateEndpointConnection'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.NewAzureRmExpressRouteGatewayCommand","New-AzExpressRouteGateway","0","3010","The property 'HostedSubnet' of type 'Microsoft.Azure.Commands.Network.Models.PSHubIpConfiguration' has been removed.","Add the property 'HostedSubnet' back to type 'Microsoft.Azure.Commands.Network.Models.PSHubIpConfiguration'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.NewAzureFirewallDnsSettingCommand","New-AzFirewallPolicyDnsSetting","0","3010","The property 'RequireProxyForNetworkRules' of type 'Microsoft.Azure.Commands.Network.Models.PSAzureFirewallPolicyDnsSettings' has been removed.","Add the property 'RequireProxyForNetworkRules' back to type 'Microsoft.Azure.Commands.Network.Models.PSAzureFirewallPolicyDnsSettings'."
"Microsoft.Azure.PowerShell.Cmdlets.Network.dll","Microsoft.Azure.Commands.Network.NewAzureFirewallDnsSettingCommand","New-AzFirewallPolicyDnsSetting","0","2000","The cmdlet 'New-AzFirewallPolicyDnsSetting' no longer supports the parameter 'ProxyNotRequiredForNetworkRule' and no alias was found for the original parameter name.","Add the parameter 'ProxyNotRequiredForNetworkRule' back to the cmdlet 'New-AzFirewallPolicyDnsSetting', or add an alias to the original parameter name."
Expand Down