Skip to content

Commit 801bf01

Browse files
Interface endpoints
1 parent 47e14a5 commit 801bf01

13 files changed

+533
-4
lines changed

src/ResourceManager/Network/Commands.Network/Az.Network.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
385385
'New-AzFirewallApplicationRuleCollection',
386386
'New-AzFirewallApplicationRule',
387387
'New-AzFirewallNetworkRuleCollection',
388-
'New-AzFirewallNetworkRule'
388+
'New-AzFirewallNetworkRule',
389+
'Get-AzInterfaceEndpoint'
389390

390391
# Variables to export from this module
391392
# VariablesToExport = @()

src/ResourceManager/Network/Commands.Network/AzureRM.Network.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
386386
'New-AzureRmFirewallApplicationRuleCollection',
387387
'New-AzureRmFirewallApplicationRule',
388388
'New-AzureRmFirewallNetworkRuleCollection',
389-
'New-AzureRmFirewallNetworkRule'
389+
'New-AzureRmFirewallNetworkRule',
390+
'Get-AzureRmInterfaceEndpoint'
390391

391392
# Variables to export from this module
392393
# VariablesToExport = @()

src/ResourceManager/Network/Commands.Network/ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--
1+
<!--
22
Please leave this section at the top of the change log.
33
44
Changes for the current release should go under the section titled "Current Release", and should adhere to the following format:
@@ -60,6 +60,7 @@
6060
- Cmdlets updated with optonal parameter -AutoscaleConfiguration
6161
- New-AzureRmApplicationGateway
6262
- Set-AzureRmApplicationGateway
63+
* Add cmdlet for Interface Endpoint Get-AzureInterfaceEndpoint
6364

6465
## Version 6.7.0
6566
* Updated cmdlet New-AzureRmVirtualNetworkGatewayConnection with support for switch ExpressRouteGatewayBypass

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
<Compile Include="AzureFirewall\RemoveAzureFirewallCommand.cs" />
193193
<Compile Include="AzureFirewall\AzureFirewallBaseCmdlet.cs" />
194194
<Compile Include="AzureFirewall\SetAzureFirewallCommand.cs" />
195+
<Compile Include="InterfaceEndpoint\AzureInterfaceEndpointBaseCmdlet.cs" />
195196
<Compile Include="Generated\ApplicationSecurityGroup\GetAzureRMApplicationSecurityGroupCommand.cs" />
196197
<Compile Include="Generated\ApplicationSecurityGroup\NewAzureRMApplicationSecurityGroupCommand.cs" />
197198
<Compile Include="Generated\ApplicationSecurityGroup\RemoveAzureRMApplicationSecurityGroupCommand.cs" />
@@ -355,6 +356,7 @@
355356
<Compile Include="Generated\Models\PSResourceNavigationLink.cs" />
356357
<Compile Include="Generated\Models\PSTroubleshootingDetails.cs" />
357358
<Compile Include="Generated\Models\PSTroubleshootingRecommendedActions.cs" />
359+
<Compile Include="InterfaceEndpoint\GetAzureInterfaceEndpointCommand.cs" />
358360
<Compile Include="Models\PSTrafficAnalyticsConfigurationProperties.cs" />
359361
<Compile Include="Models\PSTrafficAnalyticsProperties.cs" />
360362
<Compile Include="Generated\Models\PSTunnelConnectionHealth.cs" />
@@ -539,6 +541,8 @@
539541
<Compile Include="NetworkWatcher\GetAzureNetworkWatcherReachabilityProvidersListCommand.cs" />
540542
<Compile Include="NetworkWatcher\GetAzureRMNetworkWatcherReachabilityReportCommand.cs" />
541543
<Compile Include="ProviderWideCmdlets\GetAzureExpressRouteServiceProviderCommand.cs" />
544+
<Compile Include="Models\PSEndpointService.cs" />
545+
<Compile Include="Models\PSInterfaceEndpoint.cs" />
542546
<Compile Include="PublicIpPrefix\GetAzurePublicIpPrefixCommand.cs" />
543547
<Compile Include="PublicIpPrefix\NewAzurePublicIpPrefixCommand.cs" />
544548
<Compile Include="PublicIpPrefix\PublicIpPrefixBaseCmdlet.cs" />

src/ResourceManager/Network/Commands.Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,19 @@ private static void Initialize()
810810
cfg.CreateMap<MNM.AzureFirewallNetworkRule, CNM.PSAzureFirewallNetworkRule>();
811811
cfg.CreateMap<MNM.AzureFirewallRCAction, CNM.PSAzureFirewallRCAction>();
812812
cfg.CreateMap<MNM.AzureFirewallApplicationRuleProtocol, CNM.PSAzureFirewallApplicationRuleProtocol>();
813+
814+
// Interface endpoint
815+
// CNM to MNM
816+
cfg.CreateMap<CNM.PSInterfaceEndpoint, MNM.InterfaceEndpoint>();
817+
818+
// MNM to CNM
819+
cfg.CreateMap<MNM.InterfaceEndpoint, CNM.PSInterfaceEndpoint>();
820+
821+
// CNM to MNM
822+
cfg.CreateMap<CNM.PSEndpointService, MNM.EndpointService>();
823+
824+
// MNM to CNM
825+
cfg.CreateMap<MNM.EndpointService, CNM.PSEndpointService>();
813826
});
814827

