Change psm template

This commit is contained in:
Esa Kataja
2025-03-20 11:02:32 +02:00
parent 2034353958
commit c897b1d7f9
+1 -22
View File
@@ -10,17 +10,12 @@ function Get-AllCodeServerPages!NAME! {
param ( param (
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$Resource, [string]$Resource,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$RootProperty, [string]$RootProperty,
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$CacheKeyProperty = "conceptCodeId", [string]$CacheKeyProperty = "conceptCodeId",
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[ScriptBlock]$Converter = ${function:ConvertFrom-CodeServerObject!NAME!}, [ScriptBlock]$Converter = ${function:ConvertFrom-CodeServerObject!NAME!},
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[int]$PageSize = 500 [int]$PageSize = 500
) )
@@ -32,7 +27,6 @@ function Get-AllCodeServerPages!NAME! {
$cacheKey = $Resource.GetHashCode() $cacheKey = $Resource.GetHashCode()
$cache[$cacheKey] = @{} $cache[$cacheKey] = @{}
} }
process { process {
$currentPage = 0; $currentPage = 0;
$Global:debugOut = @() $Global:debugOut = @()
@@ -56,16 +50,12 @@ function Get-AllCodeServerPages!NAME! {
$Global:cache[$cacheKey].Add($key, $codeObject.attributes) $Global:cache[$cacheKey].Add($key, $codeObject.attributes)
} }
} }
} }
} }
write-output $cache[$cacheKey].Values write-output $cache[$cacheKey].Values
} }
end { end {
} }
} }
""" """
@@ -76,32 +66,25 @@ function Get-CodeServerObject!NAME! {
param ( param (
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$conceptCodeId, [string]$conceptCodeId,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$Resource, [string]$Resource,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$RootProperty, [string]$RootProperty,
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$CacheKeyProperty = "conceptCodeId" [string]$CacheKeyProperty = "conceptCodeId"
) )
begin { begin {
if ($null -eq $Global:cache) { if ($null -eq $Global:cache) {
$params = @{ $params = @{
Resource = $Resource; Resource = $Resource;
RootProperty = $RootProperty; RootProperty = $RootProperty;
} }
if ($PSBoundParameters.ContainsKey("CacheKeyProperty")) { if ($PSBoundParameters.ContainsKey("CacheKeyProperty")) {
$params.Add("CacheKeyProperty", $CacheKeyProperty) $params.Add("CacheKeyProperty", $CacheKeyProperty)
} }
[void](Get-AllCodeServerPages!NAME! @params) [void](Get-AllCodeServerPages!NAME! @params)
} }
$cacheKey = $Resource.GetHashCode() $cacheKey = $Resource.GetHashCode()
} }
@@ -109,9 +92,7 @@ function Get-CodeServerObject!NAME! {
Write-Debug $cacheKey Write-Debug $cacheKey
Write-Output $cache[$cacheKey][$conceptCodeId] Write-Output $cache[$cacheKey][$conceptCodeId]
} }
end { end {
} }
} }
""" """
@@ -151,9 +132,7 @@ class CodeServer!NAME! {
} }
Export-ModuleMember ConvertFrom-CodeServerObject!NAME! Export-ModuleMember ConvertFrom-CodeServerObject!NAME!, Get-AllCodeServerPages!NAME!,Get-CodeServerObject!NAME!
Export-ModuleMember Get-AllCodeServerPages!NAME!
Export-ModuleMember Get-CodeServerObject!NAME!
""" """
def define_maps(items: list[str]) -> str: def define_maps(items: list[str]) -> str: