Skip to content

Commit 9021d4e

Browse files
committed
PR fixes
1 parent 1bfae1e commit 9021d4e

23 files changed

+5315
-10514
lines changed

src/ResourceManager/PowerBI/ChangeLog.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
-->
2020
## Current Release
2121

22-
## Version 1.0.0
2322
* New Cmdlet Get-AzureRmPowerBIEmbeddedCapacity
2423
Gets the details of a PowerBI Embedded Capacity.
2524
* New Cmdlet New-AzureRmPowerBIEmbeddedCapacity

src/ResourceManager/PowerBI/Commands.PowerBI.Test/ScenarioTests/PowerBITests.ps1

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ function Test-PowerBIEmbeddedCapacity
2525
[array]$capacityGet = Get-AzureRmPowerBIEmbeddedCapacity -ResourceGroupName $resourceGroupName -Name $capacityName
2626
$capacityGetItem = $capacityGet[0]
2727

28-
Assert-True {$capacityGetItem.ProvisioningState -like "Succeeded"}
2928
Assert-True {$capacityGetItem.State -like "Succeeded"}
30-
3129
Assert-AreEqual $capacityName $capacityGetItem.Name
3230
Assert-AreEqual $location $capacityGetItem.Location
31+
Assert-AreEqual $resourceGroupName $capacityGetItem.ResourceGroup
3332
Assert-AreEqual "Microsoft.PowerBIDedicated/capacities" $capacityGetItem.Type
3433
Assert-True {$capacityGetItem.Id -like "*$resourceGroupName*"}
3534

3635
# Test to make sure the capacity does exist
37-
Assert-True {Test-AzureRmPowerBIEmbeddedCapacity -ResourceGroupName $resourceGroupName -Name $capacityName}
36+
Assert-True {Test-AzureRmPowerBIEmbeddedCapacity -Name $capacityName}
3837
# Test it without specifying a resource group
3938
Assert-True {Test-AzureRmPowerBIEmbeddedCapacity -Name $capacityName}
4039

@@ -97,14 +96,13 @@ function Test-PowerBIEmbeddedCapacity
9796
$capacityGetItem = Suspend-AzureRmPowerBIEmbeddedCapacity -ResourceGroupName $resourceGroupName -Name $capacityName -PassThru
9897
# this is to ensure backward compatibility compatibility. The servie side would make change to differenciate state and provisioningState in future
9998
Assert-True {$capacityGetItem.State -like "Paused"}
100-
Assert-True {$capacityGetItem.ProvisioningState -like "Paused"}
99+
Assert-AreEqual $resourceGroupName $capacityGetItem.ResourceGroup
101100

102101
# Resume PowerBI Embedded capacity
103102
$capacityGetItem = Resume-AzureRmPowerBIEmbeddedCapacity -ResourceGroupName $resourceGroupName -Name $capacityName -PassThru
104103
[array]$capacityGet = Get-AzureRmPowerBIEmbeddedCapacity -ResourceId $capacityGetItem.Id
105104
$capacityGetItem = $capacityGet[0]
106105
Assert-AreEqual $capacityGetItem.Name $capacityGetItem.Name
107-
Assert-True {$capacityGetItem.ProvisioningState -like "Succeeded"}
108106
Assert-True {$capacityGetItem.State -like "Succeeded"}
109107

110108
# Delete PowerBI Embedded capacity
@@ -148,9 +146,7 @@ function Test-PowerBIEmbeddedCapacityScale
148146
[array]$capacityGet = Get-AzureRmPowerBIEmbeddedCapacity -ResourceGroupName $resourceGroupName -Name $capacityName
149147
$capacityGetItem = $capacityGet[0]
150148

151-
Assert-True {$capacityGetItem.ProvisioningState -like "Succeeded"}
152149
Assert-True {$capacityGetItem.State -like "Succeeded"}
153-
154150
Assert-AreEqual $capacityName $capacityGetItem.Name
155151
Assert-AreEqual $location $capacityGetItem.Location
156152
Assert-AreEqual A1 $capacityGetItem.Sku

