Skip to content

Commit a0ea5b8

Browse files
authored
Fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 (#45)
* fix for #39 * contenttype not used so post commands were failign * correct comment wording * update api call to fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 * fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 * fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 * fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 * formatting & spelling * whitespace changes * lets have a copyJob when we ask for one not a warehouse * fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 * fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 * change confirmImpact to high so confirm works cc. @SQLDBAWithABeard * fix for New-FabricDataPipeline - issue with call to Invoke-FabricAPIRequest #39 * fix for #39 * Removed leading slash from $apiEndpointURI #39 * Removed leading slash #39 ---------
1 parent b6a5777 commit a0ea5b8

16 files changed

+142
-127
lines changed

source/Public/Capacity/Get-FabricCapacity.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
The name of the capacity to retrieve. This parameter is optional.
1515
1616
.EXAMPLE
17-
Get-FabricCapacity -capacityId "capacity-12345"
17+
Get-FabricCapacity -capacityId "capacity-12345"
1818
This example retrieves the capacity details for the capacity with ID "capacity-12345".
1919
2020
.EXAMPLE
21-
Get-FabricCapacity -capacityName "MyCapacity"
21+
Get-FabricCapacity -capacityName "MyCapacity"
2222
This example retrieves the capacity details for the capacity named "MyCapacity".
2323
2424
.NOTES
@@ -51,14 +51,14 @@ function Get-FabricCapacity {
5151
Write-Message -Message "Token validation completed." -Level Debug
5252

5353
# Construct the API endpoint URL
54-
$apiEndpointURI = "{0}/capacities" -f $FabricConfig.BaseUrl
54+
$apiEndpointURI = "capacities"
5555

5656
# Invoke the Fabric API to retrieve capacity details
57-
$capacities = Invoke-FabricAPIRequest `
58-
-BaseURI $apiEndpointURI `
59-
-Headers $FabricConfig.FabricHeaders `
60-
-Method Get
61-
57+
$apiParams = @{
58+
Uri = $apiEndpointURI
59+
Method = 'Get'
60+
}
61+
$capacities = (Invoke-FabricAPIRequest @apiParams).Value
6262

6363
# Filter results based on provided parameters
6464
$response = if ($capacityId) {
@@ -85,4 +85,4 @@ function Get-FabricCapacity {
8585
Write-Message -Message "Failed to retrieve capacity. Error: $errorDetails" -Level Error
8686
return $null
8787
}
88-
}
88+
}

source/Public/Confirm-FabricAuthToken.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<#
22
.SYNOPSIS
3-
Check whether the Fabric API authentication token is set and not expired and reset it if necessary.
3+
Check whether the Fabric API authentication token is set and not expired and reset it if necessary.
44
55
.DESCRIPTION
6-
The Confirm-FabricAuthToken function retrieves the Fabric API authentication token. If the token is not already set, it calls the Set-FabricAuthToken function to set it. It then outputs the token.
6+
The Confirm-FabricAuthToken function retrieves the Fabric API authentication token. If the token is not already set, it calls the Set-FabricAuthToken function to set it. It then outputs the token.
77
88
.EXAMPLE
9-
Confirm-FabricAuthToken
9+
Confirm-FabricAuthToken
1010
11-
This command retrieves the Fabric API authentication token.
11+
This command retrieves the Fabric API authentication token.
1212
1313
.INPUTS
14-
None. You cannot pipe inputs to this function.
14+
None. You cannot pipe inputs to this function.
1515
1616
.OUTPUTS
17-
Returns object as Get-FabricDebugInfo function
17+
Returns object as Get-FabricDebugInfo function
1818
1919
.NOTES
2020
@@ -47,4 +47,4 @@ function Confirm-FabricAuthToken {
4747
$s = Get-FabricDebugInfo
4848
return $s
4949

50-
}
50+
}

source/Public/Copy Job/Get-FabricCopyJob.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ function Get-FabricCopyJob {
6060

6161

6262
# Construct the API endpoint URL
63-
$apiEndpointURI = "{0}/workspaces/{1}/copyJobs" -f $FabricConfig.BaseUrl, $WorkspaceId
63+
$apiEndpointURI = "workspaces/{0}/copyJobs" -f $WorkspaceId
6464

6565
# Invoke the Fabric API to retrieve capacity details
66-
$copyJobs = Invoke-FabricAPIRequest `
67-
-BaseURI $apiEndpointURI `
68-
-Headers $FabricConfig.FabricHeaders `
69-
-Method Get
66+
$apiParams = @{
67+
Uri = $apiEndpointURI
68+
Method = 'Get'
69+
}
70+
$copyJobs = Invoke-FabricAPIRequest @apiParams
7071

7172
# Filter results based on provided parameters
7273
$response = if ($CopyJobId) {

source/Public/Copy Job/Get-FabricCopyJobDefinition.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Get-FabricCopyJobDefinition {
5050
Write-Message -Message "Authentication token is valid." -Level Debug
5151

5252
# Step 2: Construct the API endpoint URL for retrieving the Copy Job definition.
53-
$apiEndpointUrl = "{0}/workspaces/{1}/copyJobs/{2}/getDefinition" -f $FabricConfig.BaseUrl, $WorkspaceId, $CopyJobId
53+
$apiEndpointUrl = "workspaces/{0}/copyJobs/{1}/getDefinition" -f $WorkspaceId, $CopyJobId
5454

5555
# Step 3: Append the format query parameter if specified by the user.
5656
if ($CopyJobFormat) {
@@ -59,10 +59,11 @@ function Get-FabricCopyJobDefinition {
5959
Write-Message -Message "Constructed API Endpoint URL: $apiEndpointUrl" -Level Debug
6060

6161
# Step 4: Execute the API request to retrieve the Copy Job definition.
62-
$response = Invoke-FabricAPIRequest `
63-
-BaseURI $apiEndpointUrl `
64-
-Headers $FabricConfig.FabricHeaders `
65-
-Method Post
62+
$apiParams = @{
63+
Uri = $apiEndpointUrl
64+
Method = 'POST'
65+
}
66+
$response = Invoke-FabricAPIRequest @apiParams
6667

6768
# Step 5: Return the API response containing the Copy Job definition.
6869
return $response
@@ -71,4 +72,4 @@ function Get-FabricCopyJobDefinition {
7172
$errorDetails = $_.Exception.Message
7273
Write-Message -Message "Failed to retrieve Copy Job definition. Error: $errorDetails" -Level Error
7374
}
74-
}
75+
}

source/Public/Copy Job/New-FabricCopyJob.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function New-FabricCopyJob {
6262
Write-Message -Message "Token validation completed." -Level Debug
6363

6464
# Step 2: Construct the API URL
65-
$apiEndpointURI = "{0}/workspaces/{1}/warehouses" -f $FabricConfig.BaseUrl, $WorkspaceId
65+
$apiEndpointURI = "workspaces/{0}/copyJobs" -f $WorkspaceId
6666
Write-Message -Message "API Endpoint: $apiEndpointURI" -Level Debug
6767

6868
# Step 3: Construct the request body
@@ -127,15 +127,16 @@ function New-FabricCopyJob {
127127
if($PSCmdlet.ShouldProcess($apiEndpointURI, "Create Copy Job")) {
128128

129129
# Step 6: Make the API request
130-
$response = Invoke-FabricAPIRequest `
131-
-BaseURI $apiEndpointURI `
132-
-Headers $FabricConfig.FabricHeaders `
133-
-Method Post `
134-
-Body $bodyJson
130+
$apiParams = @{
131+
Uri = $apiEndpointURI
132+
Method = 'Post'
133+
Body = $bodyJson
135134
}
135+
$response = Invoke-FabricAPIRequest @apiParams
136+
}
136137

137-
Write-Message -Message "Copy Job created successfully!" -Level Info
138-
return $response
138+
Write-Message -Message "Copy Job created successfully!" -Level Info
139+
return $response
139140

140141
} catch {
141142
# Step 7: Handle and log errors

source/Public/Copy Job/Remove-FabricCopyJob.ps1

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Author: Tiago Balabuch
2424
#>
2525
function Remove-FabricCopyJob {
26-
[CmdletBinding(SupportsShouldProcess)]
26+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2727
param (
2828
[Parameter(Mandatory = $true)]
2929
[ValidateNotNullOrEmpty()]
@@ -40,22 +40,23 @@ function Remove-FabricCopyJob {
4040
Write-Message -Message "Token validation completed." -Level Debug
4141

4242
# Construct the API endpoint URI
43-
$apiEndpointURI = "{0}/workspaces/{1}/copyJobs/{2}" -f $FabricConfig.BaseUrl, $WorkspaceId, $CopyJobId
43+
$apiEndpointURI = "workspaces/{0}/copyJobs/{1}" -f $WorkspaceId, $CopyJobId
4444
Write-Message -Message "API Endpoint: $apiEndpointURI" -Level Debug
4545

4646
if($PSCmdlet.ShouldProcess($apiEndpointURI, "Delete Copy Job")) {
4747

4848
# Make the API request
49-
$response = Invoke-FabricAPIRequest `
50-
-Headers $FabricConfig.FabricHeaders `
51-
-BaseURI $apiEndpointURI `
52-
-Method Delete
49+
$apiParams = @{
50+
Uri = $apiEndpointURI
51+
Method = 'DELETE'
5352
}
54-
Write-Message -Message "Copy Job '$CopyJobId' deleted successfully from workspace '$WorkspaceId'." -Level Info
55-
return $response
53+
$response = Invoke-FabricAPIRequest @apiParams
54+
}
55+
Write-Message -Message "Copy Job '$CopyJobId' deleted successfully from workspace '$WorkspaceId'." -Level Info
56+
return $response
5657

57-
} catch {
58-
# Log and handle errors
58+
} catch {
59+
# Log and handle errors
5960
$errorDetails = $_.Exception.Message
6061
Write-Message -Message "Failed to delete Copy Job '$CopyJobId' from workspace '$WorkspaceId'. Error: $errorDetails" -Level Error
6162
}

source/Public/Dashboard/Get-FabricDashboard.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ function Get-FabricDashboard {
3535
Write-Message -Message "Token validation completed." -Level Debug
3636

3737
# Construct the API endpoint URL
38-
$apiEndpointURI = "{0}/workspaces/{1}/dashboards" -f $FabricConfig.BaseUrl, $WorkspaceId
38+
$apiEndpointURI = "workspaces/{0}/dashboards" -f $WorkspaceId
3939

4040
# Invoke the Fabric API to retrieve capacity details
41-
$Dashboards = Invoke-FabricAPIRequest `
42-
-BaseURI $apiEndpointURI `
43-
-Headers $FabricConfig.FabricHeaders `
44-
-Method Get
41+
$apiParams = @{
42+
Uri = $apiEndpointURI
43+
Method = 'Get'
44+
}
45+
$Dashboards = Invoke-FabricAPIRequest @apiParams
4546

4647
return $Dashboards
4748

@@ -50,4 +51,4 @@ function Get-FabricDashboard {
5051
$errorDetails = $_.Exception.Message
5152
Write-Message -Message "Failed to retrieve Dashboard. Error: $errorDetails" -Level Error
5253
}
53-
}
54+
}

source/Public/Data Pipeline/Get-FabricDataPipeline.ps1

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ function Get-FabricDataPipeline {
1717
The name of the Data Pipeline to retrieve. This parameter is optional.
1818
1919
.EXAMPLE
20-
Get-FabricData Pipeline -WorkspaceId "workspace-12345" -Data PipelineId "Data Pipeline-67890"
20+
Get-FabricData Pipeline -WorkspaceId "workspace-12345" -Data PipelineId "Data Pipeline-67890"
2121
This example retrieves the Data Pipeline details for the Data Pipeline with ID "Data Pipeline-67890" in the workspace with ID "workspace-12345".
2222
2323
.EXAMPLE
24-
Get-FabricData Pipeline -WorkspaceId "workspace-12345" -Data PipelineName "My Data Pipeline"
24+
Get-FabricData Pipeline -WorkspaceId "workspace-12345" -Data PipelineName "My Data Pipeline"
2525
This example retrieves the Data Pipeline details for the Data Pipeline named "My Data Pipeline" in the workspace with ID "workspace-12345".
2626
2727
.NOTES
@@ -59,13 +59,10 @@ function Get-FabricDataPipeline {
5959
Write-Message -Message "Token validation completed." -Level Debug
6060

6161
# Construct the API endpoint URL
62-
$apiEndpointURI = "{0}/workspaces/{1}/dataPipelines" -f $FabricConfig.BaseUrl, $WorkspaceId
62+
$apiEndpointURI = ("workspaces/{0}/dataPipelines" -f $WorkspaceId)
6363

64-
# Invoke the Fabric API to retrieve capacity details
65-
$DataPipelines = Invoke-FabricAPIRequest `
66-
-BaseURI $apiEndpointURI `
67-
-Headers $FabricConfig.FabricHeaders `
68-
-Method Get
64+
# Invoke the Fabric API to retrieve data pipeline details
65+
$DataPipelines = (Invoke-FabricAPIRequest -uri $apiEndpointURI -Method Get).Value
6966

7067
# Filter results based on provided parameters
7168
$response = if ($DataPipelineId) {
@@ -92,4 +89,4 @@ function Get-FabricDataPipeline {
9289
Write-Message -Message "Failed to retrieve DataPipeline. Error: $errorDetails" -Level Error
9390
}
9491

95-
}
92+
}

source/Public/Data Pipeline/New-FabricDataPipeline.ps1

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
An optional description for the DataPipeline.
1818
1919
.EXAMPLE
20-
New-FabricDataPipeline -WorkspaceId "workspace-12345" -DataPipelineName "New DataPipeline"
20+
New-FabricDataPipeline -WorkspaceId "workspace-12345" -DataPipelineName "New DataPipeline"
2121
This example creates a new DataPipeline named "New DataPipeline" in the workspace with ID "workspace-12345" and uploads the definition file from the specified path.
2222
2323
.NOTES
@@ -53,7 +53,7 @@ function New-FabricDataPipeline
5353
Write-Message -Message "Token validation completed." -Level Debug
5454

5555
# Step 2: Construct the API URL
56-
$apiEndpointURI = "{0}/workspaces/{1}/dataPipelines" -f $FabricConfig.BaseUrl, $WorkspaceId
56+
$apiEndpointURI = ("workspaces/{0}/dataPipelines" -f $WorkspaceId)
5757
Write-Message -Message "API Endpoint: $apiEndpointURI" -Level Debug
5858

5959
# Step 3: Construct the request body
@@ -67,16 +67,18 @@ function New-FabricDataPipeline
6767
}
6868

6969
$bodyJson = $body | ConvertTo-Json -Depth 10
70+
7071
Write-Message -Message "Request Body: $bodyJson" -Level Debug
7172

7273
if ($PSCmdlet.ShouldProcess($apiEndpointURI, "Create DataPipeline"))
7374
{
7475
# Step 4: Make the API request
75-
$response = Invoke-FabricAPIRequest `
76-
-BaseURI $apiEndpointURI `
77-
-Headers $FabricConfig.FabricHeaders `
78-
-method Post `
79-
-body $bodyJson
76+
$apiParams = @{
77+
Uri = $apiEndpointURI
78+
method = 'Post'
79+
body = $bodyJson
80+
}
81+
$response = Invoke-FabricAPIRequest @apiParams
8082
}
8183
Write-Message -Message "Data Pipeline created successfully!" -Level Info
8284
return $response

source/Public/Datamart/Get-FabricDatamart.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ function Get-FabricDatamart {
4848
Write-Message -Message "Token validation completed." -Level Debug
4949
# Step 3: Initialize variables
5050

51-
$apiEndpointURI = "{0}/workspaces/{1}/Datamarts" -f $FabricConfig.BaseUrl, $WorkspaceId
51+
$apiEndpointURI = "workspaces/{0}/Datamarts" -f $WorkspaceId
52+
53+
$apiParams = @{
54+
Uri = $apiEndpointURI
55+
method = 'Get'
56+
}
57+
$Datamarts = Invoke-FabricAPIRequest @apiParams
5258

53-
$Datamarts = = Invoke-FabricAPIRequest `
54-
-BaseURI $apiEndpointURI `
55-
-Headers $FabricConfig.FabricHeaders `
56-
-Method Get
5759
# Step 9: Filter results based on provided parameters
5860

5961
$response = if ($datamartId) {

0 commit comments

Comments
 (0)