Skip to content

Commit cd62a1b

Browse files
author
Jingnan Xu
committed
run all test
1 parent 1a2ecfa commit cd62a1b

21 files changed

+974
-580
lines changed

src/FrontDoor/FrontDoor.Autorest/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@
2424
[assembly: System.Reflection.AssemblyVersionAttribute("1.13.0")]
2525
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
2626
[assembly: System.CLSCompliantAttribute(false)]
27+
28+

src/FrontDoor/FrontDoor.Autorest/custom/New-AzFrontDoor.ps1

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,81 @@ param(
262262
)
263263

264264
process {
265-
$duplicateCheck = Get-AzFrontDoor -ResourceGroupName $ResourceGroupName
266-
267-
foreach ($fd in $duplicateCheck) {
268-
if ($fd.Name -eq $Name) {
269-
throw "Front Door with name $Name already exists in resource group $ResourceGroupName"
265+
$RoutingRule = $RoutingRule
266+
if ($PSBoundParameters.ContainsKey('RoutingRule')) {
267+
$null = $PSBoundParameters.Remove('RoutingRule')
268+
}
269+
270+
$BackendPool = $BackendPool
271+
if ($PSBoundParameters.ContainsKey('BackendPool')) {
272+
$null = $PSBoundParameters.Remove('BackendPool')
273+
}
274+
275+
$BackendPoolsSetting = $BackendPoolsSetting
276+
if ($PSBoundParameters.ContainsKey('BackendPoolsSetting')) {
277+
$null = $PSBoundParameters.Remove('BackendPoolsSetting')
278+
}
279+
280+
$FrontendEndpoint = $FrontendEndpoint
281+
if ($PSBoundParameters.ContainsKey('FrontendEndpoint')) {
282+
$null = $PSBoundParameters.Remove('FrontendEndpoint')
283+
}
284+
285+
$LoadBalancingSetting = $LoadBalancingSetting
286+
if ($PSBoundParameters.ContainsKey('LoadBalancingSetting')) {
287+
$null = $PSBoundParameters.Remove('LoadBalancingSetting')
288+
}
289+
290+
$HealthProbeSetting = $HealthProbeSetting
291+
if ($PSBoundParameters.ContainsKey('HealthProbeSetting')) {
292+
$null = $PSBoundParameters.Remove('HealthProbeSetting')
293+
}
294+
295+
$Tag = $Tag
296+
if ($PSBoundParameters.ContainsKey('Tag')) {
297+
$null = $PSBoundParameters.Remove('Tag')
298+
}
299+
300+
try {
301+
$duplicateCheck = Get-AzFrontDoor @PSBoundParameters
302+
303+
foreach ($fd in $duplicateCheck) {
304+
if ($fd.Name -eq $Name) {
305+
throw "Front Door with name $Name already exists in resource group $ResourceGroupName"
306+
}
307+
}
308+
}
309+
catch {
310+
# If Get-AzFrontDoor throws an error because the resource doesn't exist,
311+
# we can continue with creating the new Front Door
312+
if ($_.Exception.Message -notlike "*was not found*") {
313+
# Re-throw if it's not a "not found" error
314+
throw $_
270315
}
271316
}
272317

318+
if ($RoutingRule) {
319+
$PSBoundParameters.Add('RoutingRule', $RoutingRule)
320+
}
321+
if ($BackendPool) {
322+
$PSBoundParameters.Add('BackendPool', $BackendPool)
323+
}
324+
if ($BackendPoolsSetting) {
325+
$PSBoundParameters.Add('BackendPoolsSetting', $BackendPoolsSetting)
326+
}
327+
if ($FrontendEndpoint) {
328+
$PSBoundParameters.Add('FrontendEndpoint', $FrontendEndpoint)
329+
}
330+
if ($LoadBalancingSetting) {
331+
$PSBoundParameters.Add('LoadBalancingSetting', $LoadBalancingSetting)
332+
}
333+
if ($HealthProbeSetting) {
334+
$PSBoundParameters.Add('HealthProbeSetting', $HealthProbeSetting)
335+
}
336+
if ($Tag) {
337+
$PSBoundParameters.Add('Tag', $Tag)
338+
}
339+
273340
Az.FrontDoor.internal\New-AzFrontDoor @PSBoundParameters
274341
}
275342
}

src/FrontDoor/FrontDoor.Autorest/custom/New-AzFrontDoorWafPolicy.ps1

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,87 @@ param(
264264
)
265265

266266
process {
267-
$duplicateCheck = Get-AzFrontDoorWafPolicy -ResourceGroupName $ResourceGroupName
268-
foreach ($policy in $duplicateCheck) {
269-
if ($policy.Name -eq $Name) {
270-
throw "WAF policy with name $Name already exists in resource group $ResourceGroupName"
267+
$SkuName = $SkuName
268+
if ($PSBoundParameters.ContainsKey('SkuName')) {
269+
$null = $PSBoundParameters.Remove('SkuName')
270+
}
271+
272+
$CustomRule = $CustomRule
273+
if ($PSBoundParameters.ContainsKey('CustomRule')) {
274+
$null = $PSBoundParameters.Remove('CustomRule')
275+
}
276+
277+
$ManagedRuleSet = $ManagedRuleSet
278+
if ($PSBoundParameters.ContainsKey('ManagedRuleSet')) {
279+
$null = $PSBoundParameters.Remove('ManagedRuleSet')
280+
}
281+
282+
$EnabledState = $EnabledState
283+
if ($PSBoundParameters.ContainsKey('EnabledState')) {
284+
$null = $PSBoundParameters.Remove('EnabledState')
285+
}
286+
287+
$Mode = $Mode
288+
if ($PSBoundParameters.ContainsKey('Mode')) {
289+
$null = $PSBoundParameters.Remove('Mode')
290+
}
291+
292+
$RequestBodyCheck = $RequestBodyCheck
293+
if ($PSBoundParameters.ContainsKey('RequestBodyCheck')) {
294+
$null = $PSBoundParameters.Remove('RequestBodyCheck')
295+
}
296+
297+
$LogScrubbingSetting = $LogScrubbingSetting
298+
if ($PSBoundParameters.ContainsKey('LogScrubbingSetting')) {
299+
$null = $PSBoundParameters.Remove('LogScrubbingSetting')
300+
}
301+
302+
$JavascriptChallengeExpirationInMinutes = $JavascriptChallengeExpirationInMinutes
303+
if ($PSBoundParameters.ContainsKey('JavascriptChallengeExpirationInMinutes')) {
304+
$null = $PSBoundParameters.Remove('JavascriptChallengeExpirationInMinutes')
305+
}
306+
307+
try {
308+
$duplicateCheck = Get-AzFrontDoorWafPolicy @PSBoundParameters
309+
foreach ($policy in $duplicateCheck) {
310+
if ($policy.Name -eq $Name) {
311+
throw "WAF policy with name $Name already exists in resource group $ResourceGroupName"
312+
}
313+
}
314+
}
315+
catch {
316+
# If Get-AzFrontDoorWafPolicy throws an error because the resource doesn't exist,
317+
# we can continue with creating the new WAF policy
318+
if ($_.Exception.Message -notlike "*was not found*") {
319+
# Re-throw if it's not a "not found" error
320+
throw $_
271321
}
272322
}
323+
324+
if (![string]::IsNullOrEmpty($SkuName)) {
325+
$PSBoundParameters.Add('SkuName', $SkuName)
326+
}
327+
if ($CustomRule) {
328+
$PSBoundParameters.Add('CustomRule', $CustomRule)
329+
}
330+
if ($ManagedRuleSet) {
331+
$PSBoundParameters.Add('ManagedRuleSet', $ManagedRuleSet)
332+
}
333+
if (![string]::IsNullOrEmpty($EnabledState)) {
334+
$PSBoundParameters.Add('EnabledState', $EnabledState)
335+
}
336+
if (![string]::IsNullOrEmpty($Mode)) {
337+
$PSBoundParameters.Add('Mode', $Mode)
338+
}
339+
if (![string]::IsNullOrEmpty($RequestBodyCheck)) {
340+
$PSBoundParameters.Add('RequestBodyCheck', $RequestBodyCheck)
341+
}
342+
if ($LogScrubbingSetting) {
343+
$PSBoundParameters.Add('LogScrubbingSetting', $LogScrubbingSetting)
344+
}
345+
if ($JavascriptChallengeExpirationInMinutes -gt 0) {
346+
$PSBoundParameters.Add('JavascriptChallengeExpirationInMinutes', $JavascriptChallengeExpirationInMinutes)
347+
}
273348

274349
$PolicySettings = [Microsoft.Azure.PowerShell.Cmdlets.FrontDoor.Models.PolicySettings]::New()
275350
if ($PSBoundParameters.ContainsKey('CustomBlockResponseBody')) {

src/FrontDoor/FrontDoor.Autorest/custom/Update-AzFrontDoorWafPolicy.ps1

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,90 @@ param(
277277
)
278278

279279
process {
280-
$retrievedPolicy = Get-AzFrontDoorWafPolicy -Name $Name -ResourceGroupName $ResourceGroupName
280+
$SkuName = $SkuName
281+
if ($PSBoundParameters.ContainsKey('SkuName')) {
282+
$null = $PSBoundParameters.Remove('SkuName')
283+
}
284+
285+
$CustomRule = $CustomRule
286+
if ($PSBoundParameters.ContainsKey('CustomRule')) {
287+
$null = $PSBoundParameters.Remove('CustomRule')
288+
}
289+
290+
$ManagedRuleSet = $ManagedRuleSet
291+
if ($PSBoundParameters.ContainsKey('ManagedRuleSet')) {
292+
$null = $PSBoundParameters.Remove('ManagedRuleSet')
293+
}
294+
295+
$EnabledState = $EnabledState
296+
if ($PSBoundParameters.ContainsKey('EnabledState')) {
297+
$null = $PSBoundParameters.Remove('EnabledState')
298+
}
299+
300+
$Mode = $Mode
301+
if ($PSBoundParameters.ContainsKey('Mode')) {
302+
$null = $PSBoundParameters.Remove('Mode')
303+
}
304+
305+
$RequestBodyCheck = $RequestBodyCheck
306+
if ($PSBoundParameters.ContainsKey('RequestBodyCheck')) {
307+
$null = $PSBoundParameters.Remove('RequestBodyCheck')
308+
}
309+
310+
$LogScrubbingSetting = $LogScrubbingSetting
311+
if ($PSBoundParameters.ContainsKey('LogScrubbingSetting')) {
312+
$null = $PSBoundParameters.Remove('LogScrubbingSetting')
313+
}
314+
315+
$JavascriptChallengeExpirationInMinutes = $JavascriptChallengeExpirationInMinutes
316+
if ($PSBoundParameters.ContainsKey('JavascriptChallengeExpirationInMinutes')) {
317+
$null = $PSBoundParameters.Remove('JavascriptChallengeExpirationInMinutes')
318+
}
319+
320+
try {
321+
$retrievedPolicy = Get-AzFrontDoorWafPolicy @PSBoundParameters
322+
}
323+
catch {
324+
# If Get-AzFrontDoorWafPolicy throws an error because the resource doesn't exist,
325+
# we cannot proceed with the update operation
326+
if ($_.Exception.Message -like "*was not found*") {
327+
throw "WAF policy '$Name' was not found in resource group '$ResourceGroupName'. Cannot update a non-existent policy."
328+
}
329+
else {
330+
# Re-throw if it's not a "not found" error
331+
throw $_
332+
}
333+
}
334+
335+
# Handle SKU: use provided SkuName or preserve existing SKU from retrieved policy
336+
if ($PSBoundParameters.ContainsKey('SkuName') -and ![string]::IsNullOrEmpty($SkuName)) {
337+
$PSBoundParameters.Add('SkuName', $SkuName)
338+
} elseif ($retrievedPolicy.Sku -and $retrievedPolicy.Sku.Name) {
339+
$PSBoundParameters.Add('SkuName', $retrievedPolicy.Sku.Name)
340+
}
341+
if ($CustomRule) {
342+
$PSBoundParameters.Add('CustomRule', $CustomRule)
343+
}
344+
if ($ManagedRuleSet) {
345+
$PSBoundParameters.Add('ManagedRuleSet', $ManagedRuleSet)
346+
}
347+
if (![string]::IsNullOrEmpty($EnabledState)) {
348+
$PSBoundParameters.Add('EnabledState', $EnabledState)
349+
}
350+
# Only add Mode and RequestBodyCheck if they have valid values
351+
if (![string]::IsNullOrEmpty($Mode)) {
352+
$PSBoundParameters.Add('Mode', $Mode)
353+
}
354+
if (![string]::IsNullOrEmpty($RequestBodyCheck)) {
355+
$PSBoundParameters.Add('RequestBodyCheck', $RequestBodyCheck)
356+
}
357+
if ($LogScrubbingSetting) {
358+
$PSBoundParameters.Add('LogScrubbingSetting', $LogScrubbingSetting)
359+
}
360+
if ($JavascriptChallengeExpirationInMinutes -gt 0) {
361+
$PSBoundParameters.Add('JavascriptChallengeExpirationInMinutes', $JavascriptChallengeExpirationInMinutes)
362+
}
363+
281364
$UpdatePolicySetting = $retrievedPolicy.PolicySetting
282365
if ($PSBoundParameters.ContainsKey("CustomBlockResponseBody")) {
283366
$null = $PSBoundParameters.Remove("CustomBlockResponseBody")
@@ -288,30 +371,31 @@ process {
288371
$null = $PSBoundParameters.Remove("CustomBlockResponseStatusCode")
289372
$UpdatePolicySetting.CustomBlockResponseStatusCode = $CustomBlockResponseStatusCode
290373
}
291-
if ($PSBoundParameters.ContainsKey("EnabledState")) {
374+
if ($PSBoundParameters.ContainsKey("EnabledState") -and ![string]::IsNullOrEmpty($EnabledState)) {
292375
$null = $PSBoundParameters.Remove("EnabledState")
293376
$UpdatePolicySetting.EnabledState = $EnabledState
294377
}
295378
if ($PSBoundParameters.ContainsKey("LogScrubbingSetting")) {
296379
$null = $PSBoundParameters.Remove("LogScrubbingSetting")
297380
$UpdatePolicySetting.LogScrubbingSetting = $LogScrubbingSetting
298381
}
299-
if ($PSBoundParameters.ContainsKey("Mode")) {
382+
if ($PSBoundParameters.ContainsKey("Mode") -and ![string]::IsNullOrEmpty($Mode)) {
300383
$null = $PSBoundParameters.Remove("Mode")
301384
$UpdatePolicySetting.Mode = $Mode
302385
}
303386
if ($PSBoundParameters.ContainsKey("RedirectUrl")) {
304387
$null = $PSBoundParameters.Remove("RedirectUrl")
305388
$UpdatePolicySetting.RedirectUrl = $RedirectUrl
306389
}
307-
if ($PSBoundParameters.ContainsKey("RequestBodyCheck")) {
390+
if ($PSBoundParameters.ContainsKey("RequestBodyCheck") -and ![string]::IsNullOrEmpty($RequestBodyCheck)) {
308391
$null = $PSBoundParameters.Remove("RequestBodyCheck")
309392
$UpdatePolicySetting.RequestBodyCheck = $RequestBodyCheck
310393
}
311394
if ($PSBoundParameters.ContainsKey("JavascriptChallengeExpirationInMinutes")) {
312395
$null = $PSBoundParameters.Remove("JavascriptChallengeExpirationInMinutes")
313396
$UpdatePolicySetting.JavascriptChallengeExpirationInMinutes = $JavascriptChallengeExpirationInMinutes
314397
}
398+
315399
$PSBoundParameters.PolicySetting = $UpdatePolicySetting
316400

317401
Az.FrontDoor.internal\Update-AzFrontDoorWafPolicy @PSBoundParameters

src/FrontDoor/FrontDoor.Autorest/docs/Az.FrontDoor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Module Name: Az.FrontDoor
3-
Module Guid: 1cd50361-7b4f-418a-9851-945676ee06e3
3+
Module Guid: cb2bcf1e-c71e-46a2-a176-6cbf613eed22
44
Download Help Link: https://learn.microsoft.com/powershell/module/az.frontdoor
55
Help Version: 1.0.0.0
66
Locale: en-US
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"generate_Id": "5eb33352-f9b1-461f-ba53-6b7ad4002371"
2+
"generate_Id": "a4bafc59-e86f-4d43-b13c-9d19f8a09ece"
33
}

0 commit comments

Comments
 (0)