src/ResourceManager/PowerBI/Commands.PowerBI.Test/SessionRecords/Microsoft.Azure.Commands.PowerBI.Test.ScenarioTests.PowerBITests/TestNegativePBIECapacity.json

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

src/ResourceManager/PowerBI/Commands.PowerBI.Test/SessionRecords/Microsoft.Azure.Commands.PowerBI.Test.ScenarioTests.PowerBITests/TestPBIECapacity.json

Lines changed: 4637 additions & 9737 deletions
Large diffs are not rendered by default.

src/ResourceManager/PowerBI/Commands.PowerBI.Test/SessionRecords/Microsoft.Azure.Commands.PowerBI.Test.ScenarioTests.PowerBITests/TestPBIECapacityScale.json

Lines changed: 337 additions & 406 deletions
Large diffs are not rendered by default.

src/ResourceManager/PowerBI/Commands.PowerBI/Commands.PowerBI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<Compile Include="Commands\UpdateAzureRmPowerBIEmbeddedCapacity.cs" />
6666
<Compile Include="Commands\SuspendAzureRmPowerBIEmbeddedCapacity.cs" />
6767
<Compile Include="Commands\TestAzureRmPowerBIEmbeddedCapacity.cs" />
68-
<Compile Include="Models\PSDedicatedCapacity.cs" />
68+
<Compile Include="Models\PSPowerBIEmbeddedCapacity.cs" />
6969
<Compile Include="Models\PowerBIClient.cs" />
7070
<Compile Include="Models\PowerBICmdletBase.cs" />
7171
<Compile Include="Models\StringOrByteArrayInstance.cs" />

src/ResourceManager/PowerBI/Commands.PowerBI/Commands/GetAzureRmPowerBIEmbeddedCapacity.cs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,22 @@
2121

