Skip to content

Commit 2208c83

Browse files
authored
Merge pull request Azure#3478 from v-Ajnava/EventHub_pwr
EventHub - Included format.ps1xml for Sku property
2 parents 312e556 + f83bdd1 commit 2208c83

File tree

12 files changed

+239
-59
lines changed

12 files changed

+239
-59
lines changed

src/ResourceManager/EventHub/AzureRM.EventHub.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '2.5.0'; }
6363
# TypesToProcess = @()
6464

6565
# Format files (.ps1xml) to be loaded when importing this module
66-
# FormatsToProcess = @()
66+
FormatsToProcess = '.\Microsoft.Azure.Commands.EventHub.format.ps1xml'
6767

6868
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
6969
NestedModules = @('.\Microsoft.Azure.Commands.EventHub.dll')

src/ResourceManager/EventHub/ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
## Current Release
77
* Overview of change #1
8-
- Additional information about change #1
8+
- Added EventHub - NameSpace, EventHub, and ConsumerGroup cmdlets #1
99
* Overview of change #2
1010
- Additional information about change #2
1111
- Additional information about change #2
@@ -21,8 +21,11 @@
2121

2222
## Version 0.0.2
2323

24+
* Future Breaking Change Notification: We've added a warning about removing property 'ResourceGroupName' from the returned NamespceAttributes from cmdlets New-AzureRmEventHubNamespace, Get-AzureRmEvnetHubNamespace and Set-AzureRmEvnetHubNamespace
25+
2426
## Version 0.0.1
2527
* Adds commandlets for the Azure EventHub
28+
2629
- New-AzureRmEventHubNamespace
2730
- Adds a New EventHub NameSpace in the existing Resource Group.
2831
- Get-AzureRmEventHubNamespace

src/ResourceManager/EventHub/Commands.EventHub.Test/ScenarioTests/Common.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function Get-Location
4444
}
4545
}
4646

47-
return "WestUS"
47+
return "West US"
4848
}
4949

5050
<#
@@ -68,5 +68,5 @@ function Get-SecondaryLocation
6868
}
6969
}
7070

71-
return "EastUS"
71+
return "East US"
7272
}

src/ResourceManager/EventHub/Commands.EventHub.Test/ScenarioTests/ConsumerGroupsTests.ps1

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,14 @@ function ConsumerGroupsTests
7676
Assert-True {$createdNamespace.Count -eq 1}
7777

7878
$found = 0
79-
for ($i = 0; $i -lt $createdNamespace.Count; $i++)
80-
{
81-
if ($createdNamespace[$i].Name -eq $namespaceName)
79+
80+
if ($createdNamespace.Name -eq $namespaceName)
8281
{
8382
$found = 1
84-
Assert-AreEqual $location $createdNamespace[$i].Location
85-
Assert-AreEqual $resourceGroupName $createdNamespace[$i].ResourceGroupName
86-
Assert-AreEqual "EventHub" $createdNamespace[$i].NamespaceType
83+
Assert-AreEqual $location $createdNamespace.Location
8784
break
8885
}
89-
}
86+
9087

9188
Assert-True {$found -eq 0} "Namespace created earlier is not found."
9289

src/ResourceManager/EventHub/Commands.EventHub.Test/ScenarioTests/EventHubsTests.ps1

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,16 @@ function EventHubsTests
8787
Assert-True {$createdNamespace.Count -eq 1}
8888

8989
$found = 0
90-
for ($i = 0; $i -lt $createdNamespace.Count; $i++)
91-
{
92-
if ($createdNamespace[$i].Name -eq $namespaceName)
90+
91+
if ($createdNamespace.Name -eq $namespaceName)
9392
{
9493
$found = 1
95-
Assert-AreEqual $location $createdNamespace[$i].Location
96-
Assert-AreEqual $resourceGroupName $createdNamespace[$i].ResourceGroupName
97-
Assert-AreEqual "EventHub" $createdNamespace[$i].NamespaceType
94+
Assert-AreEqual $location $createdNamespace.Location
9895
break
9996
}
100-
}
97+
10198
Assert-True {$found -eq 0} "Namespace created earlier is not found."
10299

