Skip to content

Commit

Permalink
Worked on code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank-Geisler committed Nov 25, 2024
1 parent bc1ce46 commit 5742d94
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 56 deletions.
2 changes: 1 addition & 1 deletion powerrti/Public/Connect-RTIAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Connect-RtiAccount {
.PARAMETER TenantId
The TenantId of the Azure Active Directory tenant you want to connect to
and in which your Fabric Capacity is.
.EXAMPLE
Connect-RTIAccount `
-TenantID '12345678-1234-1234-1234-123456789012'
Expand Down
45 changes: 28 additions & 17 deletions powerrti/Public/Eventhouse/Get-RTIEventhouse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ function Get-RtiEventhouse {
parameters cannot be used together.
.PARAMETER WorkspaceId
Id of the Fabric Workspace for which the Eventhouses should be retrieved. The value for WorkspaceId is a GUID.
Id of the Fabric Workspace for which the Eventhouses should be retrieved. The value for WorkspaceId is a GUID.
An example of a GUID is '12345678-1234-1234-1234-123456789012'.
.PARAMETER EventhouseName
The name of the Eventhouse to retrieve. This parameter cannot be used together with EventhouseID.
The name of the Eventhouse to retrieve. This parameter cannot be used together with EventhouseID.
.PARAMETER EventhouseId
The Id of the Eventhouse to retrieve. This parameter cannot be used together with EventhouseName. The value for WorkspaceId is a GUID.
The Id of the Eventhouse to retrieve. This parameter cannot be used together with EventhouseName. The value for WorkspaceId is a GUID.
An example of a GUID is '12345678-1234-1234-1234-123456789012'.
.EXAMPLE
Get-RTIEventhouse `
-WorkspaceId '12345678-1234-1234-1234-123456789012'
-WorkspaceId '12345678-1234-1234-1234-123456789012'
This example will give you all Eventhouses in the Workspace.
Expand All @@ -39,18 +39,19 @@ function Get-RtiEventhouse {
-WorkspaceId '12345678-1234-1234-1234-123456789012' `
-EventhouseId '12345678-1234-1234-1234-123456789012'
This example will give you all Information about the Eventhouse with the Id '12345678-1234-1234-1234-123456789012'.
This example will give you all Information about the Eventhouse with the Id '12345678-1234-1234-1234-123456789012'.
.LINK
https://learn.microsoft.com/en-us/rest/api/fabric/eventhouse/items/list-eventhouses?tabs=HTTP
.NOTES
TODO: Add functionality to list all Eventhouses in the subscription. To do so fetch all workspaces
TODO: Add functionality to list all Eventhouses in the subscription. To do so fetch all workspaces
and then all eventhouses in each workspace.
Revsion History:
- 2024-11-09 - FGE: Added DisplaName as Alias for EventhouseName
- 2024-11-16 - FGE: Added Verbose Output
#>

#
Expand All @@ -69,95 +70,103 @@ function Get-RtiEventhouse {

begin {

# Check if session is established - if not throw error
Write-Verbose "Checking 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
Write-Verbose "Checking if EventhouseName and EventhouseID are used together. This is not allowed"
if ($PSBoundParameters.ContainsKey("EventhouseName") -and $PSBoundParameters.ContainsKey("EventhouseID")) {
throw "Parameters EventhouseName and EventhouseID cannot be used together"
throw "Parameters EventhouseName and EventhouseID cannot be used together"
}

# Create Eventhouse API
$eventhouseAPI = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses"

$eventhouseAPIEventhouseId = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses/$EventhouseId"
$eventhouseAPI = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses"
Write-Verbose "Creating the URL for the Eventhouse API: $eventhouseAPI"

$eventhouseAPIEventhouseId = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses/$EventhouseId"
Write-Verbose "Creating the URL for the Eventhouse API when the Id is used: $eventhouseAPIEventhouseId"
}

process {

if ($PSBoundParameters.ContainsKey("EventhouseId")) {

Write-Verbose "Calling Eventhouse API with EventhouseId"
$response = Invoke-RestMethod `
-Headers $RTISession.headerParams `
-Method GET `
-Uri $eventhouseAPIEventhouseId `
-ContentType "application/json"

# FGE: adding Members for convenience
Write-Verbose "Adding the member queryServiceUri"
Add-Member `
-MemberType NoteProperty `
-Name 'queryServiceUri' `
-Value $response.properties.queryServiceUri `
-InputObject $response `
-Force

Write-Verbose "Adding the member ingestionServiceUri"
Add-Member `
-MemberType NoteProperty `
-Name 'ingestionServiceUri' `
-Value $response.properties.ingestionServiceUri `
-InputObject $response `
-Force

Write-Verbose "Adding the member databasesItemIds"
Add-Member `
-MemberType NoteProperty `
-Name 'databasesItemIds' `
-Value $response.properties.databasesItemIds `
-InputObject $response `
-Force

Write-Verbose "Adding the member minimumConsumptionUnits"
Add-Member `
-MemberType NoteProperty `
-Name 'minimumConsumptionUnits' `
-Value $response.properties.minimumConsumptionUnits `
-InputObject $response `
-Force

$response
}
else {
# Call Workspace API
Write-Verbose "Calling Eventhouse API without EventhouseId"
$response = Invoke-RestMethod `
-Headers $RTISession.headerParams `
-Method GET `
-Uri $eventhouseAPI `
-ContentType "application/json"

foreach ($eventhouse in $response.value) {
# FGE: adding Members for convenience
Write-Verbose "Adding the member queryServiceUri"
Add-Member `
-MemberType NoteProperty `
-Name 'queryServiceUri' `
-Value $eventhouse.properties.queryServiceUri `
-InputObject $eventhouse `
-Force

Write-Verbose "Adding the member ingestionServiceUri"
Add-Member `
-MemberType NoteProperty `
-Name 'ingestionServiceUri' `
-Value $eventhouse.properties.ingestionServiceUri `
-InputObject $eventhouse `
-Force

Write-Verbose "Adding the member databasesItemIds"
Add-Member `
-MemberType NoteProperty `
-Name 'databasesItemIds' `
-Value $eventhouse.properties.databasesItemIds `
-InputObject $eventhouse `
-Force

Write-Verbose "Adding the member minimumConsumptionUnits"
Add-Member `
-MemberType NoteProperty `
-Name 'minimumConsumptionUnits' `
Expand All @@ -167,10 +176,12 @@ process {
}

if ($PSBoundParameters.ContainsKey("EventhouseName")) {
Write-Verbose "Filtering the Eventhouse by EventhouseName"
$response.value | `
Where-Object { $_.displayName -eq $EventhouseName }
}
else {
Write-Verbose "Returning all Eventhouses"
$response.value
}
}
Expand Down
10 changes: 5 additions & 5 deletions powerrti/Public/Eventhouse/New-RTIEventhouse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function New-RtiEventhouse {
.NOTES
Revsion History:
- 2024-11-07 - FGE: Implemented SupportShouldProcess
- 2024-11-09 - FGE: Added DisplaName as Alias for EventhouseName
Expand All @@ -41,8 +41,8 @@ function New-RtiEventhouse {
param (

[Parameter(Mandatory=$true)]
[string]$WorkspaceID,
[string]$WorkspaceID,

[Parameter(Mandatory=$true)]
[Alias("Name", "DisplayName")]
[string]$EventhouseName,
Expand All @@ -53,7 +53,7 @@ function New-RtiEventhouse {
)

begin {
# Check if session is established - if not throw error
Write-Verbose "Checking 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"
}
Expand All @@ -66,7 +66,7 @@ begin {
-Depth 1

# Create Eventhouse API URL
$eventhouseApiUrl = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses"
$eventhouseApiUrl = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses"
}

process {
Expand Down
22 changes: 11 additions & 11 deletions powerrti/Public/Eventhouse/Remove-RTIEventhouse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ function Remove-RtiEventhouse {
Removes an existing Fabric Eventhouse
.PARAMETER WorkspaceId
Id of the Fabric Workspace for which the Eventhouse should be deleted. The value for WorkspaceId is a GUID.
Id of the Fabric Workspace for which the Eventhouse should be deleted. The value for WorkspaceId is a GUID.
An example of a GUID is '12345678-1234-1234-1234-123456789012'.
.PARAMETER EventhouseId
The Id of the Eventhouse to delete. The value for EventhouseId is a GUID.
The Id of the Eventhouse to delete. The value for EventhouseId is a GUID.
An example of a GUID is '12345678-1234-1234-1234-123456789012'. EventhouseId and EventhouseName cannot be used together.
.PARAMETER EventhouseName
Expand All @@ -23,20 +23,20 @@ function Remove-RtiEventhouse {
Remove-RtiEventhouse `
-WorkspaceId '12345678-1234-1234-1234-123456789012' `
-EventhouseId '12345678-1234-1234-1234-123456789012'
This example will delete the Eventhouse with the Id '12345678-1234-1234-1234-123456789012' from
This example will delete the Eventhouse with the Id '12345678-1234-1234-1234-123456789012' from
the Workspace with the Id '12345678-1234-1234-1234-123456789012'.
.EXAMPLE
Remove-RtiEventhouse `
-WorkspaceId '12345678-1234-1234-1234-123456789012' `
-EventhouseName 'MyEventhouse'
This example will delete the Eventhouse with the name 'MyEventhouse' from the Workspace with the
This example will delete the Eventhouse with the name 'MyEventhouse' from the Workspace with the
Id '12345678-1234-1234-1234-123456789012'.
.NOTES
Revsion History:
- 2024-11-07 - FGE: Implemented SupportShouldProcess
- 2024-11-09 - FGE: Added DisplaName as Alias for EventhouseName
Expand All @@ -48,8 +48,8 @@ function Remove-RtiEventhouse {
param (

[Parameter(Mandatory=$true)]
[string]$WorkspaceId,
[string]$WorkspaceId,

[Alias("Id")]
[string]$EventhouseId,

Expand All @@ -66,7 +66,7 @@ begin {

# You can either use Name or WorkspaceID
if ($PSBoundParameters.ContainsKey("EventhouseName") -and $PSBoundParameters.ContainsKey("EventhouseID")) {
throw "Parameters EventhouseName and EventhouseID cannot be used together"
throw "Parameters EventhouseName and EventhouseID cannot be used together"
}

if ($PSBoundParameters.ContainsKey("EventhouseName")) {
Expand All @@ -78,7 +78,7 @@ begin {
}

# Create Eventhouse API URL
$eventhouseApiUrl = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses/$EventhouseId"
$eventhouseApiUrl = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses/$EventhouseId"
}

process {
Expand Down
20 changes: 10 additions & 10 deletions powerrti/Public/Eventhouse/Set-RtiEventhouse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ function Set-RtiEventhouse {
Updates Properties of an existing Fabric Eventhouse
.PARAMETER WorkspaceId
Id of the Fabric Workspace for which the Eventhouse should be updated. The value for WorkspaceId is a GUID.
Id of the Fabric Workspace for which the Eventhouse should be updated. The value for WorkspaceId is a GUID.
An example of a GUID is '12345678-1234-1234-1234-123456789012'.
.PARAMETER EventhouseId
The Id of the Eventhouse to update. The value for EventhouseId is a GUID.
The Id of the Eventhouse to update. The value for EventhouseId is a GUID.
An example of a GUID is '12345678-1234-1234-1234-123456789012'.
.PARAMETER EventhouseNewName
Expand All @@ -29,18 +29,18 @@ function Set-RtiEventhouse {
-EventhouseNewName 'MyNewEventhouse' `
-EventhouseDescription 'This is my new Eventhouse'
This example will update the Eventhouse with the Id '12345678-1234-1234-1234-123456789012'
This example will update the Eventhouse with the Id '12345678-1234-1234-1234-123456789012'
in the Workspace with the Id '12345678-1234-1234-1234-123456789012' to
have the name 'MyNewEventhouse' and the description
have the name 'MyNewEventhouse' and the description
'This is my new Eventhouse'.
.NOTES
TODO: Add functionality to update Eventhouse properties using EventhouseName instead of EventhouseId
Revsion History:
- 2024-11-07 - FGE: Implemented SupportShouldProcess
- 2024-11-09 - FGE: Added NewDisplaName as Alias for EventhouseName
- 2024-11-09 - FGE: Added NewDisplaName as Alias for EventhouseName
.LINK
https://learn.microsoft.com/en-us/rest/api/fabric/eventhouse/items/create-eventhouse?tabs=HTTP
Expand All @@ -50,12 +50,12 @@ function Set-RtiEventhouse {
param (

[Parameter(Mandatory=$true)]
[string]$WorkspaceId,
[string]$WorkspaceId,

[Parameter(Mandatory=$true)]
[Alias("Id")]
[string]$EventhouseId,
[string]$EventhouseId,

[Alias("NewName", "NewDisplayName")]
[string]$EventhouseNewName,

Expand Down Expand Up @@ -87,7 +87,7 @@ begin {
-Depth 1

# Create Eventhouse API URL
$eventhouseApiUrl = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses/$EventhouseId"
$eventhouseApiUrl = "$($RTISession.BaseFabricUrl)/v1/workspaces/$WorkspaceId/eventhouses/$EventhouseId"
}

process {
Expand Down
Loading

0 comments on commit 5742d94

Please sign in to comment.