2222
namespace Microsoft.Azure.Commands.PowerBI
2323
{
24-
[Cmdlet(VerbsCommon.Get, "AzureRmPowerBIEmbeddedCapacity"),
25-
OutputType(typeof(List<PSDedicatedCapacity>))]
24+
[Cmdlet(VerbsCommon.Get, "AzureRmPowerBIEmbeddedCapacity", DefaultParameterSetName = ParameterSet),
25+
OutputType(typeof(List<PSPowerBIEmbeddedCapacity>))]
2626
public class GetAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
2727
{
28-
protected const string ResourceGroupParameterSet = "ByResourceGroup";
29-
protected const string CapacityParameterSet = "ByCapacity";
28+
protected const string ParameterSet = "ByCapacityOrResourceGroupOrSubscription";
3029
protected const string ResourceIdParameterSet = "ByResourceId";
3130

3231
[Parameter(
33-
ParameterSetName = ResourceGroupParameterSet,
34-
Mandatory = false,
35-
HelpMessage = "Name of resource group under which the user want to retrieve the capacity.")]
36-
[Parameter(
37-
ParameterSetName = CapacityParameterSet,
32+
ParameterSetName = ParameterSet,
3833
Mandatory = false,
3934
HelpMessage = "Name of resource group under which the user want to retrieve the capacity.")]
4035
public string ResourceGroupName { get; set; }
4136

4237
[Parameter(
43-
ParameterSetName = CapacityParameterSet,
44-
Mandatory = true,
45-
Position = 0,
38+
ParameterSetName = ParameterSet,
39+
Mandatory = false,
4640
HelpMessage = "Name of a specific capacity.")]
4741
public string Name { get; set; }
4842

@@ -55,27 +49,25 @@ public class GetAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
5549

5650
public override void ExecuteCmdlet()
5751
{
58-
string resourceGroupName = string.Empty;
59-
string capacityName = string.Empty;
52+
string resourceGroupName = ResourceGroupName;
53+
string capacityName = Name;
6054

6155
if (!string.IsNullOrEmpty(ResourceId))
6256
{
6357
PowerBIUtils.GetResourceGroupNameAndCapacityName(ResourceId, out resourceGroupName, out capacityName);
64-
ResourceGroupName = resourceGroupName;
65-
Name = capacityName;
6658
}
6759

68-
if (!string.IsNullOrEmpty(Name))
60+
if (!string.IsNullOrEmpty(capacityName))
6961
{
7062
// Get for single capacity
71-
var capacity = PowerBIClient.GetCapacity(ResourceGroupName, Name);
63+
var capacity = PowerBIClient.GetCapacity(resourceGroupName, capacityName);
7264
WriteObject(capacity);
7365
}
7466
else
7567
{
7668
// List all capacities in given resource group if avaliable otherwise all capacities in the subscription
77-
var list = PowerBIClient.ListCapacities(ResourceGroupName);
78-
list.ForEach(capacity => WriteObject(capacity));
69+
var list = PowerBIClient.ListCapacities(resourceGroupName);
70+
WriteObject(list, true);
7971
}
8072
}
8173
}

src/ResourceManager/PowerBI/Commands.PowerBI/Commands/NewAzureRmPowerBIEmbeddedCapacity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace Microsoft.Azure.Commands.PowerBI
2424
{
2525
[Cmdlet(VerbsCommon.New, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true),
26-
OutputType(typeof(PSDedicatedCapacity))]
26+
OutputType(typeof(PSPowerBIEmbeddedCapacity))]
2727
public class NewPowerBIEmbeddedCapacity : PowerBICmdletBase
2828
{
2929
[Parameter(

src/ResourceManager/PowerBI/Commands.PowerBI/Commands/RemoveAzureRmPowerBIEmbeddedCapacity.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace Microsoft.Azure.Commands.PowerBI
2525
{
26-
[Cmdlet(VerbsCommon.Remove, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true),
27-
OutputType(typeof(PSDedicatedCapacity))]
26+
[Cmdlet(VerbsCommon.Remove, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true, DefaultParameterSetName = CmdletParametersSet),
27+
OutputType(typeof(PSPowerBIEmbeddedCapacity))]
2828
public class RemovePowerBIEmbeddedCapacity : PowerBICmdletBase
2929
{
3030
protected const string CmdletParametersSet = "ByNameAndResourceGroup";
@@ -62,22 +62,18 @@ public class RemovePowerBIEmbeddedCapacity : PowerBICmdletBase
6262
ValueFromPipeline = true,
6363
HelpMessage = "PowerBI Embedded Capacity object.")]
6464
[ValidateNotNullOrEmpty]
65-
public PSDedicatedCapacity InputObject { get; set; }
65+
public PSPowerBIEmbeddedCapacity InputObject { get; set; }
6666

6767
[Parameter(Mandatory = false)]
6868
public SwitchParameter PassThru { get; set; }
6969

7070
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
7171
public override void ExecuteCmdlet()
7272
{
73-
string capacityName = string.Empty;
73+
string capacityName = Name;
7474
string resourceGroupName = ResourceGroupName;
7575

76-
if (!string.IsNullOrEmpty(Name))
77-
{
78-
capacityName = Name;
79-
}
80-
else if (!string.IsNullOrEmpty(ResourceId))
76+
if (!string.IsNullOrEmpty(ResourceId))
8177
{
8278
PowerBIUtils.GetResourceGroupNameAndCapacityName(ResourceId, out resourceGroupName, out capacityName);
8379
}
@@ -93,7 +89,7 @@ public override void ExecuteCmdlet()
9389

9490
if (ShouldProcess(capacityName, Resources.RemovingPowerBIEmbeddedCapacity))
9591
{
96-
PSDedicatedCapacity capacity = null;
92+
PSPowerBIEmbeddedCapacity capacity = null;
9793
if (!PowerBIClient.TestCapacity(resourceGroupName, capacityName, out capacity))
9894
{
9995
throw new InvalidOperationException(string.Format(Properties.Resources.CapacityDoesNotExist, capacityName));

src/ResourceManager/PowerBI/Commands.PowerBI/Commands/ResumeAzureRmPowerBIEmbeddedCapacity.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace Microsoft.Azure.Commands.PowerBI
2525
{
26-
[Cmdlet(VerbsLifecycle.Resume, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true),
27-
OutputType(typeof(PSDedicatedCapacity))]
26+
[Cmdlet(VerbsLifecycle.Resume, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true, DefaultParameterSetName = CmdletParametersSet),
27+
OutputType(typeof(PSPowerBIEmbeddedCapacity))]
2828
public class ResumeAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
2929
{
3030
protected const string CmdletParametersSet = "ByNameAndResourceGroup";
@@ -62,21 +62,17 @@ public class ResumeAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
6262
ValueFromPipeline = true,
6363
HelpMessage = "PowerBI Embedded Capacity object.")]
6464
[ValidateNotNullOrEmpty]
65-
public PSDedicatedCapacity InputObject { get; set; }
65+
public PSPowerBIEmbeddedCapacity InputObject { get; set; }
6666

6767
[Parameter(Mandatory = false)]
6868
public SwitchParameter PassThru { get; set; }
6969

7070
public override void ExecuteCmdlet()
7171
{
72-
string capacityName = string.Empty;
72+
string capacityName = Name;
7373
string resourceGroupName = ResourceGroupName;
7474

75-
if (!string.IsNullOrEmpty(Name))
76-
{
77-
capacityName = Name;
78-
}
79-
else if (!string.IsNullOrEmpty(this.ResourceId))
75+
if (!string.IsNullOrEmpty(this.ResourceId))
8076
{
8177
PowerBIUtils.GetResourceGroupNameAndCapacityName(ResourceId, out resourceGroupName, out capacityName);
8278
}
@@ -92,7 +88,7 @@ public override void ExecuteCmdlet()
9288

9389
if (ShouldProcess(capacityName, Resources.ResumingPowerBIEmbeddedCapacity))
9490
{
95-
PSDedicatedCapacity capacity = null;
91+
PSPowerBIEmbeddedCapacity capacity = null;
9692
if (!PowerBIClient.TestCapacity(resourceGroupName, capacityName, out capacity))
9793
{
9894
throw new InvalidOperationException(string.Format(Properties.Resources.CapacityDoesNotExist, capacityName));

src/ResourceManager/PowerBI/Commands.PowerBI/Commands/SuspendAzureRmPowerBIEmbeddedCapacity.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
namespace Microsoft.Azure.Commands.PowerBI
2525
{
26-
[Cmdlet(VerbsLifecycle.Suspend, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true),
27-
OutputType(typeof(PSDedicatedCapacity))]
26+
[Cmdlet(VerbsLifecycle.Suspend, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true, DefaultParameterSetName = CmdletParametersSet),
27+
OutputType(typeof(PSPowerBIEmbeddedCapacity))]
2828
public class SuspendAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
2929
{
3030
protected const string CmdletParametersSet = "ByNameAndResourceGroup";
@@ -62,21 +62,17 @@ public class SuspendAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
6262
ValueFromPipeline = true,
6363
HelpMessage = "PowerBI Embedded Capacity object.")]
6464
[ValidateNotNullOrEmpty]
65-
public PSDedicatedCapacity InputObject { get; set; }
65+
public PSPowerBIEmbeddedCapacity InputObject { get; set; }
6666

6767
[Parameter(Mandatory = false)]
6868
public SwitchParameter PassThru { get; set; }
6969

7070
public override void ExecuteCmdlet()
7171
{
72-
string capacityName = string.Empty;
72+
string capacityName = Name;
7373
string resourceGroupName = ResourceGroupName;
7474

75-
if (!string.IsNullOrEmpty(Name))
76-
{
77-
capacityName = Name;
78-
}
79-
else if (!string.IsNullOrEmpty(ResourceId))
75+
if (!string.IsNullOrEmpty(ResourceId))
8076
{
8177
PowerBIUtils.GetResourceGroupNameAndCapacityName(ResourceId, out resourceGroupName, out capacityName);
8278
}
@@ -87,7 +83,7 @@ public override void ExecuteCmdlet()
8783

8884
if (ShouldProcess(capacityName, Resources.SuspendingPowerBIEmbeddedCapacity))
8985
{
90-
PSDedicatedCapacity capacity = null;
86+
PSPowerBIEmbeddedCapacity capacity = null;
9187
if (!PowerBIClient.TestCapacity(resourceGroupName, capacityName, out capacity))
9288
{
9389
throw new InvalidOperationException(string.Format(Properties.Resources.CapacityDoesNotExist, capacityName));

src/ResourceManager/PowerBI/Commands.PowerBI/Commands/TestAzureRmPowerBIEmbeddedCapacity.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ public class TestAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
3030
[ValidateNotNullOrEmpty]
3131
public string Name { get; set; }
3232

33-
[Parameter(
34-
Mandatory = false,
35-
HelpMessage = "Name of resource group under which want to test the capacity.")]
36-
[ValidateNotNullOrEmpty]
37-
public string ResourceGroupName { get; set; }
38-
3933
public override void ExecuteCmdlet()
4034
{
41-
PSDedicatedCapacity capacity = null;
42-
WriteObject(PowerBIClient.TestCapacity(ResourceGroupName, Name, out capacity));
35+
PSPowerBIEmbeddedCapacity capacity = null;
36+
WriteObject(PowerBIClient.TestCapacity(string.Empty, Name, out capacity));
4337
}
4438
}
4539
}

src/ResourceManager/PowerBI/Commands.PowerBI/Commands/UpdateAzureRmPowerBIEmbeddedCapacity.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
namespace Microsoft.Azure.Commands.PowerBI
2626
{
27-
[Cmdlet(VerbsData.Update, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true),
28-
OutputType(typeof(PSDedicatedCapacity))]
27+
[Cmdlet(VerbsData.Update, "AzureRmPowerBIEmbeddedCapacity", SupportsShouldProcess = true, DefaultParameterSetName = CmdletParametersSet),
28+
OutputType(typeof(PSPowerBIEmbeddedCapacity))]
2929
public class UpdateAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
3030
{
3131
protected const string CmdletParametersSet = "ByNameAndResourceGroup";
@@ -84,21 +84,17 @@ public class UpdateAzurePowerBIEmbeddedCapacity : PowerBICmdletBase
8484
ValueFromPipeline = true,
8585
HelpMessage = "PowerBI Embedded Capacity object.")]
8686
[ValidateNotNullOrEmpty]
87-
public PSDedicatedCapacity InputObject { get; set; }
87+
public PSPowerBIEmbeddedCapacity InputObject { get; set; }
8888

8989
[Parameter(Mandatory = false)]
9090
public SwitchParameter PassThru { get; set; }
9191

9292
public override void ExecuteCmdlet()
9393
{
94-
string capacityName = string.Empty;
94+
string capacityName = Name;
9595
string resourceGroupName = ResourceGroupName;
9696

97-
if (!string.IsNullOrEmpty(Name))
98-
{
99-
capacityName = Name;
100-
}
101-
else if (!string.IsNullOrEmpty(ResourceId))
97+
if (!string.IsNullOrEmpty(ResourceId))
10298
{
10399
PowerBIUtils.GetResourceGroupNameAndCapacityName(ResourceId, out resourceGroupName, out capacityName);
104100
}
@@ -114,7 +110,7 @@ public override void ExecuteCmdlet()
114110

115111
if (ShouldProcess(capacityName, Resources.UpdatingPowerBIEmbeddedCapacity))
116112
{
117-
PSDedicatedCapacity currentCapacity = null;
113+
PSPowerBIEmbeddedCapacity currentCapacity = null;
118114
if (!PowerBIClient.TestCapacity(resourceGroupName, capacityName, out currentCapacity))
119115
{
120116
throw new InvalidOperationException(string.Format(Properties.Resources.CapacityDoesNotExist, capacityName));
@@ -132,7 +128,7 @@ public override void ExecuteCmdlet()
132128
Tag = TagsConversionHelper.CreateTagHashtable(currentCapacity.Tag);
133129
}
134130

135-
PSDedicatedCapacity updateCapacity = PowerBIClient.CreateOrUpdateCapacity(resourceGroupName, capacityName, location, Sku, Tag, Administrator, currentCapacity);
131+
PSPowerBIEmbeddedCapacity updateCapacity = PowerBIClient.CreateOrUpdateCapacity(resourceGroupName, capacityName, location, Sku, Tag, Administrator, currentCapacity);
136132

137133
if(PassThru.IsPresent)
138134
{

0 commit comments

Comments
 (0)