103-
104100
# Create a EventHub
105101
Write-Debug " Create new eventHub "
106102
$msgRetentionInDays = 3
@@ -123,7 +119,7 @@ function EventHubsTests
123119
$found = 0
124120
for ($i = 0; $i -lt $createdEventHubList.Count; $i++)
125121
{
126-
if ($createdEventHubList[$i].Name -eq $createdEventHub)
122+
if ($createdEventHubList[$i].Name -eq $createdEventHub.Name)
127123
{
128124
$found = $found + 1
129125
}
@@ -190,17 +186,13 @@ function EventHubsAuthTests
190186
# Assert
191187
Assert-True {$createdNamespace.Count -eq 1}
192188
$found = 0
193-
for ($i = 0; $i -lt $createdNamespace.Count; $i++)
194-
{
195-
if ($createdNamespace[$i].Name -eq $namespaceName)
189+
190+
if ($createdNamespace.Name -eq $namespaceName)
196191
{
197192
$found = 1
198-
Assert-AreEqual $location $createdNamespace[$i].Location
199-
Assert-AreEqual $resourceGroupName $createdNamespace[$i].ResourceGroupName
200-
Assert-AreEqual "EventHub" $createdNamespace[$i].NamespaceType
193+
Assert-AreEqual $location $createdNamespace.Location
201194
break
202195
}
203-
}
204196

205197
# Assert
206198
Assert-True {$found -eq 0} "Namespace created earlier is not found."

src/ResourceManager/EventHub/Commands.EventHub.Test/ScenarioTests/NamespaceTests.ps1

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,13 @@ function NamespaceAuthTests
7676
Assert-True {$createdNamespace.Count -eq 1}
7777

7878
$found = 0
79-
for ($i = 0; $i -lt $createdNamespace.Count; $i++)
80-
{
81-
if ($createdNamespace[$i].Name -eq $namespaceName)
79+
80+
if ($createdNamespace.Name -eq $namespaceName)
8281
{
8382
$found = 1
84-
Assert-AreEqual $location $createdNamespace[$i].Location
85-
Assert-AreEqual $resourceGroupName $createdNamespace[$i].ResourceGroupName
83+
Assert-AreEqual $location $createdNamespace.Location
8684
break
8785
}
88-
}
8986

9087
Assert-True {$found -eq 0} "Namespace created earlier is not found."
9188

@@ -231,17 +228,13 @@ function NamespaceTests
231228
Assert-True {$createdNamespace.Count -eq 1}
232229

233230
$found = 0
234-
for ($i = 0; $i -lt $createdNamespace.Count; $i++)
235-
{
236-
if ($createdNamespace[$i].Name -eq $namespaceName)
231+
232+
if ($createdNamespace.Name -eq $namespaceName)
237233
{
238234
$found = 1
239-
Assert-AreEqual $location $createdNamespace[$i].Location
240-
Assert-AreEqual $resourceGroupName $createdNamespace[$i].ResourceGroupName
241-
Assert-AreEqual "EventHub" $createdNamespace[$i].NamespaceType
235+
Assert-AreEqual $location $createdNamespace.Location
242236
break
243237
}
244-
}
245238

246239
Assert-True {$found -eq 0} "Namespace created earlier is not found."
247240

@@ -260,8 +253,6 @@ function NamespaceTests
260253
{
261254
$found = 1
262255
Assert-AreEqual $location $allCreatedNamespace[$i].Location
263-
Assert-AreEqual $secondResourceGroup $allCreatedNamespace[$i].ResourceGroupName
264-
Assert-AreEqual "EventHub" $allCreatedNamespace[$i].NamespaceType
265256
break
266257
}
267258
}
@@ -278,16 +269,12 @@ function NamespaceTests
278269
{
279270
$found = $found + 1
280271
Assert-AreEqual $location $allCreatedNamespace[$i].Location
281-
Assert-AreEqual $resourceGroupName $allCreatedNamespace[$i].ResourceGroupName
282-
Assert-AreEqual "EventHub" $allCreatedNamespace[$i].NamespaceType
283272
}
284273

