Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Az Eventgrid] Add new features for 2021-12-31 release #17608

Merged
merged 20 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ function SystemTopicEventSubscriptionTests {


Write-Debug "Deleting event subscription : $eventSubscriptionName for system topic : $topicName"
Remove-AzEventGridSystemTopicEventSubscription -ResourceGroup $resourceGroupName -SystemTopicName $topicName -EventSubscriptionName $eventSubscriptionName
Remove-AzEventGridSystemTopicEventSubscription -ResourceGroup $resourceGroupName -SystemTopicName $topicName -EventSubscriptionName $eventSubscriptionName -Force

Write-Debug "Deleting event subscription : $eventSubscriptionName for system topic : $topicName"
Remove-AzEventGridSystemTopicEventSubscription -ResourceGroup $resourceGroupName -SystemTopicName $topicName -EventSubscriptionName $eventSubscriptionName2
Remove-AzEventGridSystemTopicEventSubscription -ResourceGroup $resourceGroupName -SystemTopicName $topicName -EventSubscriptionName $eventSubscriptionName2 -Force


Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName -Force

#Write-Debug "Deleting topic: $topicName"
#Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2
Expand Down
10 changes: 5 additions & 5 deletions src/EventGrid/EventGrid.Test/ScenarioTests/SystemTopicTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ function SystemTopicTests {
Assert-True {$allCreatedTopics.PsSystemTopicsList.Count -ge 0} "Topics created earlier are not found."

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName -Force

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2 -Force

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName3
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName3 -Force


}
Expand Down Expand Up @@ -159,10 +159,10 @@ function SystemTopicIdentityTests {


Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName
Remove-AzEventGridSystemTopic -ResourceGroup $resourceGroupName -Name $topicName -Force

Write-Debug "Deleting topic: $topicName"
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2
Remove-AzEventGridSystemTopic -ResourceGroup $secondResourceGroup -Name $topicName2 -Force


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,48 @@ public class RemoveAzureRmEventGridSystemTopic : AzureEventGridCmdletBase
[ValidateNotNullOrEmpty]
public PSSystemTopic InputObject { get; set; }

/// <summary>
/// If present, do not ask for confirmation
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = EventGridConstants.ForceHelp)]
public SwitchParameter Force { get; set; }

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

public override void ExecuteCmdlet()
{
if (this.ShouldProcess(this.Name, $"Remove topic {this.Name} in resource group {this.ResourceGroupName}"))
string resourceGroupName = string.Empty;
string topicName = string.Empty;
if (!string.IsNullOrEmpty(this.Name))
{
string resourceGroupName = string.Empty;
string topicName = string.Empty;

if (!string.IsNullOrEmpty(this.Name))
{
resourceGroupName = this.ResourceGroupName;
topicName = this.Name;
}
else if (!string.IsNullOrEmpty(this.ResourceId))
{
EventGridUtils.GetResourceGroupNameAndTopicName(this.ResourceId, out resourceGroupName, out topicName);
}
else if (this.InputObject != null)
{
resourceGroupName = this.InputObject.ResourceGroupName;
topicName = this.InputObject.TopicName;
}
resourceGroupName = this.ResourceGroupName;
topicName = this.Name;
}
else if (!string.IsNullOrEmpty(this.ResourceId))
{
EventGridUtils.GetResourceGroupNameAndTopicName(this.ResourceId, out resourceGroupName, out topicName);
}
else if (this.InputObject != null)
{
resourceGroupName = this.InputObject.ResourceGroupName;
topicName = this.InputObject.TopicName;
}

this.Client.DeleteSystemTopic(resourceGroupName, topicName);
if (this.PassThru)
ConfirmAction(Force.IsPresent,
$"Remove topic {this.Name} in resource group {this.ResourceGroupName}",
$"Removing topic {this.Name} in resource group {this.ResourceGroupName}",
topicName,
() =>
{
this.WriteObject(true);
}
}
this.Client.DeleteSystemTopic(resourceGroupName, topicName);
if (PassThru)
{
WriteObject(true);
}
});

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,31 @@ public class RemoveAzureEventGridSystemTopicEventSubscription : AzureEventGridCm
[ValidateNotNullOrEmpty]
public string SystemTopicName { get; set; }

