Pax8API/Public/Get-Pax8Schema.ps1
|
function Get-Pax8Schema { [CmdletBinding()] param ( [ArgumentCompleter({ param($commandName, $parameterName, $wordToComplete) $catalog = Get-Pax8SchemaCatalog @($catalog.schemas.Name | Sort-Object -Unique | Where-Object { $_ -like "$wordToComplete*" }) })] [Alias('SchemaName')] [string]$Name, [ValidateSet('Partner', 'Quoting', 'VendorProvisioning', 'VendorUsage', 'Webhooks', 'Authentication')] [string]$Scope, [string]$SpecFile, [switch]$ListAvailable ) $catalog = Get-Pax8SchemaCatalog $schemas = @($catalog.schemas) if ($Name) { $schemas = @($schemas | Where-Object { $_.Name -eq $Name }) } if ($Scope) { $schemas = @($schemas | Where-Object { $_.Scope -eq $Scope }) } if ($SpecFile) { $schemas = @($schemas | Where-Object { $_.SpecFile -eq $SpecFile }) } if ($ListAvailable) { return $schemas | Sort-Object Scope, Name | Select-Object Name, Scope, SpecFile, @{ Name = 'Type'; Expression = { $_.Schema.Type } }, @{ Name = 'PropertyCount'; Expression = { @($_.Schema.Properties).Count } } } $schemas | Sort-Object Scope, Name } |