Skip to content

Commit 3f8a5cb

Browse files
committed
Because few functions should support 'ShouldProcess'.
1 parent c3b92ba commit 3f8a5cb

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

source/Public/Deployment Pipeline/New-FabricDeploymentPipeline.ps1

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Author: Kamil Nowinski
5151
#>
5252

5353
function New-FabricDeploymentPipeline {
54-
[CmdletBinding()]
54+
[CmdletBinding(SupportsShouldProcess)]
5555
param(
5656
[Parameter(Mandatory = $true)]
5757
[ValidateNotNullOrEmpty()]
@@ -90,23 +90,17 @@ function New-FabricDeploymentPipeline {
9090
$requestBody.description = $Description
9191
}
9292

93-
# Step 4: Make the API request
94-
$response = Invoke-FabricRestMethod -Uri "deploymentPipelines" -Method Post -Body $requestBody
95-
96-
# Step 5: Validate response
97-
Test-FabricApiResponse -response $response -ObjectIdOrName $DisplayName -typeName "deployment pipeline"
93+
# Step 4: Make the API request and Validate response
94+
if ($PSCmdlet.ShouldProcess($requestBody, "Create new Deployment Pipeline")) {
95+
$response = Invoke-FabricRestMethod -Uri "deploymentPipelines" -Method Post -Body $requestBody
96+
$response = Test-FabricApiResponse -response $response -ObjectIdOrName $DisplayName -typeName "deployment pipeline"
97+
}
9898

99-
# Step 6: Handle results
99+
# Step 5: Handle results
100100
$response
101-
# if ($response) {
102-
# Write-Message -Message "Successfully created deployment pipeline." -Level Debug
103-
# return $response
104-
# } else {
105-
# Write-Message -Message "Failed to create deployment pipeline." -Level Warning
106-
# return $null
107-
# }
101+
108102
} catch {
109-
# Step 7: Error handling
103+
# Step 6: Error handling
110104
$errorDetails = $_.Exception.Message
111105
Write-Message -Message "Failed to create deployment pipeline. Error: $errorDetails" -Level Error
112106
return $null

source/Public/Deployment Pipeline/Remove-FabricDeploymentPipeline.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,18 @@ function Remove-FabricDeploymentPipeline {
3939
$apiEndpointUrl = "deploymentPipelines/$DeploymentPipelineId"
4040
Write-Message -Message "API Endpoint: $apiEndpointUrl" -Level Debug
4141

42-
# Step 3: Make the API request
43-
if ($PSCmdlet.ShouldProcess($apiEndpointUrl, "Delete deployment pipeline"))
42+
# Step 3: Make the API request & validate response
43+
if ($PSCmdlet.ShouldProcess($apiEndpointUrl, "Delete Deployment Pipeline"))
4444
{
4545
$response = Invoke-FabricRestMethod -Uri $apiEndpointUrl -Method Delete
46+
Test-FabricApiResponse -response $response -ObjectIdOrName $DeploymentPipelineId -typeName "deployment pipeline"
4647
}
4748

48-
# Step 4: Validate response
49-
Test-FabricApiResponse -response $response -ObjectIdOrName $DeploymentPipelineId -typeName "deployment pipeline"
50-
51-
# Step 5: Handle results
49+
# Step 4: Handle results
5250
Write-Message -Message "Deployment pipeline $DeploymentPipelineId deleted successfully." -Level Info
5351

5452
} catch {
55-
# Step 6: Error handling
53+
# Step 5: Error handling
5654
$errorDetails = $_.Exception.Message
5755
Write-Message -Message "Failed to delete deployment pipeline. Error: $errorDetails" -Level Error
5856
}

source/Public/Deployment Pipeline/Remove-FabricWorkspaceFromStage.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ function Remove-FabricWorkspaceFromStage {
4848
Write-Message -Message "API Endpoint: $apiEndpointUrl" -Level Debug
4949

5050
# Step 3: Make the API request and validate response
51-
$response = Invoke-FabricRestMethod -Uri $apiEndpointUrl -Method Post
52-
Test-FabricApiResponse -Response $response
51+
if ($PSCmdlet.ShouldProcess($apiEndpointUrl, "Remove Workspace from Deployment Pipeline Stage")) {
52+
$response = Invoke-FabricRestMethod -Uri $apiEndpointUrl -Method Post
53+
$response = Test-FabricApiResponse -Response $response
54+
}
5355

5456
# Step 4: Return results
5557
Write-Message -Message "Successfully unassigned workspace from deployment pipeline stage." -Level Info

0 commit comments

Comments
 (0)