Skip to content

Commit 4f6a395

Browse files
Add ShouldProcess support for revoke functions
Enhance the Revoke-FabricExternalDataShares and Revoke-FabricCapacityTenantSettingOverrides functions to include ShouldProcess support, allowing for confirmation prompts before executing the revoke actions. This improves safety and user control over destructive operations. Also, update the corresponding test files to include new parameters for Confirm and WhatIf, ensuring comprehensive testing for these changes. Thank you!
1 parent a0ea5b8 commit 4f6a395

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

source/Public/External Data Share/Revoke-FabricExternalDataShares.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ function Revoke-FabricExternalDataShares {
5353
Write-Message -Message "Constructing API endpoint URI..." -Level Debug
5454
$apiEndpointURI = "{0}/admin/workspaces/{1}/items/{2}/externalDataShares/{3}/revoke" -f $FabricConfig.BaseUrl, $WorkspaceId, $ItemId, $ExternalDataShareId
5555

56+
if ($PSCmdlet.ShouldProcess("$ExternalDataShareId", "revoke")) {
57+
5658
$externalDataShares = Invoke-FabricAPIRequest `
5759
-BaseURI $apiEndpointURI `
5860
-Headers $FabricConfig.FabricHeaders `
5961
-Method Post
62+
}
6063

6164
# Step 4: Return retrieved data
6265
Write-Message -Message "Successfully revoked external data shares." -Level Info

source/Public/Tenant/Revoke-FabricCapacityTenantSettingOverrides.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ function Revoke-FabricCapacityTenantSettingOverrides {
4343
$apiEndpointURI = "{0}/admin/capacities/{1}/delegatedTenantSettingOverrides/{2}" -f $FabricConfig.BaseUrl, $capacityId, $tenantSettingName
4444
Write-Message -Message "Constructed API Endpoint: $apiEndpointURI" -Level Debug
4545

46+
if ($PSCmdlet.ShouldProcess("$tenantSettingName" , "Revoke")) {
4647
# Step 3: Invoke the Fabric API to retrieve capacity tenant setting overrides
4748
$response = Invoke-FabricAPIRequest `
4849
-BaseURI $apiEndpointURI `
4950
-Headers $FabricConfig.FabricHeaders `
5051
-Method Delete
51-
52+
}
5253
Write-Message -Message "Successfully removed the tenant setting override '$tenantSettingName' from the capacity with ID '$capacityId'." -Level Info
5354
return $response
5455
} catch {

tests/Unit/Revoke-FabricCapacityTenantSettingOverrides.Tests.ps1

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ param(
33
$ModuleName = "FabricTools",
44
$expectedParams = @(
55
"capacityId"
6-
"tenantSettingName"
7-
"Verbose"
8-
"Debug"
9-
"ErrorAction"
10-
"WarningAction"
11-
"InformationAction"
12-
"ProgressAction"
13-
"ErrorVariable"
14-
"WarningVariable"
15-
"InformationVariable"
16-
"OutVariable"
17-
"OutBuffer"
18-
"PipelineVariable"
19-
6+
"tenantSettingName"
7+
"Verbose"
8+
"Debug"
9+
"ErrorAction"
10+
"WarningAction"
11+
"InformationAction"
12+
"ProgressAction"
13+
"ErrorVariable"
14+
"WarningVariable"
15+
"InformationVariable"
16+
"OutVariable"
17+
"OutBuffer"
18+
"PipelineVariable"
19+
"Confirm"
20+
"WhatIf"
2021
)
2122
)
2223

@@ -44,4 +45,3 @@ Describe "Revoke-FabricCapacityTenantSettingOverrides" -Tag "UnitTests" {
4445
}
4546
}
4647
}
47-

tests/Unit/Revoke-FabricExternalDataShares.Tests.ps1

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ param(
33
$ModuleName = "FabricTools",
44
$expectedParams = @(
55
"WorkspaceId"
6-
"ItemId"
7-
"ExternalDataShareId"
8-
"Verbose"
9-
"Debug"
10-
"ErrorAction"
11-
"WarningAction"
12-
"InformationAction"
13-
"ProgressAction"
14-
"ErrorVariable"
15-
"WarningVariable"
16-
"InformationVariable"
17-
"OutVariable"
18-
"OutBuffer"
19-
"PipelineVariable"
20-
6+
"ItemId"
7+
"ExternalDataShareId"
8+
"Verbose"
9+
"Debug"
10+
"ErrorAction"
11+
"WarningAction"
12+
"InformationAction"
13+
"ProgressAction"
14+
"ErrorVariable"
15+
"WarningVariable"
16+
"InformationVariable"
17+
"OutVariable"
18+
"OutBuffer"
19+
"PipelineVariable"
20+
"Confirm"
21+
"WhatIf"
2122
)
2223
)
2324

@@ -45,4 +46,3 @@ Describe "Revoke-FabricExternalDataShares" -Tag "UnitTests" {
4546
}
4647
}
4748
}
48-

0 commit comments

Comments
 (0)