Public/generated/Invoke-KriticalUtcmM365DscSchemaBridge.ps1
|
# Kritical.PS.UTCM | Microsoft Graph UTCM REST API toolkit # (c) 2026 Kritical Pty Ltd | https://kritical.net # Kritical brand banner is rendered at module load via Write-KriticalUtcmBanner. function Invoke-KriticalUtcmM365DscSchemaBridge { <# .SYNOPSIS Dispatch bridge from auto-generated Kritical.UTCM Get-* / Test-* / Set-* function to actual Graph endpoint. Populated per-resource in follow-up waves. #> [CmdletBinding()] param( [Parameter(Mandatory)][string]$ResourceName, [Parameter(Mandatory)][string]$Workload, [Parameter(Mandatory)][ValidateSet('Get','Test','Set','New','Remove')][string]$Verb, [hashtable]$CallerParams ) # Try dispatch via the auto-generated endpoint map first. $mapPath = Join-Path $PSScriptRoot '../../../generated/endpoint-map.json' $mapPath = Resolve-Path $mapPath -ErrorAction SilentlyContinue $endpoint = $null if ($mapPath) { try { $map = Get-Content $mapPath.Path -Raw | ConvertFrom-Json if ($map.PSObject.Properties.Name -contains $ResourceName) { $endpoint = $map.$ResourceName } } catch { } } if (-not $endpoint) { return [pscustomobject]@{ ResourceName = $ResourceName Workload = $Workload Verb = $Verb Verdict = 'UNMAPPED' Reason = 'Endpoint-map does not carry a mapping for this resource yet. Follow-up wave will add via Ship-KriticalUtcmEndpointMap.ps1.' CallerParams = $CallerParams } } # Delegate to Krit.EntraId primitive (uses pagination + backoff + retry) if (-not (Get-Module Krit.EntraId)) { $entraPath = Resolve-Path (Join-Path $PSScriptRoot '../../../../KRTPax8ToShopifyConnector/scripts/m365-setup/Krit.EntraId.psm1') -ErrorAction SilentlyContinue if ($entraPath) { Import-Module $entraPath.Path -Force } } switch ($Verb) { 'Get' { $r = Invoke-KritEntraApi -Path $endpoint.Path -UseBeta:$endpoint.UseBeta return [pscustomobject]@{ ResourceName = $ResourceName Workload = $Workload Verb = 'Get' Verdict = 'OK' Endpoint = $endpoint.Path Value = @($r.value) Count = @($r.value).Count } } default { return [pscustomobject]@{ ResourceName = $ResourceName Workload = $Workload Verb = $Verb Verdict = 'VERB-NOT-YET-IMPLEMENTED' Endpoint = $endpoint.Path } } } } |