Compare commits
3
Commits
fd7809e017
...
71c78fc7fe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71c78fc7fe | ||
|
|
472b7d9df7 | ||
|
|
9ed4fbb7ef |
+8
-7
@@ -99,7 +99,7 @@ function Get-CodeServerObject!NAME! {
|
||||
$params.Add("CacheKeyProperty", $CacheKeyProperty)
|
||||
}
|
||||
|
||||
[void](Get-AllCodeServerPagesRoles @params)
|
||||
[void](Get-AllCodeServerPages!NAME! @params)
|
||||
}
|
||||
|
||||
$cacheKey = $Resource.GetHashCode()
|
||||
@@ -119,6 +119,7 @@ function Get-CodeServerObject!NAME! {
|
||||
convert_from = """
|
||||
Function ConvertFrom-CodeServerObject!NAME!([PSCustomObject[]]$codeServerObject!NAME!) {
|
||||
$map = @{
|
||||
"conceptCodeId" = "conceptCodeId";
|
||||
!MAPS!
|
||||
}
|
||||
|
||||
@@ -145,27 +146,27 @@ class CodeServer!NAME! {
|
||||
!VARIABLES!
|
||||
|
||||
}
|
||||
|
||||
[string]${conceptCodeId}
|
||||
!STRINGS!
|
||||
|
||||
}
|
||||
|
||||
Export-ModuleMember ConvertFrom-CodeServerObject!NAME!
|
||||
Export-AllCodeServerPages!NAME!
|
||||
Export-CodeServerObject!NAME!
|
||||
Export-ModuleMember Get-AllCodeServerPages!NAME!
|
||||
Export-ModuleMember Get-CodeServerObject!NAME!
|
||||
"""
|
||||
|
||||
def define_maps(items: list[str]) -> str:
|
||||
return "\n".join([f"\t'{sanitize_name(item)}' = '{item}'" for item in items])
|
||||
return "\n".join([f"\t\"{sanitize_name(item)}\" = \"{item}\";" for item in items])
|
||||
|
||||
def define_variables(items: list[str]) -> str:
|
||||
return "\n".join([f"\t$this.{{{sanitize_name(item)}}} = $dic['{item}']" for item in items])
|
||||
return "\n".join([f"\t$this.{{{sanitize_name(item)}}} = $dic[\"{item}\"]" for item in items])
|
||||
|
||||
def define_strings(items: list[str]) -> str:
|
||||
return "\n".join(["\t" + "[string]$" + "{" + sanitize_name(item) + "}" for item in items])
|
||||
|
||||
|
||||
def write_psm(name, items: list[str], filename: Path = Path("Connector.psm1")) -> str:
|
||||
def write_psm(name, items: list[str], filename: Path = Path("CodeServerConnector.psm1")) -> str:
|
||||
if filename.exists():
|
||||
backup_filename = str(filename) + f".{datetime.now().strftime('%Y-%m-%d.%H%M%S')}.bak"
|
||||
shutil.copy2(filename, backup_filename)
|
||||
|
||||
+8
-8
@@ -46,8 +46,8 @@ def add_connection(root: ET.Element, name: str, attr_list: list[str], descriptio
|
||||
predefined_commands = initialization.find("PredefinedCommands")
|
||||
if predefined_commands is None:
|
||||
predefined_commands = ET.SubElement(initialization, "PredefinedCommands")
|
||||
ET.SubElement(predefined_commands, "Command", Name=f"Get-AllCodeServerPages{name}", Description=f"Get all pages for {name}")
|
||||
ET.SubElement(predefined_commands, "Command", Name=f"Get-CodeServerPage{name}", Description=f"Get a specific page for {name}")
|
||||
ET.SubElement(predefined_commands, "Command", Name=f"Get-AllCodeServerPages{name}")
|
||||
ET.SubElement(predefined_commands, "Command", Name=f"Get-CodeServerObject{name}")
|
||||
|
||||
schema = root.find("Schema")
|
||||
if schema is not None:
|
||||
@@ -55,24 +55,24 @@ def add_connection(root: ET.Element, name: str, attr_list: list[str], descriptio
|
||||
new_class = ET.SubElement(schema, "Class", Name=f"CodeServerObject{name}")
|
||||
properties = ET.SubElement(new_class, "Properties")
|
||||
property = ET.SubElement(properties, "Property", Name="conceptCodeId", DataType="String", IsMultivalue="false", IsAutoFill="false", IsUniqueKey="true")
|
||||
return_binding = ET.SubElement(property, "ReturnBinding")
|
||||
return_binding = ET.SubElement(property, "ReturnBindings")
|
||||
ET.SubElement(return_binding, "Bind", CommandResultOf=f"Get-AllCodeServerPages{name}", Path="conceptCodeId")
|
||||
ET.SubElement(return_binding, "Bind", CommandResultOf=f"Get-CodeServerPage{name}", Path="conceptCodeId")
|
||||
ET.SubElement(return_binding, "Bind", CommandResultOf=f"Get-CodeServerObject{name}", Path="conceptCodeId")
|
||||
mapping = ET.SubElement(property, "CommandMappings")
|
||||
ET.SubElement(mapping, "Map", ToCommand=f"Get-CodeServerPages{name}", Parameter="conceptCodeId")
|
||||
ET.SubElement(mapping, "Map", ToCommand=f"Get-AllCodeServerPages{name}", Parameter="conceptCodeId")
|
||||
|
||||
for attr in attr_list:
|
||||
property = ET.SubElement(properties, "Property", Name=sanitize_name(attr), DataType="String", IsMultivalue="false", IsAutoFill="false")
|
||||
return_binding = ET.SubElement(property, "ReturnBinding")
|
||||
return_binding = ET.SubElement(property, "ReturnBindings")
|
||||
ET.SubElement(return_binding, "Bind", CommandResultOf=f"Get-AllCodeServerPages{name}", Path=sanitize_name(attr))
|
||||
ET.SubElement(return_binding, "Bind", CommandResultOf=f"Get-CodeServerPage{name}", Path=sanitize_name(attr))
|
||||
ET.SubElement(return_binding, "Bind", CommandResultOf=f"Get-CodeServerObject{name}", Path=sanitize_name(attr))
|
||||
|
||||
read_configuration = ET.SubElement(new_class, "ReadConfiguration")
|
||||
listing_command = ET.SubElement(read_configuration, "ListingCommand", Command=f"Get-AllCodeServerPages{name}")
|
||||
ET.SubElement(listing_command, "SetParameter", Param="Resource", Source="ConnectionParameter", Value=f"VarhaUrl{name}")
|
||||
ET.SubElement(listing_command, "SetParameter", Param="RootProperty", Source="FixedValue", Value="conceptCodes")
|
||||
cmd_squence = ET.SubElement(read_configuration, "CommandSequence")
|
||||
item = ET.SubElement(cmd_squence, "Item", Command=f"Get-CodeServerPage{name}", Order="1")
|
||||
item = ET.SubElement(cmd_squence, "Item", Command=f"Get-CodeServerObject{name}", Order="1")
|
||||
ET.SubElement(item, "SetParameter", Param="Resource", Source="ConnectionParameter", Value=f"VarhaUrl{name}")
|
||||
ET.SubElement(item, "SetParameter", Param="RootProperty", Source="FixedValue", Value="conceptCodes")
|
||||
return root
|
||||
|
||||
Reference in New Issue
Block a user