Modules/snapshots.psm1
# GET /rest/v1.0/dd-systems/{SYSTEM-ID}/snapshots function Get-DDSnapshots { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $true, ParameterSetName = 'byID',ValueFromPipelineByPropertyName = $true)] [string]$id, [Parameter(Mandatory = $false, ParameterSetName = 'byID')] [Parameter(Mandatory = $false, ParameterSetName = 'default')] [string] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "GET" } process { switch ($PsCmdlet.ParameterSetName) { default { $apiver = "rest/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/snapshots" } 'byID' { $apiver = "rest/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/snapshots/$ID" } } $parameters = @{ uri = $uri apiver = $apiver Method = $METHOD body = $body RequestMethod = "REST" Verbose = $PSBoundParameters['Verbose'] -eq $true } try { $Response += Invoke-DDapirequest @Parameters } catch { Get-DDWebException -ExceptionMessage $_ break } write-verbose ($response | Out-String) } end { switch ($PsCmdlet.ParameterSetName) { 'default' { $response.snapshot | Select-Object -ExcludeProperty links, link # -Property *,@{N="alert_gen";E={(Get-Date 01.01.1970)+([System.TimeSpan]::fromseconds($_.alert_gen_epoch))}},@{N="clear";E={(Get-Date 01.01.1970)+([System.TimeSpan]::fromseconds($_.clear_epoch))}} } 'byID' { $response | Select-Object -Property * -ExcludeProperty link } } } } |