Skip to content

Replaced RouteTables and Routes with generated #4689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2017
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@
<Compile Include="NetworkWatcher\RemoveAzureNetworkWatcherCommand.cs" />
<Compile Include="ProviderWideCmdlets\GetAzureExpressRouteServiceProviderCommand.cs" />
<Compile Include="Models\PSApplicationSecurityGroup.cs" />
<Compile Include="RouteTable\GetAzureRMRouteTableCommand.cs" />
<Compile Include="RouteTable\NewAzureRMRouteTableCommand.cs" />
<Compile Include="RouteTable\RemoveAzureRMRouteTableCommand.cs" />
<Compile Include="RouteTable\Route\AddAzureRmRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\GetAzureRmRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\NewAzureRmRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\RemoveAzureRmRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\SetAzureRmRouteConfigCommand.cs" />
<Compile Include="RouteTable\SetAzureRMRouteTableCommand.cs" />
<Compile Include="Usage\GetAzureNetworkUsageCommand.cs" />
<Compile Include="VirtualNetworkGatewayConnection\GetAzureRmVirtualNetworkGatewayConnectionVpnDeviceConfigScript.cs" />
<Compile Include="VirtualNetworkGatewayConnection\GetAzureRmVirtualNetworkGatewaySupportedVpnDevice.cs" />
Expand Down Expand Up @@ -388,17 +397,6 @@
<Compile Include="PublicIpAddress\PublicIpAddressBaseCmdlet.cs" />
<Compile Include="PublicIpAddress\RemoveAzurePublicIpAddressCommand.cs" />
<Compile Include="PublicIpAddress\SetAzurePublicIpAddressCommand.cs" />
<Compile Include="RouteTable\GetAzureRouteTableCommand.cs" />
<Compile Include="RouteTable\RouteTableBaseCmdlet.cs" />
<Compile Include="RouteTable\NewAzureRouteTableCommand.cs" />
<Compile Include="RouteTable\RemoveAzureRouteTableCommand.cs" />
<Compile Include="RouteTable\Route\AddAzureRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\AzureRouteConfigBase.cs" />
<Compile Include="RouteTable\Route\GetAzureRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\NewAzureRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\RemoveAzureRouteConfigCommand.cs" />
<Compile Include="RouteTable\Route\SetAzureRouteConfigCommand.cs" />
<Compile Include="RouteTable\SetAzureRouteTableCommand.cs" />
<Compile Include="VirtualNetworkGateway\AzureVirtualNetworkGatewayIpConfigBase.cs" />
<Compile Include="VirtualNetworkGateway\ChildResourceHelp.cs" />
<Compile Include="VirtualNetworkGateway\UpdateAzureVirtualNetworkGatewayCommand.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//

// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

using AutoMapper;
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
using Microsoft.Rest.Azure;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using CNM = Microsoft.Azure.Commands.Network.Models;