/// <summary>
/// If present, do not ask for confirmation
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = EventGridConstants.ForceHelp)]
public SwitchParameter Force { get; set; }

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

public override void ExecuteCmdlet()
{
if (this.ShouldProcess(this.EventSubscriptionName, $"Remove event subscription {this.EventSubscriptionName}"))
{
this.Client.DeleteSystemTopicEventSubscriptiion(this.ResourceGroupName, this.SystemTopicName, this.EventSubscriptionName);
if (this.PassThru)
ConfirmAction(Force.IsPresent,
$"Remove event subscription {this.EventSubscriptionName}",
$"Removing event subscription {this.EventSubscriptionName}",
this.EventSubscriptionName,
() =>
{
this.WriteObject(true);
}
}
this.Client.DeleteSystemTopicEventSubscriptiion(this.ResourceGroupName, this.SystemTopicName, this.EventSubscriptionName);
if (PassThru)
{
WriteObject(true);
}
});
}
}
}
1 change: 1 addition & 0 deletions src/EventGrid/EventGrid/Utilities/EventGridConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class EventGridConstants
public const string IdentityTypeHelp = "Different identity types. Could be either of following 'SystemAssigned', 'UserAssigned', 'SystemAssigned, UserAssigned', 'None'";
public const string IdentityIdsHelp = "The list of user assigned identities";
public const string SourceHelp = "Source for a system topic";
public const string ForceHelp = "Indicates that the cmdlet does not prompt you for confirmation. By default, this cmdlet prompts you to confirm that you want to delete the resource";

public const string ODataQueryHelp = "The OData query used for filtering the list results. Filtering is currently allowed on the Name property only.The supported operations include: CONTAINS, eq (for equal), ne (for not equal), AND, OR and NOT.";
public const string TopHelp = "The maximum number of resources to be obtained. Valid value is between 1 and 100. If top value is specified and more results are still available, the result will contain a link to the next page to be queried in NextLink. If the Top value is not specified, the full list of resources will be returned at once.";
Expand Down
22 changes: 11 additions & 11 deletions src/EventGrid/EventGrid/help/Az.EventGrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ Gets the shared access keys used to publish events to an Event Grid domain.
Gets the details of an Event Grid domain topic, or gets a list of all Event Grid domain topics under specific Event Grid domain in the current Azure subscription.

### [Get-AzEventGridFullUrlForSystemTopicEventSubscription](Get-AzEventGridFullUrlForSystemTopicEventSubscription.md)
{{ Fill in the Synopsis }}
Gets the full URL for system topic event subscription

### [Get-AzEventGridSubscription](Get-AzEventGridSubscription.md)
Gets the details of an event subscription, or gets a list of all event subscriptions in the current Azure subscription.

### [Get-AzEventGridSystemTopic](Get-AzEventGridSystemTopic.md)
{{ Fill in the Synopsis }}
Gets the details of an Event Grid system topic, or gets a list of all Event Grid system topics in the current Azure subscription.

### [Get-AzEventGridSystemTopicEventSubscription](Get-AzEventGridSystemTopicEventSubscription.md)
{{ Fill in the Synopsis }}
Gets the details of an event subscription, or gets a list of all event subscriptions for a given Azure Eventgrid system topic.

### [Get-AzEventGridSystemTopicEventSubscriptionDeliveryAttribute](Get-AzEventGridSystemTopicEventSubscriptionDeliveryAttribute.md)
{{ Fill in the Synopsis }}
Gets the delivery attributes for system topic event subscription

### [Get-AzEventGridTopic](Get-AzEventGridTopic.md)
Gets the details of an Event Grid topic, or gets a list of all Event Grid topics in the current Azure subscription.
Expand All @@ -57,10 +57,10 @@ Creates a new Azure Event Grid Domain Topic.
Creates a new Azure Event Grid Event Subscription to a topic, Azure resource, Azure subscription or Resource Group.

### [New-AzEventGridSystemTopic](New-AzEventGridSystemTopic.md)
{{ Fill in the Synopsis }}
Creates a new Azure Event Grid System Topic.

### [New-AzEventGridSystemTopicEventSubscription](New-AzEventGridSystemTopicEventSubscription.md)
{{ Fill in the Synopsis }}
Creates a new Azure Event Grid Event Subscription to a System topic.