815828
_mapper = config.CreateMapper();
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+

2+
// ----------------------------------------------------------------------------------
3+
//
4+
// Copyright Microsoft Corporation
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ----------------------------------------------------------------------------------
15+
16+
namespace Microsoft.Azure.Commands.Network
17+
{
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using System.Net;
20+
using Microsoft.Azure.Management.Network;
21+
using Microsoft.Azure.Management.Network.Models;
22+
using System.Collections.Generic;
23+
using Microsoft.Rest.Azure;
24+
25+
public abstract class AzureInterfaceEndpointBaseCmdlet : NetworkBaseCmdlet
26+
{
27+
public IInterfaceEndpointsOperations InterfaceEndpointClient
28+
{
29+
get
30+
{
31+
return NetworkClient.NetworkManagementClient.InterfaceEndpoints;
32+
}
33+
}
34+
35+
public bool IsServiceEndpointPolicyPresent(string resourceGroupName, string name)
36+
{
37+
try
38+
{
39+
GetInterfaceEndpoint(resourceGroupName, name);
40+
}
41+
catch (Microsoft.Rest.Azure.CloudException exception)
42+
{
43+
if (exception.Response.StatusCode == HttpStatusCode.NotFound)
44+
{
45+
// Resource is not present
46+
return false;
47+
}
48+
49+
throw;
50+
}
51+
52+
return true;
53+
}
54+
55+
public PSInterfaceEndpoint GetInterfaceEndpoint(string resourceGroupName, string name, string expandResource = null)
56+
{
57+
var interfaceEndpoint = this.InterfaceEndpointClient.Get(resourceGroupName, name, expandResource);
58+
59+
var pSInterfaceEndpoint = ToInterfaceEndpoint(interfaceEndpoint);
60+
pSInterfaceEndpoint.ResourceGroupName = resourceGroupName;
61+
62+
return pSInterfaceEndpoint;
63+
}
64+
65+
public IEnumerable<PSInterfaceEndpoint> ListInterfaceEndpoints(string resourceGroupName)
66+
{
67+
var interfaceEndpoints = this.InterfaceEndpointClient.List(resourceGroupName);
68+
69+
List<PSInterfaceEndpoint> pSInterfaceEndpoints = new List<PSInterfaceEndpoint>();
70+
foreach (var interfaceEndpoint in interfaceEndpoints)
71+
{
72+
var pSInterfaceEndpoint = ToInterfaceEndpoint(interfaceEndpoint);
73+
pSInterfaceEndpoint.ResourceGroupName = resourceGroupName;
74+
pSInterfaceEndpoints.Add(pSInterfaceEndpoint);
75+
}
76+
77+
return pSInterfaceEndpoints;
78+
}
79+
80+
public PSInterfaceEndpoint ToInterfaceEndpoint(InterfaceEndpoint interfaceEndpoint)
81+
{
82+
var pSInterfaceEndpoint = NetworkResourceManagerProfile.Mapper.Map<PSInterfaceEndpoint>(interfaceEndpoint);
83+
return pSInterfaceEndpoint;
84+
}
85+
}
86+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Network
16+
{
17+
using Microsoft.Azure.Commands.Network.Models;
18+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
19+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
using System.Collections.Generic;
22+
using System.Management.Automation;
23+
24+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "InterfaceEndpoint", SupportsShouldProcess = true, DefaultParameterSetName = "GetByNameParameterSet"), OutputType(typeof(PSInterfaceEndpoint))]
25+
public class GetInterfaceEndpointCommand : AzureInterfaceEndpointBaseCmdlet
26+
{
27+
[Parameter(
28+
Mandatory = false,
29+
ParameterSetName = "GetByNameParameterSet",
30+
HelpMessage = "The name of the interface endpoint")]
31+
[ValidateNotNullOrEmpty]
32+
public string Name { get; set; }
33+
34+
[Parameter(
35+
Mandatory = true,
36+
ValueFromPipelineByPropertyName = true,
37+
HelpMessage = "The resource group name.",
38+
ParameterSetName = "GetByNameParameterSet")]
39+
[ResourceGroupCompleter]
40+
[ValidateNotNullOrEmpty]
41+
public virtual string ResourceGroupName { get; set; }
42+
43+
[Parameter(
44+
Mandatory = true,
45+
ValueFromPipelineByPropertyName = true,
46+
ParameterSetName = "GetByResourceIdParameterSet")]
47+
[ValidateNotNullOrEmpty]
48+
public virtual string ResourceId { get; set; }
49+
50+
public override void Execute()
51+
{
52+
if (this.ShouldProcess(Name, VerbsLifecycle.Restart))
53+
{
54+
base.Execute();
55+
56+
if (this.IsParameterBound(c => c.ResourceId))
57+
{
58+
var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
59+
this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
60+
this.Name = resourceIdentifier.ResourceName;
61+
}
62+
63+
if (!string.IsNullOrEmpty(this.Name))
64+
{
65+
PSInterfaceEndpoint psInterfaceEndpoint;
66+
psInterfaceEndpoint = this.GetInterfaceEndpoint(this.ResourceGroupName, this.Name);
67+
WriteObject(psInterfaceEndpoint);
68+
}
69+
else
70+
{
71+
IEnumerable<PSInterfaceEndpoint> interfaceEndpoints = null;
72+
if (!string.IsNullOrEmpty(this.ResourceGroupName))
73+
{
74+
interfaceEndpoints = ListInterfaceEndpoints(this.ResourceGroupName);
75+
}
76+
77+
WriteObject(interfaceEndpoints, true);
78+
}
79+
}
80+
}
81+
}
82+
}