namespace Microsoft.Azure.Commands.Network.Automation
{
[Cmdlet(VerbsCommon.Get, "AzureRmRouteTable"), OutputType(typeof(PSRouteTable))]
public partial class GetAzureRmRouteTable : NetworkBaseCmdlet
{
[Parameter(
Mandatory = true,
HelpMessage = "The resource group name of route table.",
ParameterSetName = "Expand",
ValueFromPipelineByPropertyName = true)]
[Parameter(
Mandatory = false,
HelpMessage = "The resource group name of route table.",
ParameterSetName = "NoExpand",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Alias("ResourceName")]
[Parameter(
Mandatory = true,
HelpMessage = "The name of route table.",
ParameterSetName = "Expand",
ValueFromPipelineByPropertyName = true)]
[Parameter(
Mandatory = false,
HelpMessage = "The name of route table.",
ParameterSetName = "NoExpand",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(
Mandatory = true,
ParameterSetName = "Expand",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ExpandResource { get; set; }

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

if(!string.IsNullOrEmpty(this.Name))
{
var vRouteTable = this.NetworkClient.NetworkManagementClient.RouteTables.Get(ResourceGroupName, Name, ExpandResource);
var vRouteTableModel = Mapper.Map<CNM.PSRouteTable>(vRouteTable);
vRouteTableModel.ResourceGroupName = this.ResourceGroupName;
vRouteTableModel.Tag = TagsConversionHelper.CreateTagHashtable(vRouteTable.Tags);
WriteObject(vRouteTableModel, true);
}
else
{
IPage<RouteTable> vRouteTablePage;
if(!string.IsNullOrEmpty(this.ResourceGroupName))
{
vRouteTablePage = this.NetworkClient.NetworkManagementClient.RouteTables.List(this.ResourceGroupName);
}
else
{
vRouteTablePage = this.NetworkClient.NetworkManagementClient.RouteTables.ListAll();
}

var vRouteTableList = ListNextLink<RouteTable>.GetAllResourcesByPollingNextLink(vRouteTablePage,
this.NetworkClient.NetworkManagementClient.RouteTables.ListNext);
List<PSRouteTable> psRouteTableList = new List<PSRouteTable>();
foreach (var vRouteTable in vRouteTableList)
{
var vRouteTableModel = Mapper.Map<CNM.PSRouteTable>(vRouteTable);
vRouteTableModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(vRouteTable.Id);
vRouteTableModel.Tag = TagsConversionHelper.CreateTagHashtable(vRouteTable.Tags);
psRouteTableList.Add(vRouteTableModel);
}
WriteObject(psRouteTableList);
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//

// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
using System.Net;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using AutoMapper;
using MNM = Microsoft.Azure.Management.Network.Models;

namespace Microsoft.Azure.Commands.Network.Automation
{
[Cmdlet(VerbsCommon.New, "AzureRmRouteTable", SupportsShouldProcess = true), OutputType(typeof(PSRouteTable))]
public partial class NewAzureRmRouteTable : NetworkBaseCmdlet
{
[Parameter(
Mandatory = true,
HelpMessage = "The resource group name of route table.",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Alias("ResourceName")]
[Parameter(
Mandatory = true,
HelpMessage = "The name of route table.",
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "The location.",
ValueFromPipelineByPropertyName = true)]
public string Location { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "A hashtable which represents resource tags.",
ValueFromPipelineByPropertyName = true)]
public Hashtable Tag { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Collection of routes contained within a route table.",
ValueFromPipelineByPropertyName = true)]
public List<PSRoute> Route { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Do not ask for confirmation if you want to overwrite a resource")]
public SwitchParameter Force { get; set; }

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


var vRouteTable = new PSRouteTable
{
Location = this.Location,
Routes = this.Route,
};

var vRouteTableModel = Mapper.Map<MNM.RouteTable>(vRouteTable);
vRouteTableModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);
var present = true;
try
{
this.NetworkClient.NetworkManagementClient.RouteTables.Get(this.ResourceGroupName, this.Name);
}
catch (Microsoft.Rest.Azure.CloudException exception)
{
if (exception.Response.StatusCode == HttpStatusCode.NotFound)
{
// Resource is not present
present = false;
}
else
{
throw;
}
}

ConfirmAction(
Force.IsPresent,
string.Format(Properties.Resources.OverwritingResource, Name),
Properties.Resources.CreatingResourceMessage,
Name,
() =>
{
this.NetworkClient.NetworkManagementClient.RouteTables.CreateOrUpdate(this.ResourceGroupName, this.Name, vRouteTableModel);
var getRouteTable = this.NetworkClient.NetworkManagementClient.RouteTables.Get(this.ResourceGroupName, this.Name);
var psRouteTable = Mapper.Map<PSRouteTable>(getRouteTable);
psRouteTable.ResourceGroupName = this.ResourceGroupName;
psRouteTable.Tag = TagsConversionHelper.CreateTagHashtable(getRouteTable.Tags);
WriteObject(psRouteTable, true);
},
() => present);

}
}
}
Loading