-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a fuction that retrieves the DashboardDefinition
- Loading branch information
1 parent
8f2e8b5
commit 7040ecf
Showing
4 changed files
with
296 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Get-RtiDebugInfo | ||
|
||
## SYNOPSIS | ||
Shows internal debug information about the current session. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Get-RtiDebugInfo [-ProgressAction <ActionPreference>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Shows internal debug information about the current session. | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
```powershell | ||
PS C:\> {{ Add example code here }} | ||
``` | ||
|
||
{{ Add example description here }} | ||
|
||
## PARAMETERS | ||
|
||
### -ProgressAction | ||
{{ Fill ProgressAction Description }} | ||
|
||
```yaml | ||
Type: System.Management.Automation.ActionPreference | ||
Parameter Sets: (All) | ||
Aliases: proga | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
## OUTPUTS | ||
## NOTES | ||
## RELATED LINKS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Get-RtiKQLDashboardDefinition | ||
|
||
## SYNOPSIS | ||
Retrieves Fabric KQLDashboard Definitions for a given KQLDashboard. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Get-RtiKQLDashboardDefinition [-WorkspaceId] <String> [[-KQLDashboardName] <String>] | ||
[[-KQLDashboardId] <String>] [[-Format] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Retrieves the Definition of Fabric KQLDashboards. | ||
Without the KQLDashboardName or KQLDashboardID parameter, all KQLDashboards are returned. | ||
If you want to retrieve a specific KQLDashboard, you can use the KQLDashboardName or KQLDashboardID parameter. | ||
These | ||
parameters cannot be used together. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
Get-RtiKQLDashboardDefinition | ||
``` | ||
|
||
## PARAMETERS | ||
|
||
### -Format | ||
{{ Fill Format Description }} | ||
|
||
```yaml | ||
Type: System.String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 4 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -KQLDashboardId | ||
The Id of the KQLDashboard to retrieve. | ||
This parameter cannot be used together with KQLDashboardName. | ||
The value for KQLDashboardID is a GUID. | ||
An example of a GUID is '12345678-1234-1234-1234-123456789012'. | ||
```yaml | ||
Type: System.String | ||
Parameter Sets: (All) | ||
Aliases: Id | ||
|
||
Required: False | ||
Position: 3 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -KQLDashboardName | ||
The name of the KQLDashboard to retrieve. | ||
This parameter cannot be used together with KQLDashboardID. | ||
```yaml | ||
Type: System.String | ||
Parameter Sets: (All) | ||
Aliases: Name, DisplayName | ||
|
||
Required: False | ||
Position: 2 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -ProgressAction | ||
{{ Fill ProgressAction Description }} | ||
```yaml | ||
Type: System.Management.Automation.ActionPreference | ||
Parameter Sets: (All) | ||
Aliases: proga | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -WorkspaceId | ||
Id of the Fabric Workspace for which the KQLDashboards should be retrieved. | ||
The value for WorkspaceId is a GUID. | ||
An example of a GUID is '12345678-1234-1234-1234-123456789012'. | ||
```yaml | ||
Type: System.String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
## OUTPUTS | ||
## NOTES | ||
TODO: Add functionality to list all KQLDashboards. | ||
To do so fetch all workspaces and | ||
then all KQLDashboards in each workspace. | ||
Revision History: | ||
- 2024-11-09 - FGE: Added DisplaName as Alias for KQLDashboardName | ||
## RELATED LINKS |
116 changes: 116 additions & 0 deletions
116
powerrti/Public/KQLDashboard/Get-RtiKQLDashboardDefinition.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
function Get-RtiKQLDashboardDefinition { | ||
#Requires -Version 7.1 | ||
|
||
<# | ||
.SYNOPSIS | ||
Retrieves Fabric KQLDashboard Definitions for a given KQLDashboard. | ||
.DESCRIPTION | ||
Retrieves the Definition of the Fabric KQLDashboard that is specified by the KQLDashboardName or KQLDashboardID. | ||
The KQLDashboard Definition contains the parts of the KQLDashboard, which are the visualizations and their configuration. | ||
This is provided as a JSON object. | ||
.PARAMETER WorkspaceId | ||
Id of the Fabric Workspace in which the KQLDashboard exists. The value for WorkspaceId is a GUID. | ||
An example of a GUID is '12345678-1234-1234-1234-123456789012'. | ||
.PARAMETER KQLDashboardName | ||
The name of the KQLDashboard to retrieve. This parameter cannot be used together with KQLDashboardID. | ||
.PARAMETER KQLDashboardID | ||
The Id of the KQLDashboard to retrieve. This parameter cannot be used together with KQLDashboardName. The value for KQLDashboardID is a GUID. | ||
An example of a GUID is '12345678-1234-1234-1234-123456789012'. | ||
.EXAMPLE | ||
Get-RtiKQLDashboardDefinition ` | ||
-WorkspaceId "12345678-1234-1234-1234-123456789012" ` | ||
-KQLDashboardName "MyKQLDashboard" | ||
This example retrieves the KQLDashboard Definition for the KQLDashboard named "MyKQLDashboard" in the | ||
Workspace with the ID "12345678-1234-1234-1234-123456789012". | ||
.EXAMPLE | ||
$db = Get-RtiKQLDashboardDefinition ` | ||
-WorkspaceId "12345678-1234-1234-1234-123456789012" ` | ||
-KQLDashboardName "MyKQLDashboard" | ||
$db[0].payload | ` | ||
Set-Content ` | ||
-Path "C:\temp\mydashboard.json" | ||
This example retrieves the KQLDashboard Definition for the KQLDashboard named "MyKQLDashboard" in the | ||
Workspace with the ID "12345678-1234-1234-1234-123456789012". | ||
The definition is saved to a file named "mydashboard.json". | ||
.NOTES | ||
Revision History: | ||
- 2024-11-16 - FGE: First version | ||
#> | ||
|
||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory=$true)] | ||
[string]$WorkspaceId, | ||
|
||
[Alias("Name","DisplayName")] | ||
[string]$KQLDashboardName, | ||
|
||
[Alias("Id")] | ||
[string]$KQLDashboardId, | ||
|
||
[string]$Format | ||
) | ||
|
||
begin { | ||
|
||
# Check if session is established - if not throw error | ||
if ($null -eq $RTISession.headerParams) { | ||
throw "No session established to Fabric Real-Time Intelligence. Please run Connect-RTISession" | ||
} | ||
|
||
# You can either use Name or WorkspaceID | ||
if ($PSBoundParameters.ContainsKey("KQLDashboardName") -and $PSBoundParameters.ContainsKey("KQLDashboardId")) { | ||
throw "Parameters KQLDashboardName and KQLDashboardId cannot be used together" | ||
} | ||
|
||
# Create KQLDashboard API | ||
$KQLDashboardAPI = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/KQLDashboards" | ||
|
||
$KQLDashboardAPIKQLDashboardId = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/KQLDashboards/$KQLDashboardId/getDefinition" | ||
|
||
$body = @{ | ||
} | ConvertTo-Json ` | ||
-Depth 1 | ||
|
||
} | ||
|
||
process { | ||
|
||
if ($PSBoundParameters.ContainsKey("KQLDashboardId")) { | ||
|
||
$response = Invoke-RestMethod ` | ||
-Headers $RTISession.headerParams ` | ||
-Method POST ` | ||
-Uri $KQLDashboardAPIKQLDashboardId ` | ||
-Body $null ` | ||
-ContentType "application/json" | ||
|
||
$parts = $response.definition.parts | ||
|
||
foreach ($part in $parts) { | ||
$bytes = [System.Convert]::FromBase64String($part.payload) | ||
$decodedText = [System.Text.Encoding]::UTF8.GetString($bytes) | ||
|
||
$part.payload = $decodedText | ||
} | ||
|
||
$parts | ||
} | ||
} | ||
|
||
end {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters