Classes/Public/PrismVMStats.ps1

# VM statistics for a reporting period, with source and query context.
class PrismVMStats {
    [string]$VmExtId
    [string]$VmName
    [string]$PrismSession
    [datetimeoffset]$StartTime
    [datetimeoffset]$EndTime
    [int]$SamplingInterval
    [string]$StatType
    [string]$Select
    # Samples may contain different metrics, depending on availability and Select.
    [object[]]$Stats
    [object]$RawData

    PrismVMStats(
        [object]$data,
        [PrismVM]$vm,
        [string]$prismSession,
        [datetimeoffset]$startTime,
        [datetimeoffset]$endTime,
        [int]$samplingInterval,
        [string]$statType,
        [string]$select
    ) {
        if ($null -eq $vm -or [string]::IsNullOrWhiteSpace($vm.ExtId)) { throw 'A VM ExtId is required.' }
        if ($null -eq $data) { throw "The API response did not contain statistics for VM '$($vm.ExtId)'." }
        $this.VmExtId = $vm.ExtId
        $this.VmName = $vm.Name
        $this.PrismSession = $prismSession
        $this.StartTime = $startTime
        $this.EndTime = $endTime
        $this.SamplingInterval = $samplingInterval
        $this.StatType = $statType.ToUpperInvariant()
        $this.Select = $select
        $this.Stats = if ($null -eq $data.stats) { @() } else { @($data.stats) }
        $this.RawData = $data
    }
}