src/ResourceManager/Network/Commands.Network/Microsoft.Azure.Commands.Network.format.ps1xml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@
804804
<Label>ServiceEndpointPolicies</Label>
805805
<PropertyName>ServiceEndpointPoliciesText</PropertyName>
806806
</ListItem>
807+
<ListItem>
808+
<Label>InterfaceEndpoints</Label>
809+
<PropertyName>InterfaceEndpointsText</PropertyName>
810+
</ListItem>
807811
</ListItems>
808812
</ListEntry>
809813
</ListEntries>
@@ -1419,6 +1423,85 @@
14191423
</ListEntries>
14201424
</ListControl>
14211425
</View>
1426+
<View>
1427+
<Name>Microsoft.Azure.Commands.Network.Models.PSInterfaceEndpoint</Name>
1428+
<ViewSelectedBy>
1429+
<TypeName>Microsoft.Azure.Commands.Network.Models.PSInterfaceEndpoint</TypeName>
1430+
</ViewSelectedBy>
1431+
<ListControl>
1432+
<ListEntries>
1433+
<ListEntry>
1434+
<ListItems>
1435+
<ListItem>
1436+
<Label>Name</Label>
1437+
<PropertyName>Name</PropertyName>
1438+
</ListItem>
1439+
<ListItem>
1440+
<Label>ResourceGroupName</Label>
1441+
<PropertyName>ResourceGroupName</PropertyName>
1442+
</ListItem>
1443+
<ListItem>
1444+
<Label>Location</Label>
1445+
<PropertyName>Location</PropertyName>
1446+
</ListItem>
1447+
<ListItem>
1448+
<Label>Id</Label>
1449+
<PropertyName>Id</PropertyName>
1450+
</ListItem>
1451+
<ListItem>
1452+
<Label>Etag</Label>
1453+
<PropertyName>Etag</PropertyName>
1454+
</ListItem>
1455+
<ListItem>
1456+
<Label>ResourceGuid</Label>
1457+
<PropertyName>ResourceGuid</PropertyName>
1458+
</ListItem>
1459+
<ListItem>
1460+
<Label>ProvisioningState</Label>
1461+
<PropertyName>ProvisioningState</PropertyName>
1462+
</ListItem>
1463+
<ListItem>
1464+
<Label>EndpointService</Label>
1465+
<PropertyName>EndpointServiceText</PropertyName>
1466+
</ListItem>
1467+
<ListItem>
1468+
<Label>Subnet</Label>
1469+
<PropertyName>SubnetText</PropertyName>
1470+
</ListItem>
1471+
<ListItem>
1472+
<Label>Owner</Label>
1473+
<PropertyName>Owner</PropertyName>
1474+
</ListItem> <ListItem>
1475+
<Label>Fqdn</Label>
1476+
<PropertyName>Fqdn</PropertyName>
1477+
</ListItem>
1478+
<ListItem>
1479+
<Label>NetworkInterfaces</Label>
1480+
<PropertyName>NetworkInterfacesText</PropertyName>
1481+
</ListItem>
1482+
</ListItems>
1483+
</ListEntry>
1484+
</ListEntries>
1485+
</ListControl>
1486+
</View>
1487+
<View>
1488+
<Name>Microsoft.Azure.Commands.Network.Models.PSEndpointService</Name>
1489+
<ViewSelectedBy>
1490+
<TypeName>Microsoft.Azure.Commands.Network.Models.PSEndpointService</TypeName>
1491+
</ViewSelectedBy>
1492+
<ListControl>
1493+
<ListEntries>
1494+
<ListEntry>
1495+
<ListItems>
1496+
<ListItem>
1497+
<Label>Id</Label>
1498+
<PropertyName>Id</PropertyName>
1499+
</ListItem>
1500+
</ListItems>
1501+
</ListEntry>
1502+
</ListEntries>
1503+
</ListControl>
1504+
</View>
14221505
<View>
14231506
<Name>Microsoft.Azure.Commands.Network.Models.PSServiceEndpointPolicyDefinition</Name>
14241507
<ViewSelectedBy>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
16+
namespace Microsoft.Azure.Commands.Network.Models
17+
{
18+
using Newtonsoft.Json;
19+
20+
public class PSEndpointService
21+
{
22+
[JsonProperty(Order = 1)]
23+
public string Id { get; set; }
24+
}
25+
}

0 commit comments

Comments
 (0)