Skip to content

Commit 6d85b80

Browse files
authored
[Az.EventHub] Get-AzEventHub accepts pipeline input from Get-AzEventHubNamespace. (#13732)
* Modified to accept pipeline input from Get-AzEventHubNamespace * Successful Test Records * Updating Help markdown files and changelog.md * Added Static Analyser exception * Correcting breaking change
1 parent 1afea3b commit 6d85b80

File tree

7 files changed

+717
-795
lines changed

7 files changed

+717
-795
lines changed

src/EventHub/EventHub.Test/SessionRecords/Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.EventHubsTests/EventHubsAuthorizationRulesCRUD.json

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

src/EventHub/EventHub.Test/SessionRecords/Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.EventHubsTests/EventHubsCRUD.json

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

src/EventHub/EventHub/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added functionality to accept input from pipeline for `Get-AzEventHub` from `Get-AzEventHubNamespace`.
2122

2223
## Version 1.7.2
2324
* Fixed that `New-AzServiceBusAuthorizationRuleSASToken` returns invalid token. [#12975]

src/EventHub/EventHub/Cmdlets/EventHub/GetAzureEventHubs.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
using Microsoft.Azure.Commands.EventHub.Models;
1616
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
17+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
18+
using System;
1719
using System.Collections.Generic;
1820
using System.Linq;
1921
using System.Management.Automation;
@@ -25,34 +27,45 @@ namespace Microsoft.Azure.Commands.EventHub.Commands.EventHub
2527
/// <para> If EventHub name provided, a single EventHub detials will be returned</para>
2628
/// <para> If EventHub name not provided, list of EventHub will be returned</para>
2729
/// </summary>
28-
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "EventHub"), OutputType(typeof(PSEventHubAttributes))]
30+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "EventHub", DefaultParameterSetName = EventhubPropertiesParameterSet), OutputType(typeof(PSEventHubAttributes))]
2931
public class GetAzureRmEventHub : AzureEventHubsCmdletBase
3032
{
31-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 0, HelpMessage = "Resource Group Name")]
33+
[Parameter(Mandatory = true, Position = 0, HelpMessage = "Resource Group Name", ParameterSetName= EventhubPropertiesParameterSet)]
3234
[ResourceGroupCompleter]
3335
[ValidateNotNullOrEmpty]
3436
public string ResourceGroupName { get; set; }
3537

36-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 1, HelpMessage = "Namespace Name")]
38+
[Parameter(Mandatory = true, Position = 1, HelpMessage = "Namespace Name", ParameterSetName = EventhubPropertiesParameterSet)]
3739
[ValidateNotNullOrEmpty]
3840
[Alias(AliasNamespaceName)]
3941
public string Namespace { get; set; }
4042

41-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, Position = 2, HelpMessage = "EventHub Name")]
43+
[Parameter(Mandatory = false, Position = 2, HelpMessage = "EventHub Name", ParameterSetName = EventhubPropertiesParameterSet)]
44+
[Parameter(Mandatory = false, Position = 1, HelpMessage = "EventHub Name", ParameterSetName = NamespaceInputObjectParameterSet)]
4245
[Alias(AliasEventHubName)]
4346
public string Name { get; set; }
4447

45-
[Parameter(Mandatory = false, HelpMessage = "Determine the maximum number of EventHubs to return.")]
48+
[Parameter(Mandatory = false, HelpMessage = "Determine the maximum number of EventHubs to return.", ParameterSetName = EventhubPropertiesParameterSet)]
4649
[ValidateNotNull]
4750
public int? MaxCount { get; set; }
4851

52+
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "Namespace object", ParameterSetName = NamespaceInputObjectParameterSet)]
53+
[ValidateNotNull]
54+
public PSNamespaceAttributes NamespaceObject { get; set; }
55+
4956
/// <summary>
5057
///
5158
/// </summary>
5259
public override void ExecuteCmdlet()
5360
{
5461
try
5562
{
63+
if (this.IsParameterBound(c => c.NamespaceObject))
64+
{
65+
this.ResourceGroupName = this.NamespaceObject.ResourceGroupName;
66+
this.Namespace = this.NamespaceObject.Name;
67+
}
68+
5669
if (!string.IsNullOrEmpty(Name))
5770
{
5871
// Get a EventHub

src/EventHub/EventHub/help/Get-AzEventHub.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.EventHub.dll-Help.xml
33
Module Name: Az.EventHub
44
online version: https://docs.microsoft.com/powershell/module/az.eventhub/get-azeventhub
@@ -12,11 +12,18 @@ Gets the details of a single Event Hub, or gets a list of Event Hubs.
1212

1313
## SYNTAX
1414

15+
### EventhubPropertiesSet (Default)
1516
```
1617
Get-AzEventHub [-ResourceGroupName] <String> [-Namespace] <String> [[-Name] <String>] [-MaxCount <Int32>]
1718
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1819
```
1920

21+
### NamespaceInputObjectSet
22+
```
23+
Get-AzEventHub [[-Name] <String>] [-NamespaceObject] <PSNamespaceAttributes>
24+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
25+
```
26+
2027
## DESCRIPTION
2128
The Get-AzEventHub cmdlet returns either the details of an Event Hub, or a list of all Event Hubs in the current namespace.
2229
If the Event Hub name is provided, the details of a single Event Hub are returned.
@@ -60,7 +67,7 @@ Determine the maximum number of EventHubs to return.
6067
6168
```yaml
6269
Type: System.Nullable`1[System.Int32]
63-
Parameter Sets: (All)
70+
Parameter Sets: EventhubPropertiesSet
6471
Aliases:
6572

6673
Required: False
@@ -81,7 +88,7 @@ Aliases: EventHubName
8188
Required: False
8289
Position: 2
8390
Default value: None
84-
Accept pipeline input: True (ByPropertyName)
91+
Accept pipeline input: False
8592
Accept wildcard characters: False
8693
```
8794
@@ -90,13 +97,28 @@ Namespace Name
9097
9198
```yaml
9299
Type: System.String
93-
Parameter Sets: (All)
100+
Parameter Sets: EventhubPropertiesSet
94101
Aliases: NamespaceName
95102

96103
Required: True
97104
Position: 1
98105
Default value: None
99-
Accept pipeline input: True (ByPropertyName)
106+
Accept pipeline input: False
107+
Accept wildcard characters: False
108+
```
109+
110+
### -NamespaceObject
111+
Namespace object
112+
113+
```yaml
114+
Type: Microsoft.Azure.Commands.EventHub.Models.PSNamespaceAttributes
115+
Parameter Sets: NamespaceInputObjectSet
116+
Aliases:
117+
118+
Required: True
119+
Position: 0
120+
Default value: None
121+
Accept pipeline input: True (ByValue)
100122
Accept wildcard characters: False
101123
```
102124
@@ -105,18 +127,18 @@ Resource Group Name
105127
106128
```yaml
107129
Type: System.String
108-
Parameter Sets: (All)
130+
Parameter Sets: EventhubPropertiesSet
109131
Aliases:
110132

111133
Required: True
112134
Position: 0
113135
Default value: None
114-
Accept pipeline input: True (ByPropertyName)
136+
Accept pipeline input: False
115137
Accept wildcard characters: False
116138
```
117139
118140
### CommonParameters
119-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
141+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
120142
121143
## INPUTS
122144

src/EventHub/EventHub/help/Get-AzEventHubNamespace.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.EventHub.dll-Help.xml
33
Module Name: Az.EventHub
44
online version: https://docs.microsoft.com/powershell/module/az.eventhub/get-azeventhubnamespace
@@ -95,7 +95,7 @@ Accept wildcard characters: False
9595
```
9696
9797
### CommonParameters
98-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
98+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
9999
100100
## INPUTS
101101
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
2+
"Az.EventHub","Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureRmEventHub","Get-AzEventHub","0","1050","The parameter set '__AllParameterSets' for cmdlet 'Get-AzEventHub' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'Get-AzEventHub'."

0 commit comments

Comments
 (0)