Functions/Public/Get-DeviceStatistics.ps1
|
<#
.SYNOPSIS Retrieve a list of device statistics data from MVB. .PARAMETER GroupId The group_id to filter by. .PARAMETER Group The Group object(s) to filter by. .PARAMETER DeviceId The device_id to filter by. .PARAMETER Device The Device object(s) to filter by. .PARAMETER GroupDevice The GroupDevice object(s) to filter by. .PARAMETER Count Optional. The number of results to return per page. Default is 100. .PARAMETER Page Optional. The page number to return. Default is 1. #> function Get-DeviceStatistics { [CmdletBinding(DefaultParameterSetName = "GroupId")] param ( [Parameter(ParameterSetName = "Device", ValueFromPipeline)] [PSTypeName("ViewSonic.myViewBoard.DeviceProfile")] [object[]] $Device, [Parameter(ParameterSetName = "GroupDevice", ValueFromPipeline)] [PSTypeName("ViewSonic.myViewBoard.GroupDeviceInfo")] [object[]] $GroupDevice, [Parameter(ParameterSetName = "DeviceId")] [string[]] $DeviceId, [Parameter(ParameterSetName = "Group", ValueFromPipeline)] [PSTypeName("ViewSonic.myViewBoard.GroupInfo")] [object[]] $Group, [Parameter(ParameterSetName = "GroupId")] [string[]] $GroupId, [Parameter()] [ValidateRange(1, [int]::MaxValue)] [int] $Count, [Parameter()] [ValidateRange(1, [int]::MaxValue)] [int] $Page ) process { $ResolvedId = @() $QueryKey = $null switch ($PSCmdlet.ParameterSetName) { "Group" { $QueryKey = "group_id" if ($null -ne $Group -and $null -ne $Group.id) { $ResolvedId += $Group.id } } "GroupId" { $QueryKey = "group_id" if ($PSBoundParameters.ContainsKey("GroupId")) { $ResolvedId += $GroupId } } "Device" { $QueryKey = "device_id" if ($null -ne $Device -and $null -ne $Device.id) { $ResolvedId += $Device.id } } "GroupDevice" { $QueryKey = "device_id" if ($null -ne $GroupDevice -and $null -ne $GroupDevice.id) { $ResolvedId += $GroupDevice.id } } "DeviceId" { $QueryKey = "device_id" if ($PSBoundParameters.ContainsKey("DeviceId")) { $ResolvedId += $DeviceId } } } $Parameters = @{ ResourceType = [MVBResourceType]::devices DevicesSubType = [MVBDevicesSubType]::statistics } if ($ResolvedId.Count -gt 0 -and -not [string]::IsNullOrWhiteSpace($QueryKey)) { $Parameters["QueryParameters"] = @{ $QueryKey = ($ResolvedId -join ",") } } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["Count"] = $Count } if ($PSBoundParameters.ContainsKey("Page")) { $Parameters["Page"] = $Page } return Get-Resource @Parameters } } |