Skip to content

Commit

Permalink
[Az.EventHub] Get-AzEventHub accepts pipeline input from Get-AzEventH…
Browse files Browse the repository at this point in the history
…ubNamespace. (#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
  • Loading branch information
hakashya authored May 26, 2021
1 parent 1afea3b commit 6d85b80
Show file tree
Hide file tree
Showing 7 changed files with 717 additions and 795 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/EventHub/EventHub/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Added functionality to accept input from pipeline for `Get-AzEventHub` from `Get-AzEventHubNamespace`.

## Version 1.7.2
* Fixed that `New-AzServiceBusAuthorizationRuleSASToken` returns invalid token. [#12975]
Expand Down
23 changes: 18 additions & 5 deletions src/EventHub/EventHub/Cmdlets/EventHub/GetAzureEventHubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

using Microsoft.Azure.Commands.EventHub.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
Expand All @@ -25,34 +27,45 @@ namespace Microsoft.Azure.Commands.EventHub.Commands.EventHub
/// <para> If EventHub name provided, a single EventHub detials will be returned</para>
/// <para> If EventHub name not provided, list of EventHub will be returned</para>
/// </summary>
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "EventHub"), OutputType(typeof(PSEventHubAttributes))]
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "EventHub", DefaultParameterSetName = EventhubPropertiesParameterSet), OutputType(typeof(PSEventHubAttributes))]
public class GetAzureRmEventHub : AzureEventHubsCmdletBase
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 0, HelpMessage = "Resource Group Name")]
[Parameter(Mandatory = true, Position = 0, HelpMessage = "Resource Group Name", ParameterSetName= EventhubPropertiesParameterSet)]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 1, HelpMessage = "Namespace Name")]
[Parameter(Mandatory = true, Position = 1, HelpMessage = "Namespace Name", ParameterSetName = EventhubPropertiesParameterSet)]
[ValidateNotNullOrEmpty]
[Alias(AliasNamespaceName)]
public string Namespace { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, Position = 2, HelpMessage = "EventHub Name")]
[Parameter(Mandatory = false, Position = 2, HelpMessage = "EventHub Name", ParameterSetName = EventhubPropertiesParameterSet)]
[Parameter(Mandatory = false, Position = 1, HelpMessage = "EventHub Name", ParameterSetName = NamespaceInputObjectParameterSet)]
[Alias(AliasEventHubName)]
public string Name { get; set; }

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

[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "Namespace object", ParameterSetName = NamespaceInputObjectParameterSet)]
[ValidateNotNull]
public PSNamespaceAttributes NamespaceObject { get; set; }

/// <summary>
///
/// </summary>
public override void ExecuteCmdlet()
{
try
{
if (this.IsParameterBound(c => c.NamespaceObject))
{
this.ResourceGroupName = this.NamespaceObject.ResourceGroupName;
this.Namespace = this.NamespaceObject.Name;
}

if (!string.IsNullOrEmpty(Name))
{
// Get a EventHub
Expand Down
38 changes: 30 additions & 8 deletions src/EventHub/EventHub/help/Get-AzEventHub.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.EventHub.dll-Help.xml
Module Name: Az.EventHub
online version: https://docs.microsoft.com/powershell/module/az.eventhub/get-azeventhub
Expand All @@ -12,11 +12,18 @@ Gets the details of a single Event Hub, or gets a list of Event Hubs.

## SYNTAX

### EventhubPropertiesSet (Default)
```
Get-AzEventHub [-ResourceGroupName] <String> [-Namespace] <String> [[-Name] <String>] [-MaxCount <Int32>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### NamespaceInputObjectSet
```
Get-AzEventHub [[-Name] <String>] [-NamespaceObject] <PSNamespaceAttributes>
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
The Get-AzEventHub cmdlet returns either the details of an Event Hub, or a list of all Event Hubs in the current namespace.
If the Event Hub name is provided, the details of a single Event Hub are returned.
Expand Down Expand Up @@ -60,7 +67,7 @@ Determine the maximum number of EventHubs to return.
```yaml
Type: System.Nullable`1[System.Int32]
Parameter Sets: (All)
Parameter Sets: EventhubPropertiesSet
Aliases:

Required: False
Expand All @@ -81,7 +88,7 @@ Aliases: EventHubName
Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept pipeline input: False
Accept wildcard characters: False
```
Expand All @@ -90,13 +97,28 @@ Namespace Name
```yaml
Type: System.String
Parameter Sets: (All)
Parameter Sets: EventhubPropertiesSet
Aliases: NamespaceName

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept pipeline input: False
Accept wildcard characters: False
```
### -NamespaceObject
Namespace object
```yaml
Type: Microsoft.Azure.Commands.EventHub.Models.PSNamespaceAttributes
Parameter Sets: NamespaceInputObjectSet
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
Expand All @@ -105,18 +127,18 @@ Resource Group Name
```yaml
Type: System.String
Parameter Sets: (All)
Parameter Sets: EventhubPropertiesSet
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
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).
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).
## INPUTS
Expand Down
4 changes: 2 additions & 2 deletions src/EventHub/EventHub/help/Get-AzEventHubNamespace.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.EventHub.dll-Help.xml
Module Name: Az.EventHub
online version: https://docs.microsoft.com/powershell/module/az.eventhub/get-azeventhubnamespace
Expand Down Expand Up @@ -95,7 +95,7 @@ Accept wildcard characters: False
```
### CommonParameters
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).
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).
## INPUTS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
"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 comments on commit 6d85b80

Please sign in to comment.