### [New-AzEventGridTopic](New-AzEventGridTopic.md)
Creates a new Azure Event Grid Topic.
Expand All @@ -78,10 +78,10 @@ Removes an Azure Event Grid Domain Topic.
Removes an Azure Event Grid event subscription.

### [Remove-AzEventGridSystemTopic](Remove-AzEventGridSystemTopic.md)
{{ Fill in the Synopsis }}
Removes an Azure Event Grid System Topic.

### [Remove-AzEventGridSystemTopicEventSubscription](Remove-AzEventGridSystemTopicEventSubscription.md)
{{ Fill in the Synopsis }}
### [Remove-AzEventGridSystemTopic](Remove-AzEventGridSystemTopic.md)
Removes an Azure Event Grid System Topic.

### [Remove-AzEventGridTopic](Remove-AzEventGridTopic.md)
Removes an Azure Event Grid Topic.
Expand All @@ -93,8 +93,8 @@ Sets the properties of an Event Grid topic.
Update the properties of an Event Grid event subscription.

### [Update-AzEventGridSystemTopic](Update-AzEventGridSystemTopic.md)
{{ Fill in the Synopsis }}
Updates the properties of an Event Grid System topic.

### [Update-AzEventGridSystemTopicEventSubscription](Update-AzEventGridSystemTopicEventSubscription.md)
{{ Fill in the Synopsis }}
Update the properties of an Event Grid System topic event subscription.

Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,22 @@ Gets the full URL for system topic event subscription

### TopicNameParameterSet (Default)
```
Get-AzEventGridFullUrlForSystemTopicEventSubscription [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
Get-AzEventGridFullUrlForSystemTopicEventSubscription [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

### SystemTopicEventSuscriptionParameterSet
```
Get-AzEventGridFullUrlForSystemTopicEventSubscription -EventSubscriptionName <String>
-ResourceGroupName <String> -SystemTopicName <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
-ResourceGroupName <String> -SystemTopicName <String> [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

## DESCRIPTION
Get the full endpoint URL if it is a webhook based event subscription.

## EXAMPLES


### Example 1
```powershell
Get-AzEventGridFullUrlForSystemTopicEventSubscription -ResourceGroupName MyResourceGroupName -SystemTopicName Topic1 -EventSubscriptionName EventSubscription1
Expand Down Expand Up @@ -100,37 +99,6 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
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).

Expand All @@ -145,4 +113,5 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS

https://docs.microsoft.com/en-us/azure/event-grid/system-topics
3 changes: 1 addition & 2 deletions src/EventGrid/EventGrid/help/Get-AzEventGridSystemTopic.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Get-AzEventGridSystemTopic -ResourceGroup MyResourceGroupName -Name Topic1

Gets the details of Event Grid System topic \`Topic1\` in resource group \`MyResourceGroupName\`.


### Example 2
```powershell
Get-AzEventGridSystemTopic -ResourceGroup MyResourceGroupName
Expand Down Expand Up @@ -73,7 +72,6 @@ Get-AzEventGridSystemTopic $result.NextLink

List the first 10 Event Grid System topics (if any) in the subscription that satisfies the $odataFilter query. If more results are available, the $result.NextLink will not be $null. In order to get next page(s) of topics, user is expected to re-call Get-AzEventGridSystemTopic and uses result.NextLink obtained from the previous call. Caller should stop when result.NextLink becomes $null.


## PARAMETERS

### -DefaultProfile
Expand Down Expand Up @@ -189,4 +187,5 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to have if we can provide relate links.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


https://docs.microsoft.com/en-us/azure/event-grid/system-topics
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ Gets the details of an event subscription, or gets a list of all event subscript

### TopicNameParameterSet (Default)
```
Get-AzEventGridSystemTopicEventSubscription [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Get-AzEventGridSystemTopicEventSubscription [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### SystemTopicEventSuscriptionParameterSet
```
Get-AzEventGridSystemTopicEventSubscription [-EventSubscriptionName <String>] -ResourceGroupName <String>
-SystemTopicName <String> [-IncludeFullEndpointUrl] [-ODataQuery <String>] [-Top <Int32>] [-NextLink <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -187,37 +186,6 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
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).

Expand All @@ -236,4 +204,5 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS

https://docs.microsoft.com/en-us/azure/event-grid/system-topics
Loading