Skip to content

Commit 5af4828

Browse files
committed
Because we want to show message for statusCode 200 as well
1 parent 58150d4 commit 5af4828

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

source/Private/Test-FabricApiResponse.ps1

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,17 @@ function Test-FabricApiResponse {
5555

5656
$responseHeader = $script:responseHeader
5757
$statusCode = $script:statusCode
58+
$result = $null
5859

5960
$verb = (Get-PSCallStack)[1].Command.Split('-')[0]
6061
Write-Message -Message "Testing API response for '$verb' operation. StatusCode: $statusCode." -Level Debug
6162

6263
switch ($statusCode) {
6364
200 {
64-
return $null
65+
$result = $null
6566
}
6667
201 {
67-
switch ($verb) {
68-
'New' { $msg = "$TypeName '$ObjectIdOrName' created successfully!" }
69-
'Update' { $msg = "$TypeName '$ObjectIdOrName' updated successfully!" }
70-
'Remove' { $msg = "$TypeName '$ObjectIdOrName' deleted successfully!" }
71-
default { $msg = "Received $statusCode status code for $verb operation on $TypeName '$ObjectIdOrName'" }
72-
}
73-
Write-Message -Message $msg -Level Info
74-
return $Response
68+
$result = $Response
7569
}
7670
202 {
7771
Write-Message -Message "$verb Request for $TypeName '$ObjectIdOrName' accepted. Provisioning in progress!" -Level Info
@@ -115,4 +109,17 @@ function Test-FabricApiResponse {
115109
}
116110
}
117111

112+
switch ($verb) {
113+
'New' { $msg = "$TypeName '$ObjectIdOrName' created successfully!" }
114+
'Update' { $msg = "$TypeName '$ObjectIdOrName' updated successfully!" }
115+
'Remove' { $msg = "$TypeName '$ObjectIdOrName' deleted successfully!" }
116+
'Get' { $msg = "" }
117+
default { $msg = "Received $statusCode status code for $verb operation on $TypeName '$ObjectIdOrName'." }
118+
}
119+
if ($msg) {
120+
Write-Message -Message $msg -Level Info
121+
}
122+
123+
$result
124+
118125
}

source/Public/SQL Database/New-FabricSQLDatabase.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ function New-FabricSQLDatabase
7777
}
7878
# Step 5: Handle and log the response
7979
Test-FabricApiResponse -Response $response -ObjectIdOrName $Name -TypeName 'SQL Database' -NoWait:$NoWait
80-
81-
Write-Message -Message "SQL Database '$Name' created successfully!" -Level Info
8280
}
8381
catch
8482
{

source/Public/SQL Database/Remove-FabricSQLDatabase.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ function Remove-FabricSQLDatabase
5353

5454
# Step 4: Validate the response code
5555
Test-FabricApiResponse -Response $response -ObjectIdOrName $SQLDatabaseId -TypeName "SQL Database"
56-
57-
Write-Message -Message "SQL Database '$SQLDatabaseId' deleted successfully!" -Level Info
5856
}
5957
catch
6058
{

0 commit comments

Comments
 (0)