Change psm template

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