Skip to content

Commit 8944f4f

Browse files
committed
Fix the issue of New-AzureRmDisk, New-AzureRmSnapshot, Update-AzureRmDisk and Update-AzureRmSnapshot.
1 parent 27fce5c commit 8944f4f

File tree

5 files changed

+44
-17
lines changed

5 files changed

+44
-17
lines changed

src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskCreateOrUpdateMethod.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// Changes to this file may cause incorrect behavior and will be lost if the
2020
// code is regenerated.
2121

22+
using AutoMapper;
2223
using Microsoft.Azure.Commands.Compute.Automation.Models;
2324
using Microsoft.Azure.Management.Compute;
2425
using Microsoft.Azure.Management.Compute.Models;
@@ -117,16 +118,20 @@ public partial class NewAzureRmDisk : ComputeAutomationBaseCmdlet
117118
{
118119
protected override void ProcessRecord()
119120
{
121+
ComputeAutomationAutoMapperProfile.Initialize();
120122
ExecuteClientAction(() =>
121123
{
122124
if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
123125
{
124126
string resourceGroupName = this.ResourceGroupName;
125127
string diskName = this.DiskName;
126-
PSDisk disk = this.Disk;
127-
128+
Disk disk = new Disk();
129+
Mapper.Map<PSDisk, Disk>(this.Disk, disk);
128130
var result = DisksClient.CreateOrUpdate(resourceGroupName, diskName, disk);
129-
WriteObject(result);
131+
132+
PSDisk psResult = new PSDisk();
133+
Mapper.Map<Disk, PSDisk>(result, psResult);
134+
WriteObject(psResult);
130135
}
131136
});
132137
}

src/ResourceManager/Compute/Commands.Compute/Generated/Disk/DiskUpdateMethod.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,23 @@ public partial class UpdateAzureRmDisk : ComputeAutomationBaseCmdlet
121121
{
122122
protected override void ProcessRecord()
123123
{
124+
ComputeAutomationAutoMapperProfile.Initialize();
124125
ExecuteClientAction(() =>
125126
{
126127
if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
127128
{
128-
129129
string resourceGroupName = this.ResourceGroupName;
130130
string diskName = this.DiskName;
131-
PSDiskUpdate disk = this.DiskUpdate;
132-
PSDisk diskOrg = this.Disk;
133131

134-
var result = (disk == null)
135-
? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskOrg)
136-
: DisksClient.Update(resourceGroupName, diskName, disk);
132+
Disk diskObj = new Disk();
133+
Mapper.Map<PSDisk, Disk>(this.Disk, diskObj);
134+
135+
DiskUpdate diskUpdateObj= new DiskUpdate();
136+
Mapper.Map<PSDiskUpdate, DiskUpdate>(this.DiskUpdate, diskUpdateObj);
137+
138+
var result = (this.DiskUpdate == null)
139+
? DisksClient.CreateOrUpdate(resourceGroupName, diskName, diskObj)
140+
: DisksClient.Update(resourceGroupName, diskName, diskUpdateObj);
137141

138142
var psObject = new PSDisk();
139143
Mapper.Map<Disk, PSDisk>(result, psObject);

src/ResourceManager/Compute/Commands.Compute/Generated/Models/ComputeAutoMapperProfile.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ protected override void Configure()
9595
Mapper.CreateMap<FROM.DiskUpdate, FROM.Disk>();
9696
Mapper.CreateMap<FROM.Snapshot, FROM.SnapshotUpdate>();
9797
Mapper.CreateMap<FROM.SnapshotUpdate, FROM.Snapshot>();
98+
Mapper.CreateMap<FROM.Disk, TO.PSDisk>();
99+
Mapper.CreateMap<TO.PSDisk, FROM.Disk>();
100+
Mapper.CreateMap<FROM.DiskUpdate, TO.PSDiskUpdate>();
101+
Mapper.CreateMap<TO.PSDiskUpdate, FROM.DiskUpdate>();
102+
Mapper.CreateMap<FROM.Snapshot, TO.PSSnapshot>();
103+
Mapper.CreateMap<TO.PSSnapshot, FROM.Snapshot>();
104+
Mapper.CreateMap<FROM.SnapshotUpdate, TO.PSSnapshotUpdate>();
105+
Mapper.CreateMap<TO.PSSnapshotUpdate, FROM.SnapshotUpdate>();
98106
}
99107
}
100108
}

src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotCreateOrUpdateMethod.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// Changes to this file may cause incorrect behavior and will be lost if the
2020
// code is regenerated.
2121

22+
using AutoMapper;
2223
using Microsoft.Azure.Commands.Compute.Automation.Models;
2324
using Microsoft.Azure.Management.Compute;
2425
using Microsoft.Azure.Management.Compute.Models;
@@ -117,16 +118,21 @@ public partial class NewAzureRmSnapshot : ComputeAutomationBaseCmdlet
117118
{
118119
protected override void ProcessRecord()
119120
{
121+
ComputeAutomationAutoMapperProfile.Initialize();
120122
ExecuteClientAction(() =>
121123
{
122124
if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
123125
{
124126
string resourceGroupName = this.ResourceGroupName;
125127
string snapshotName = this.SnapshotName;
126-
PSSnapshot snapshot = this.Snapshot;
128+
Snapshot snapshot = new Snapshot();
129+
Mapper.Map<PSSnapshot, Snapshot>(this.Snapshot, snapshot);
127130

128131
var result = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);
129-
WriteObject(result);
132+
133+
PSSnapshot psResult = new PSSnapshot();
134+
Mapper.Map<Snapshot, PSSnapshot>(result, psResult);
135+
WriteObject(psResult);
130136
}
131137
});
132138
}

src/ResourceManager/Compute/Commands.Compute/Generated/Snapshot/SnapshotUpdateMethod.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,23 @@ public partial class UpdateAzureRmSnapshot : ComputeAutomationBaseCmdlet
121121
{
122122
protected override void ProcessRecord()
123123
{
124+
ComputeAutomationAutoMapperProfile.Initialize();
124125
ExecuteClientAction(() =>
125126
{
126127
if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
127128
{
128-
129129
string resourceGroupName = this.ResourceGroupName;
130130
string snapshotName = this.SnapshotName;
131-
PSSnapshotUpdate snapshot = this.SnapshotUpdate;
132-
PSSnapshot snapshotOrg = this.Snapshot;
133131

134-
var result = (snapshot == null)
135-
? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
136-
: SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);
132+
Snapshot snapshotObj = new Snapshot();
133+
Mapper.Map<PSSnapshot, Snapshot>(this.Snapshot, snapshotObj);
134+
135+
SnapshotUpdate snapshotUpdateObj = new SnapshotUpdate();
136+
Mapper.Map<PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotUpdateObj);
137+
138+
var result = (this.SnapshotUpdate == null)
139+
? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotObj)
140+
: SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotUpdateObj);
137141

138142
var psObject = new PSSnapshot();
139143
Mapper.Map<Snapshot, PSSnapshot>(result, psObject);

0 commit comments

Comments
 (0)