-
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.
- Loading branch information
Showing
3 changed files
with
53 additions
and
53 deletions.
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
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 @@ | ||
function Deploy-FabricItems { | ||
param ( | ||
[string]$DestinationWorkspaceId, | ||
|
||
[ValidateSet("Notebook")] | ||
[string]$Type | ||
) | ||
|
||
# Get all items of the specified type in the destination workspace | ||
$items = Get-FabricItems -Type $Type -WorkspaceId $DestinationWorkspaceId | ||
|
||
# Get all directories in the current directory that end with .Notebook | ||
$itemDirs = Get-ChildItem -Directory | Where-Object { $_.Name -like "*.$Type" } | ||
|
||
# Loop through each directory in the source which is a notebook | ||
foreach ($dir in $itemDirs) { | ||
|
||
# grab the item name, which is before the '.' in the directory name | ||
$ItemName = $dir.Name.Split('.')[0] | ||
|
||
$existingItem = $items.value | Where-Object { $_.DisplayName -eq $ItemName } | ||
|
||
# Check if the notebook already exists in the destination workspace | ||
if ($null -eq $existingItem) { | ||
|
||
$newItem = New-FabricItem ` | ||
-WorkspaceId $DestinationWorkspaceId ` | ||
-DisplayName $ItemName ` | ||
-Type $Type | ||
|
||
# Set the notebookToUpdateId to the new notebook's Id so I can set the payload | ||
$itemToUpdateId = $newItem.Id | ||
} else { | ||
# Set the notebookToUpdateId to the existing notebook's Id so I can set the payload | ||
$itemToUpdateId = $existingItem.Id | ||
} | ||
|
||
if ($Type -eq 'Notebook') { | ||
$payload = Get-NotebookDefinitionPayload -dir $dir | ||
} | ||
|
||
Update-FabricItemDefinition ` | ||
-WorkspaceId $DestinationWorkspaceId ` | ||
-ItemId $itemToUpdateId ` | ||
-Definition $payload | ||
|
||
# todo - compare the list of notebooks in the destination that are in the source code | ||
# if the notebook is not in the source code, delete it from the destination | ||
} | ||
} |
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