285274
if ($allCreatedNamespace[$i].Name -eq $namespaceName2)
286275
{
287276
$found = $found + 1
288277
Assert-AreEqual $location $allCreatedNamespace[$i].Location
289-
Assert-AreEqual $secondResourceGroup $allCreatedNamespace[$i].ResourceGroupName
290-
Assert-AreEqual "EventHub" $allCreatedNamespace[$i].NamespaceType
291278
}
292279
}
293280

src/ResourceManager/EventHub/Commands.EventHub/Commands.EventHub.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@
153153
<None Include="..\AzureRM.EventHub.psd1">
154154
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
155155
</None>
156+
<None Include="Microsoft.Azure.Commands.EventHub.format.ps1xml">
157+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
158+
</None>
156159
<None Include="MSSharedLibKey.snk" />
157160
<None Include="packages.config">
158161
<SubType>Designer</SubType>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<Configuration>
3+
<ViewDefinitions>
4+
<View>
5+
<Name>Microsoft.Azure.Commands.EventHub.Models.NamespaceAttributes</Name>
6+
<ViewSelectedBy>
7+
<TypeName>Microsoft.Azure.Commands.EventHub.Models.NamespaceAttributes</TypeName>
8+
</ViewSelectedBy>
9+
<ListControl>
10+
<ListEntries>
11+
<ListEntry>
12+
<ListItems>
13+
<ListItem>
14+
<PropertyName>Name</PropertyName>
15+
</ListItem>
16+
<ListItem>
17+
<PropertyName>Id</PropertyName>
18+
</ListItem>
19+
<ListItem>
20+
<PropertyName>Location</PropertyName>
21+
</ListItem>
22+
<ListItem>
23+
<Label>Sku </Label>
24+
<ScriptBlock>"Name : " + $_.Sku.Name.ToString() + " , Capacity : " + $_.Sku.Capacity + " , Tier : " + $_.Sku.Tier.ToString() </ScriptBlock>
25+
</ListItem>
26+
<ListItem>
27+
<PropertyName>ProvisioningState</PropertyName>
28+
</ListItem>
29+
<ListItem>
30+
<PropertyName>Status</PropertyName>
31+
</ListItem>
32+
<ListItem>
33+
<PropertyName>CreatedAt</PropertyName>
34+
</ListItem>
35+
<ListItem>
36+
<PropertyName>UpdatedAt</PropertyName>
37+
</ListItem>
38+
<ListItem>
39+
<PropertyName>ServiceBusEndpoint</PropertyName>
40+
</ListItem>
41+
<ListItem>
42+
<PropertyName>Enabled</PropertyName>
43+
</ListItem>
44+
</ListItems>
45+
</ListEntry>
46+
</ListEntries>
47+
</ListControl>
48+
</View>
49+
</ViewDefinitions>
50+
</Configuration>

src/ResourceManager/EventHub/Commands.EventHub/Models/NamespaceAttributes.cs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,50 @@ public NamespaceAttributes(NamespaceResource evResource)
2929
{
3030
if (evResource != null)
3131
{
32-
Sku = evResource.Sku;
33-
ProvisioningState = evResource.ProvisioningState;
34-
Status = (Microsoft.Azure.Commands.EventHub.Models.NamespaceState)evResource.Status;
35-
CreatedAt = evResource.CreatedAt;
36-
UpdatedAt = evResource.UpdatedAt;
37-
ServiceBusEndpoint = evResource.ServiceBusEndpoint;
38-
Enabled = evResource.Enabled;
39-
Location = evResource.Location;
32+
Sku = new Sku
33+
{
34+
Capacity = evResource.Sku.Capacity,
35+
Name = evResource.Sku.Name,
36+
Tier = evResource.Sku.Tier
37+
};
38+
if (evResource.ProvisioningState != null)
39+
ProvisioningState = evResource.ProvisioningState;
40+
if(evResource.Status.HasValue)
41+
Status = (Microsoft.Azure.Commands.EventHub.Models.NamespaceState)evResource.Status;
42+
if(evResource.CreatedAt.HasValue)
43+
CreatedAt = evResource.CreatedAt;
44+
if(evResource.UpdatedAt.HasValue)
45+
UpdatedAt = evResource.UpdatedAt;
46+
if(evResource.ServiceBusEndpoint != null)
47+
ServiceBusEndpoint = evResource.ServiceBusEndpoint;
48+
if(evResource.Enabled.HasValue)
49+
Enabled = evResource.Enabled;
50+
if(evResource.Location != null)
51+
Location = evResource.Location;
52+
if(evResource.Id != null)
53+
Id = evResource.Id;
54+
if (evResource.Name != null)
55+
Name = evResource.Name;
4056

4157
}
4258
}
43-
59+
4460
/// <summary>
4561
/// Gets or sets the name of the resource group the Namespace is in
4662
/// </summary>
63+
[ObsoleteAttribute("ResourceGroupName property is obsolete.", false)]
4764
public string ResourceGroupName { get; set; }
4865

4966
/// <summary>
5067
/// Gets or sets the Id of the Namespace
5168
/// </summary>
5269
public string Id { get; set; }
5370

71+
/// <summary>
72+
/// Gets or sets the Name of the Namespace
73+
/// </summary>
74+
public string Name { get; set; }
75+
5476
/// <summary>
5577
/// Gets or sets the Id of the Namespace
5678
/// </summary>

src/ResourceManager/EventHub/Commands.EventHub/Utilities/EventHubsClient.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,27 @@ public NamespaceAttributes UpdateNamespace(string resourceGroupName, string name
9898
{
9999
Location = location
100100
};
101-
101+
102102
if(state.HasValue)
103103
{
104104
parameter.Status = state;
105105
}
106106

107+
Sku tempSku = new Sku();
108+
107109
if (skuName != null)
108110
{
109-
parameter.Sku.Name = skuName;
110-
parameter.Sku.Tier = skuName;
111+
tempSku.Name = skuName;
112+
tempSku.Tier = skuName;
111113
}
112114

113115
if (skuCapacity.HasValue)
114116
{
115-
parameter.Sku.Capacity = skuCapacity;
117+
tempSku.Capacity = skuCapacity;
116118
}
117119

120+
parameter.Sku = tempSku;
121+
118122
if (tags != null && tags.Count() > 0)
119123
{
120124
parameter.Tags = new Dictionary<string, string>(tags);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!--
2+
Please leave this section at the top of the breaking change documentation.
3+
4+
New breaking changes should go under the section titled "Current Breaking Changes", and should adhere to the following format:
5+
6+
## Current Breaking Changes
7+
8+
The following cmdlets were affected this release:
9+
10+
**Cmdlet 1**
11+
- Description of what has changed
12+
13+
```powershell
14+
# Old
15+
# Sample of how the cmdlet was previously called
16+
17+
# New
18+
# Sample of how the cmdlet should now be called
19+
```
20+
21+
## Release X.0.0
22+
23+
The following cmdlets were affected this release:
24+
25+
**Cmdlet 1**
26+
- Description of what has changed
27+
28+
```powershell
29+
# Old
30+
# Sample of how the cmdlet was previously called
31+
32+
# New
33+
# Sample of how the cmdlet should now be called
34+
```
35+
36+
Note: the above sections follow the template found in the link below:
37+
38+
https://github.com/Azure/azure-powershell/blob/dev/documentation/breaking-changes/breaking-change-template.md
39+
-->
40+
41+
## Current Breaking Changes

0 commit comments

Comments
 (0)