Skip to content

Commit bf0dd26

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#7595 from hytao/frontdoor
add remove-AzureRmFrontDoorContent cmdlet
2 parents cc7d1b0 + 4feaa28 commit bf0dd26

11 files changed

+297
-58
lines changed

src/ResourceManager/FrontDoor/Commands.FrontDoor/Az.FrontDoor.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ CmdletsToExport = 'New-AzFrontDoor', 'Get-AzFrontDoor', 'Set-AzFrontDoor',
7878
'New-AzFrontDoorHealthProbeSettingObject', 'New-AzFrontDoorLoadBalancingSettingObject',
7979
'New-AzFrontDoorMatchConditionObject', 'New-AzFrontDoorCustomRuleObject', 'New-AzFrontDoorManagedRuleObject',
8080
'New-AzFrontDoorFireWallPolicy', 'Get-AzFrontDoorFireWallPolicy', 'Set-AzFrontDoorFireWallPolicy',
81-
'Remove-AzFrontDoorFireWallPolicy', 'New-AzFrontDoorRuleGroupOverrideObject'
81+
'Remove-AzFrontDoorFireWallPolicy', 'New-AzFrontDoorRuleGroupOverrideObject', 'Remove-AzFrontDoorContent''
8282
8383
# Variables to export from this module
8484
# VariablesToExport = @()

src/ResourceManager/FrontDoor/Commands.FrontDoor/AzureRM.FrontDoor.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ CmdletsToExport = 'New-AzureRmFrontDoor', 'Get-AzureRmFrontDoor', 'Set-AzureRmFr
7878
'New-AzureRmFrontDoorHealthProbeSettingObject', 'New-AzureRmFrontDoorLoadBalancingSettingObject',
7979
'New-AzureRmFrontDoorMatchConditionObject', 'New-AzureRmFrontDoorCustomRuleObject', 'New-AzureRmFrontDoorManagedRuleObject',
8080
'New-AzureRmFrontDoorFireWallPolicy', 'Get-AzureRmFrontDoorFireWallPolicy', 'Set-AzureRmFrontDoorFireWallPolicy',
81-
'Remove-AzureRmFrontDoorFireWallPolicy', 'New-AzureRmFrontDoorRuleGroupOverrideObject'
81+
'Remove-AzureRmFrontDoorFireWallPolicy', 'New-AzureRmFrontDoorRuleGroupOverrideObject', 'Remove-AzureRmFrontDoorContent'
8282

8383
# Variables to export from this module
8484
# VariablesToExport = @()

src/ResourceManager/FrontDoor/Commands.FrontDoor/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
## Current Release
21+
* Add remove-AzureRmFrontDoorContent for cache purge
2122

2223
## Version 0.1.0
2324
* PowerShell integration for Azure Front Door service

src/ResourceManager/FrontDoor/Commands.FrontDoor/Cmdlets/NewAzureRmFrontDoorFireWallPolicy.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.Azure.Commands.FrontDoor.Helpers;
2121
using Microsoft.Azure.Commands.FrontDoor.Models;
2222
using Microsoft.Azure.Commands.FrontDoor.Properties;
23+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2324
using Microsoft.Azure.Management.FrontDoor;
2425
using System.Linq;
2526
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
@@ -61,7 +62,7 @@ public class NewAzureRmFrontDoorFireWallPolicy : AzureFrontDoorCmdletBase
6162
/// <summary>
6263
/// Custom rules inside the policy
6364
/// </summary>
64-
[Parameter(Mandatory = true, HelpMessage = "Custom rules inside the policy")]
65+
[Parameter(Mandatory = false, HelpMessage = "Custom rules inside the policy")]
6566
[ValidateNotNullOrEmpty]
6667
public PSCustomRule[] Customrule { get; set; }
6768

