Skip to content

Commit d923895

Browse files
committed
Merge branch 'release-4.4.1' of https://github.com/Azure/azure-powershell into automapper-fix
# Conflicts: # src/ResourceManager/Network/Commands.Network/RouteTable/NewAzureRouteTableCommand.cs # src/ResourceManager/Network/Commands.Network/RouteTable/RouteTableBaseCmdlet.cs # src/ResourceManager/Network/Commands.Network/RouteTable/SetAzureRouteTableCommand.cs
2 parents 6560f3e + 6190f88 commit d923895

File tree

267 files changed

+6623
-3130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+6623
-3130
lines changed

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTests/TestEmptyRouteTable.json

Lines changed: 200 additions & 310 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTests/TestRouteHopTypeTest.json

Lines changed: 187 additions & 304 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTests/TestRouteTableCRUD.json

Lines changed: 325 additions & 531 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTests/TestRouteTableRouteCRUD.json

Lines changed: 649 additions & 496 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.RouteTableTests/TestRouteTableSubnetRef.json

Lines changed: 268 additions & 376 deletions
Large diffs are not rendered by default.

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@
359359
<Compile Include="NetworkWatcher\RemoveAzureNetworkWatcherCommand.cs" />
360360
<Compile Include="ProviderWideCmdlets\GetAzureExpressRouteServiceProviderCommand.cs" />
361361
<Compile Include="Models\PSApplicationSecurityGroup.cs" />
362+
<Compile Include="RouteTable\GetAzureRMRouteTableCommand.cs" />
363+
<Compile Include="RouteTable\NewAzureRMRouteTableCommand.cs" />
364+
<Compile Include="RouteTable\RemoveAzureRMRouteTableCommand.cs" />
365+
<Compile Include="RouteTable\Route\AddAzureRmRouteConfigCommand.cs" />
366+
<Compile Include="RouteTable\Route\GetAzureRmRouteConfigCommand.cs" />
367+
<Compile Include="RouteTable\Route\NewAzureRmRouteConfigCommand.cs" />
368+
<Compile Include="RouteTable\Route\RemoveAzureRmRouteConfigCommand.cs" />
369+
<Compile Include="RouteTable\Route\SetAzureRmRouteConfigCommand.cs" />
370+
<Compile Include="RouteTable\SetAzureRMRouteTableCommand.cs" />
362371
<Compile Include="Usage\GetAzureNetworkUsageCommand.cs" />
363372
<Compile Include="VirtualNetworkGatewayConnection\GetAzureRmVirtualNetworkGatewayConnectionVpnDeviceConfigScript.cs" />
364373
<Compile Include="VirtualNetworkGatewayConnection\GetAzureRmVirtualNetworkGatewaySupportedVpnDevice.cs" />
@@ -386,17 +395,6 @@
386395
<Compile Include="PublicIpAddress\PublicIpAddressBaseCmdlet.cs" />
387396
<Compile Include="PublicIpAddress\RemoveAzurePublicIpAddressCommand.cs" />
388397
<Compile Include="PublicIpAddress\SetAzurePublicIpAddressCommand.cs" />
389-
<Compile Include="RouteTable\GetAzureRouteTableCommand.cs" />
390-
<Compile Include="RouteTable\RouteTableBaseCmdlet.cs" />
391-
<Compile Include="RouteTable\NewAzureRouteTableCommand.cs" />
392-
<Compile Include="RouteTable\RemoveAzureRouteTableCommand.cs" />
393-
<Compile Include="RouteTable\Route\AddAzureRouteConfigCommand.cs" />
394-
<Compile Include="RouteTable\Route\AzureRouteConfigBase.cs" />
395-
<Compile Include="RouteTable\Route\GetAzureRouteConfigCommand.cs" />
396-
<Compile Include="RouteTable\Route\NewAzureRouteConfigCommand.cs" />
397-
<Compile Include="RouteTable\Route\RemoveAzureRouteConfigCommand.cs" />
398-
<Compile Include="RouteTable\Route\SetAzureRouteConfigCommand.cs" />
399-
<Compile Include="RouteTable\SetAzureRouteTableCommand.cs" />
400398
<Compile Include="VirtualNetworkGateway\AzureVirtualNetworkGatewayIpConfigBase.cs" />
401399
<Compile Include="VirtualNetworkGateway\ChildResourceHelp.cs" />
402400
<Compile Include="VirtualNetworkGateway\UpdateAzureVirtualNetworkGatewayCommand.cs" />
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
//
2+
// Copyright (c) Microsoft and contributors. 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+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
22+
using AutoMapper;
23+
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
24+
using Microsoft.Rest.Azure;
25+
using Microsoft.Azure.Commands.Network.Models;
26+
using Microsoft.Azure.Management.Network;
27+
using Microsoft.Azure.Management.Network.Models;
28+
using System;
29+
using System.Collections;
30+
using System.Collections.Generic;
31+
using System.Linq;
32+
using System.Management.Automation;
33+
using CNM = Microsoft.Azure.Commands.Network.Models;
34+
35+
namespace Microsoft.Azure.Commands.Network.Automation
36+
{
37+
[Cmdlet(VerbsCommon.Get, "AzureRmRouteTable"), OutputType(typeof(PSRouteTable))]
38+
public partial class GetAzureRmRouteTable : NetworkBaseCmdlet
39+
{
40+
[Parameter(
41+
Mandatory = true,
42+
HelpMessage = "The resource group name of route table.",
43+
ParameterSetName = "Expand",
44+
ValueFromPipelineByPropertyName = true)]
45+
[Parameter(
46+
Mandatory = false,
47+
HelpMessage = "The resource group name of route table.",
48+
ParameterSetName = "NoExpand",
49+
ValueFromPipelineByPropertyName = true)]
50+
[ValidateNotNullOrEmpty]
51+
public string ResourceGroupName { get; set; }
52+
53+
[Alias("ResourceName")]
54+
[Parameter(
55+
Mandatory = true,
56+
HelpMessage = "The name of route table.",
57+
ParameterSetName = "Expand",
58+
ValueFromPipelineByPropertyName = true)]
59+
[Parameter(
60+
Mandatory = false,
61+
HelpMessage = "The name of route table.",
62+
ParameterSetName = "NoExpand",
63+
ValueFromPipelineByPropertyName = true)]
64+
[ValidateNotNullOrEmpty]
65+
public string Name { get; set; }
66+
67+
[Parameter(
68+
Mandatory = true,
69+
ParameterSetName = "Expand",
70+
ValueFromPipelineByPropertyName = true)]
71+
[ValidateNotNullOrEmpty]
72+
public string ExpandResource { get; set; }
73+
74+
public override void Execute()
75+
{
76+
base.Execute();
77+
78+
if(!string.IsNullOrEmpty(this.Name))
79+
{
80+
var vRouteTable = this.NetworkClient.NetworkManagementClient.RouteTables.Get(ResourceGroupName, Name, ExpandResource);
81+
var vRouteTableModel = NetworkResourceManagerProfile.Mapper.Map<CNM.PSRouteTable>(vRouteTable);
82+
vRouteTableModel.ResourceGroupName = this.ResourceGroupName;
83+
vRouteTableModel.Tag = TagsConversionHelper.CreateTagHashtable(vRouteTable.Tags);
84+
WriteObject(vRouteTableModel, true);
85+
}
86+
else
87+
{
88+
IPage<RouteTable> vRouteTablePage;
89+
if(!string.IsNullOrEmpty(this.ResourceGroupName))
90+
{
91+
vRouteTablePage = this.NetworkClient.NetworkManagementClient.RouteTables.List(this.ResourceGroupName);
92+
}
93+
else
94+
{
95+
vRouteTablePage = this.NetworkClient.NetworkManagementClient.RouteTables.ListAll();
96+
}
97+
98+
var vRouteTableList = ListNextLink<RouteTable>.GetAllResourcesByPollingNextLink(vRouteTablePage,
99+
this.NetworkClient.NetworkManagementClient.RouteTables.ListNext);
100+
List<PSRouteTable> psRouteTableList = new List<PSRouteTable>();
101+
foreach (var vRouteTable in vRouteTableList)
102+
{
103+
var vRouteTableModel = NetworkResourceManagerProfile.Mapper.Map<CNM.PSRouteTable>(vRouteTable);
104+
vRouteTableModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vRouteTable.Id);
105+
vRouteTableModel.Tag = TagsConversionHelper.CreateTagHashtable(vRouteTable.Tags);
106+
psRouteTableList.Add(vRouteTableModel);
107+
}
108+
WriteObject(psRouteTableList);
109+
}
110+
}
111+
}
112+
}

