From a62ef99146f9390ed825fd4301d7d316bf04f1b0 Mon Sep 17 00:00:00 2001 From: Hyonho Lee Date: Thu, 13 Jul 2017 12:04:18 -0700 Subject: [PATCH] Fix the issue of New-AzureRmDisk, New-AzureRmSnapshot, Update-AzureRmDisk and Update-AzureRmSnapshot. --- .../Generated/Disk/DiskCreateOrUpdateMethod.cs | 11 ++++++++--- .../Generated/Disk/DiskUpdateMethod.cs | 16 ++++++++++------ .../Generated/Models/ComputeAutoMapperProfile.cs | 8 ++++++++ .../Snapshot/SnapshotCreateOrUpdateMethod.cs | 10 ++++++++-- .../Generated/Snapshot/SnapshotUpdateMethod.cs | 15 +++++++++------ 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs index 866a5be03a26..d7dba1ecbf7b 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs @@ -19,6 +19,7 @@ // Changes to this file may cause incorrect behavior and will be lost if the // code is regenerated. +using AutoMapper; using Microsoft.Azure.Commands.Compute.Automation.Models; using Microsoft.Azure.Management.Compute; using Microsoft.Azure.Management.Compute.Models; @@ -117,16 +118,20 @@ public partial class NewAzureRmDisk : ComputeAutomationBaseCmdlet { protected override void ProcessRecord() { + ComputeAutomationAutoMapperProfile.Initialize(); ExecuteClientAction(() => { if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New)) { string resourceGroupName = this.ResourceGroupName; string diskName = this.DiskName; - PSDisk disk = this.Disk; - + Disk disk = new Disk(); + Mapper.Map(this.Disk, disk); var result = DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk); - WriteObject(result); + + PSDisk psResult = new PSDisk(); + Mapper.Map(result, psResult); + WriteObject(psResult); } }); } diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskUpdateMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskUpdateMethod.cs index 3f813f33924b..24c975765356 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskUpdateMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskUpdateMethod.cs @@ -121,19 +121,23 @@ public partial class UpdateAzureRmDisk : ComputeAutomationBaseCmdlet { protected override void ProcessRecord() { + ComputeAutomationAutoMapperProfile.Initialize(); ExecuteClientAction(() => { if (ShouldProcess(this.ResourceGroupName, VerbsData.Update)) { - string resourceGroupName = this.ResourceGroupName; string diskName = this.DiskName; - PSDiskUpdate disk = this.DiskUpdate; - PSDisk diskOrg = this.Disk; - var result = (disk == null) - ? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskOrg) - : DisksClient.Update(resourceGroupName, diskName, disk); + Disk diskObj = new Disk(); + Mapper.Map(this.Disk, diskObj); + + DiskUpdate diskUpdateObj= new DiskUpdate(); + Mapper.Map(this.DiskUpdate, diskUpdateObj); + + var result = (this.DiskUpdate == null) + ? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskObj) + : DisksClient.Update(resourceGroupName, diskName, diskUpdateObj); var psObject = new PSDisk(); Mapper.Map(result, psObject); diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/Models/ComputeAutoMapperProfile.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/Models/ComputeAutoMapperProfile.cs index dc088f127cf2..056eda453468 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/Models/ComputeAutoMapperProfile.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/Models/ComputeAutoMapperProfile.cs @@ -95,6 +95,14 @@ protected override void Configure() Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); + Mapper.CreateMap(); + Mapper.CreateMap(); + Mapper.CreateMap(); + Mapper.CreateMap(); + Mapper.CreateMap(); + Mapper.CreateMap(); + Mapper.CreateMap(); + Mapper.CreateMap(); } } } diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotCreateOrUpdateMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotCreateOrUpdateMethod.cs index f3e4261f952a..4b4c42b2368c 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotCreateOrUpdateMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotCreateOrUpdateMethod.cs @@ -19,6 +19,7 @@ // Changes to this file may cause incorrect behavior and will be lost if the // code is regenerated. +using AutoMapper; using Microsoft.Azure.Commands.Compute.Automation.Models; using Microsoft.Azure.Management.Compute; using Microsoft.Azure.Management.Compute.Models; @@ -117,16 +118,21 @@ public partial class NewAzureRmSnapshot : ComputeAutomationBaseCmdlet { protected override void ProcessRecord() { + ComputeAutomationAutoMapperProfile.Initialize(); ExecuteClientAction(() => { if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New)) { string resourceGroupName = this.ResourceGroupName; string snapshotName = this.SnapshotName; - PSSnapshot snapshot = this.Snapshot; + Snapshot snapshot = new Snapshot(); + Mapper.Map(this.Snapshot, snapshot); var result = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot); - WriteObject(result); + + PSSnapshot psResult = new PSSnapshot(); + Mapper.Map(result, psResult); + WriteObject(psResult); } }); } diff --git a/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotUpdateMethod.cs b/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotUpdateMethod.cs index 3f863c631294..aac28976d391 100644 --- a/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotUpdateMethod.cs +++ b/src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotUpdateMethod.cs @@ -125,15 +125,18 @@ protected override void ProcessRecord() { if (ShouldProcess(this.ResourceGroupName, VerbsData.Update)) { - string resourceGroupName = this.ResourceGroupName; string snapshotName = this.SnapshotName; - PSSnapshotUpdate snapshot = this.SnapshotUpdate; - PSSnapshot snapshotOrg = this.Snapshot; - var result = (snapshot == null) - ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg) - : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot); + Snapshot snapshotObj = new Snapshot(); + Mapper.Map(this.Snapshot, snapshotObj); + + SnapshotUpdate snapshotUpdateObj = new SnapshotUpdate(); + Mapper.Map(this.SnapshotUpdate, snapshotUpdateObj); + + var result = (this.SnapshotUpdate == null) + ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotObj) + : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotUpdateObj); var psObject = new PSSnapshot(); Mapper.Map(result, psObject);