Public/Get-DattoBcdrAsset.ps1
|
function Get-DattoBcdrAsset { <# .SYNOPSIS Returns BCDR assets for a device or an asset for a protected volume. .DESCRIPTION Implements GET /v1/bcdr/device/{serialNumber}/asset and GET /v1/bcdr/device/{serialNumber}/asset/{volumeName}. The response contract allows either a direct array or an envelope, both of which are handled. .PARAMETER SerialNumber The BCDR device serial number. .PARAMETER VolumeName The protected volume name returned in the asset volume field. .PARAMETER Page The one-based API page number for asset listings. .PARAMETER PerPage The number of records requested per page. .PARAMETER All Retrieves every available listing page. .PARAMETER RawResponse Returns the API response body or envelope. .PARAMETER Connection A connection object, name, or ID. .EXAMPLE Get-DattoBcdrAsset -SerialNumber 'ABC123ABC1' -All .EXAMPLE Get-DattoBcdrAsset -SerialNumber 'ABC123ABC1' -VolumeName '4b65219643aa4bc78e359928ead7fab5' #> [CmdletBinding(DefaultParameterSetName = 'List')] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)][ValidateNotNullOrEmpty()][string]$SerialNumber, [Parameter(Mandatory, ParameterSetName = 'ByVolume')][ValidateNotNullOrEmpty()][string]$VolumeName, [Parameter(ParameterSetName = 'List')][ValidateRange(1, [int]::MaxValue)][int]$Page = 1, [Parameter(ParameterSetName = 'List')][ValidateRange(1, [int]::MaxValue)][int]$PerPage = 25, [Parameter(ParameterSetName = 'List')][switch]$All, [Parameter()][switch]$RawResponse, [Parameter()][AllowNull()][object]$Connection ) process { $serial = ConvertTo-DattoApiPathSegment -Value $SerialNumber if ($PSCmdlet.ParameterSetName -eq 'ByVolume') { $volume = ConvertTo-DattoApiPathSegment -Value $VolumeName Invoke-DattoApiRequest -Path "/v1/bcdr/device/$serial/asset/$volume" -RawResponse:$RawResponse -Connection $Connection } else { Invoke-DattoApiRequest -Path "/v1/bcdr/device/$serial/asset" -Query @{ _page = $Page; _perPage = $PerPage } -All:$All -RawResponse:$RawResponse -Connection $Connection } } } |