src/ResourceManager/Network/Commands.Network/RouteTable/GetAzureRouteTableCommand.cs

Lines changed: 0 additions & 98 deletions
This file was deleted.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
//
2+
// Copyright (c) Microsoft and contributors. 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+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
22+
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
23+
using System.Net;
24+
using Microsoft.Azure.Commands.Network.Models;
25+
using Microsoft.Azure.Management.Network;
26+
using Microsoft.Azure.Management.Network.Models;
27+
using System;
28+
using System.Collections;
29+
using System.Collections.Generic;
30+
using System.Linq;
31+
using System.Management.Automation;
32+
using AutoMapper;
33+
using MNM = Microsoft.Azure.Management.Network.Models;
34+
35+
namespace Microsoft.Azure.Commands.Network.Automation
36+
{
37+
[Cmdlet(VerbsCommon.New, "AzureRmRouteTable", SupportsShouldProcess = true), OutputType(typeof(PSRouteTable))]
38+
public partial class NewAzureRmRouteTable : NetworkBaseCmdlet
39+
{
40+
[Parameter(
41+
Mandatory = true,
42+
HelpMessage = "The resource group name of route table.",
43+
ValueFromPipelineByPropertyName = true)]
44+
[ValidateNotNullOrEmpty]
45+
public string ResourceGroupName { get; set; }
46+
47+
[Alias("ResourceName")]
48+
[Parameter(
49+
Mandatory = true,
50+
HelpMessage = "The name of route table.",
51+
ValueFromPipelineByPropertyName = true)]
52+
[ValidateNotNullOrEmpty]
53+
public string Name { get; set; }
54+
55+
[Parameter(
56+
Mandatory = true,
57+
HelpMessage = "The location.",
58+
ValueFromPipelineByPropertyName = true)]
59+
public string Location { get; set; }
60+
61+
[Parameter(
62+
Mandatory = false,
63+
HelpMessage = "A hashtable which represents resource tags.",
64+
ValueFromPipelineByPropertyName = true)]
65+
public Hashtable Tag { get; set; }
66+
67+
[Parameter(
68+
Mandatory = false,
69+
HelpMessage = "Collection of routes contained within a route table.",
70+
ValueFromPipelineByPropertyName = true)]
71+
public List<PSRoute> Route { get; set; }
72+
73+
[Parameter(
74+
Mandatory = false,
75+
HelpMessage = "Do not ask for confirmation if you want to overwrite a resource")]
76+
public SwitchParameter Force { get; set; }
77+
78+
public override void Execute()
79+
{
80+
base.Execute();
81+
82+
83+
var vRouteTable = new PSRouteTable
84+
{
85+
Location = this.Location,
86+
Routes = this.Route,
87+
};
88+
89+
var vRouteTableModel = NetworkResourceManagerProfile.Mapper.Map<MNM.RouteTable>(vRouteTable);
90+
vRouteTableModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);
91+
var present = true;
92+
try
93+
{
94+
this.NetworkClient.NetworkManagementClient.RouteTables.Get(this.ResourceGroupName, this.Name);
95+
}
96+
catch (Microsoft.Rest.Azure.CloudException exception)
97+
{
98+
if (exception.Response.StatusCode == HttpStatusCode.NotFound)
99+
{
100+
// Resource is not present
101+
present = false;
102+
}
103+
else
104+
{
105+
throw;
106+
}
107+
}
108+
109+
ConfirmAction(
110+
Force.IsPresent,
111+
string.Format(Properties.Resources.OverwritingResource, Name),
112+
Properties.Resources.CreatingResourceMessage,
113+
Name,
114+
() =>
115+
{
116+
this.NetworkClient.NetworkManagementClient.RouteTables.CreateOrUpdate(this.ResourceGroupName, this.Name, vRouteTableModel);
117+
var getRouteTable = this.NetworkClient.NetworkManagementClient.RouteTables.Get(this.ResourceGroupName, this.Name);
118+
var psRouteTable = NetworkResourceManagerProfile.Mapper.Map<PSRouteTable>(getRouteTable);
119+
psRouteTable.ResourceGroupName = this.ResourceGroupName;
120+
psRouteTable.Tag = TagsConversionHelper.CreateTagHashtable(getRouteTable.Tags);
121+
WriteObject(psRouteTable, true);
122+
},
123+
() => present);
124+
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)