@@ -88,16 +89,16 @@ public override void ExecuteCmdlet()
8889
{
8990
Location = "global",
9091
CustomRules = new Management.FrontDoor.Models.CustomRules {
91-
Rules = Customrule.ToList().Select(x => x.ToSdkCustomRule()).ToList()
92+
Rules = Customrule?.ToList().Select(x => x.ToSdkCustomRule()).ToList()
9293
},
9394
ManagedRules = new Management.FrontDoor.Models.ManagedRuleSets
9495
{
9596
RuleSets = ManagedRule?.ToList().Select(x => x.ToSdkAzManagedRule()).ToList()
9697
},
9798
PolicySettings = new Management.FrontDoor.Models.PolicySettings
9899
{
99-
EnabledState = EnabledState.ToString(),
100-
Mode = Mode.ToString()
100+
EnabledState = this.IsParameterBound(c => c.EnabledState) ? EnabledState.ToString() : PSEnabledState.Enabled.ToString(),
101+
Mode = this.IsParameterBound(c => c.Mode) ? Mode.ToString() : PSMode.Prevention.ToString()
101102
}
102103
};
103104
if (ShouldProcess(Resources.WebApplicationFirewallPolicyTarget, string.Format(Resources.CreateWebApplicationFirewallPolicy, Name)))
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections;
17+
using System.Management.Automation;
18+
using System.Net;
19+
using Microsoft.Azure.Commands.FrontDoor.Common;
20+
using Microsoft.Azure.Commands.FrontDoor.Helpers;
21+
using Microsoft.Azure.Commands.FrontDoor.Models;
22+
using Microsoft.Azure.Commands.FrontDoor.Properties;
23+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
using Microsoft.Azure.Management.FrontDoor;
25+
using System.Linq;
26+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
27+
namespace Microsoft.Azure.Commands.FrontDoor.Cmdlets
28+
{
29+
/// <summary>
30+
/// Defines the New-AzureRmFrontDoor cmdlet.
31+
/// </summary>
32+
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "FrontDoorContent", SupportsShouldProcess = true), OutputType(typeof(bool))]
33+
public class RemoveAzureRmFrontDoorContent : AzureFrontDoorCmdletBase
34+
{
35+
/// <summary>
36+
/// The resource group name of the Front Door.
37+
/// </summary>
38+
[Parameter(Mandatory = true, HelpMessage = "The resource group name of the Front Door")]
39+
[ValidateNotNullOrEmpty]
40+
public string ResourceGroupName { get; set; }
41+
42+
/// <summary>
43+
/// The Front Door name.
44+
/// </summary>
45+
[Parameter(Mandatory = true, HelpMessage = "Front Door name.")]
46+
[ValidateNotNullOrEmpty]
47+
public string Name { get; set; }
48+
49+
/// <summary>
50+
/// The path to the content to be purged.
51+
/// </summary>
52+
[Parameter(Mandatory = true, HelpMessage = "The paths to the content to be purged.")]
53+
public string[] ContentPath { get; set; }
54+
55+
[Parameter(Mandatory = false, HelpMessage = "Return object (if specified).")]
56+
public SwitchParameter PassThru { get; set; }
57+
58+
public override void ExecuteCmdlet()
59+
{
60+
if (ShouldProcess(Resources.FrontDoorTarget, string.Format(Resources.PurgeFrontDoor, Name)))
61+
{
62+
var parameters = new Microsoft.Azure.Management.FrontDoor.Models.PurgeParameters(ContentPath);
63+
FrontDoorManagementClient.Endpoints.PurgeContent(ResourceGroupName, Name, parameters);
64+
if (PassThru)
65+
{
66+
WriteObject(true);
67+
}
68+
}
69+
}
70+
}
71+
}

src/ResourceManager/FrontDoor/Commands.FrontDoor/Commands.FrontDoor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<ItemGroup>
4949
<Compile Include="Cmdlets\GetAzureRmFrontDoorFireWallPolicy.cs" />
5050
<Compile Include="Cmdlets\GetAzureRmFrontDoor.cs" />
51+
<Compile Include="Cmdlets\RemoveAzureRmFrontDoorContent.cs" />
5152
<Compile Include="Cmdlets\RemoveAzureRmFrontDoorFireWallPolicy.cs" />
5253
<Compile Include="Cmdlets\SetAzureRmFrontDoorFIreWallPolicy.cs" />
5354
<Compile Include="Cmdlets\NewAzureRmFrontDoorFireWallPolicy.cs" />

src/ResourceManager/FrontDoor/Commands.FrontDoor/Properties/Resources.Designer.cs

Lines changed: 58 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/FrontDoor/Commands.FrontDoor/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,7 @@
162162
<data name="Error_ErrorResponseFromServer" xml:space="preserve">
163163
<value>Error response received. Error Message: '{0}'</value>
164164
</data>
165+
<data name="PurgeFrontDoor" xml:space="preserve">
166+
<value>Purge Contents?</value>
167+
</data>
165168
</root>

src/ResourceManager/FrontDoor/Commands.FrontDoor/help/AzureRM.FrontDoor.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ Create RuleGroupOverride Object for WAF policy creation
5656
### [Remove-AzureRmFrontDoor](Remove-AzureRmFrontDoor.md)
5757
Remove Front Door load balancer
5858

59+
### [Remove-AzureRmFrontDoorContent](Remove-AzureRmFrontDoorContent.md)
60+
Remove contents in Front Door
61+
5962
### [Remove-AzureRmFrontDoorFireWallPolicy](Remove-AzureRmFrontDoorFireWallPolicy.md)
6063
Remove WAF policy
6164

src/ResourceManager/FrontDoor/Commands.FrontDoor/help/New-AzureRmFrontDoorFireWallPolicy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Create WAF policy
1414

1515
```
1616
New-AzureRmFrontDoorFireWallPolicy -ResourceGroupName <String> -Name <String> [-EnabledState <PSEnabledState>]
17-
[-Mode <PSMode>] -Customrule <PSCustomRule[]> [-ManagedRule <PSManagedRule[]>]
17+
[-Mode <PSMode>] [-Customrule <PSCustomRule[]>] [-ManagedRule <PSManagedRule[]>]
1818
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
1919
```
2020

@@ -54,7 +54,7 @@ Type: Microsoft.Azure.Commands.FrontDoor.Models.PSCustomRule[]
5454
Parameter Sets: (All)
5555
Aliases:
5656

57-
Required: True
57+
Required: False
5858
Position: Named
5959
Default value: None
6060
Accept pipeline input: False

0 commit comments

Comments
 (0)