Public/Show-PegasusSyncOperation.ps1
function Show-PegasusSyncOperation { [CmdletBinding()] Param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] $Operation ) Begin { } Process { $color = switch($Operation.Method) { "POST" { $PSStyle.Foreground.BrightGreen } "PATCH" { $PSStyle.Foreground.BrightYellow } "DELETE"{ $PSStyle.Foreground.BrightRed } default { $PSStyle.Foreground.White } } Write-Host "$color$($Operation.Type) -> $($Operation.Method) $($PSStyle.Reset)$($Operation.Endpoint)" if($Operation.Method -eq "POST") { if($Operation.Body) { $Operation.Body | ConvertTo-Json -Depth 10 | Write-Host } else { Write-Warning "Body not provided for POST operation" } } if($Operation.Method -eq "PATCH") { if($Operation.Body) { $Operation.Body | ConvertTo-Json -Depth 10 | Write-Host } else { Write-Warning "Body object not provided for PATCH operation" } Write-Host Write-Host "There are differences between the old object below in the following properties: $($Operation.Difference -join ", ")" Write-Host if($Operation.Old) { $Operation.Old | ConvertTo-Json -Depth 10 | Write-Host } else { Write-Warning "Old object not provided for PATCH operation" } Write-Host } if($Operation.Method -eq "DELETE") { if($Operation.Old) { $Operation.Old | ConvertTo-Json -Depth 10 | Write-Host } else { Write-Warning "Old object not provided for DELETE operation" } } } End { } } |