nvramBBU.psm1


$NVRAMsDefaultProperties = ('name', 'index', 'node-name', 'sys-name');
$NVRAMDefaultProperties = ('name', 'index', 'node-name', 'fru-lifecycle-state', ' obj-severity', 'flash-num-bad-blocks', 'nvram-number-of-backup', 'nvram-fail-reason')
$NVRAMSupercapDefaultProperties = ('name', 'index', 'node-name', 'supercap-temp-level', 'supercap-temp', 'supercap-max-temp', 'supercap-short-circuit')
$BBUsDefaultProperties = ('index', 'name', 'model', 'sys-name', 'ups-input', 'fru-lifecycle-state', 'ups-battery-charge-in-percent')

.(commonLib) 

Function Get-XtremNVRAMs {
    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [parameter()]
        [Alias("Properties")]
        [array]$Property = $NVRAMsDefaultProperties,
        [parameter()]
        [Alias("Filters")]
        [array]$Filter,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest,
        [Parameter()]
        [switch]$Full = $false
    )
    initCommand
    $Route = '/types/nvrams'

    if ($Full) { $Property = '' }
    
    $result = NewXtremRequest -Method GET -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Properties $Property -ObjectSelection $ObjectSelection -Filters $Filter -ShowRest:$ShowRest.IsPresent -Multi -Full:$Full.IsPresent
    
    $result = formatOutPut $Property $result
        
    finalizeCommand
    return $result
}

Function Get-XtremNVRAM {
    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [Alias("Name", "Index")]
        [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)]
        [Argumentcompleter( { doComplete $args 'nvrams' name })]
        $NVRam,
        [Alias("Properties")]
        [array]$Property = $NVRAMDefaultProperties,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest
    )
    initCommand
    
    $Route = '/types/nvrams'

    $Route, $GetProperty = SetParametersForRequest $Route $NVRam

    $result = NewXtremRequest -Method GET -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -ObjectSelection $ObjectSelection -GetProperty $GetProperty -Properties $Property -ShowRest:$ShowRest.IsPresent
    
    $result = formatOutPut $Property $result
    
    finalizeCommand
    return $result
}

Function Get-XtremNVRAMSupercap {
    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [Alias("Name", "Index")]
        [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)]
        $NVRam,
        [Alias("Properties")]
        [array]$Property = $NVRAMSupercapDefaultProperties,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest
    )
    initCommand
        
    $Route = '/types/nvrams'
    $Route, $GetProperty = SetParametersForRequest $Route $NVRam

    $result = NewXtremRequest -Method GET -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -ObjectSelection $ObjectSelection -GetProperty $GetProperty -Properties $Property -ShowRest:$ShowRest.IsPresent
    
    $result = formatOutPut $Property $result
    
    finalizeCommand
    return $result
}

Function Get-XtremBBUs {
    <#
    .DESCRIPTION
    displays the list of BBUs.
 
    .PARAMETER Properties
    Array of properties requested from this call.
 
    .PARAMETER Filters
    Array of filters for this call.
 
    .PARAMETER ShowRest
    Return an object represents the REST operation including URI , Method and JSON
 
    .EXAMPLE
    Get-XtremBBUs
  #>

    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [parameter()]
        [Alias("Properties")]
        [string[]]$Property = $BBUsDefaultProperties,
        [parameter()]
        [Alias("Filters")]
        [string[]]$Filter,
        [Parameter()]
        [switch]$ShowRest,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$Full = $false
    )
    initCommand
    $Route = '/types/bbus'

    if ($Full) { $Property = '' }
    
    $result = NewXtremRequest -Method GET -Endpoint $Route -XtremClusterName $XtremClusterName -Session $Session -Properties $Property -Filters $Filter -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent -Multi -Full:$Full.IsPresent
    
    $result = formatOutPut $Property $result
    
    finalizeCommand
    return $result
}

Function Get-XtremBBU {
  <#
    .DESCRIPTION
    displays the details of the selected BBU.
 
    .PARAMETER BBUName
    SSD's name or index number
 
    .PARAMETER Properties
    Array of properties requested from this call.
 
    .PARAMETER ShowRest
    Return an object represents the REST operation including URI , Method and JSON
 
    .EXAMPLE
    Get-XtremBBU -BBUName bbu
  #>

    [cmdletbinding()]
    Param (
        [parameter()]
        $XtremClusterName =  (Get-XtremDefaultSession)._XtremClusterName,
        [Alias("Name", "Index")]
        [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)]
        [Argumentcompleter( { doComplete $args 'bbus' name })]
        $BBUName,
        [Parameter()]
        [Alias("Properties")]
        [string[]]$Property,
        [Parameter()]
        [object]$Session =  (Get-XtremDefaultSession),
        [Parameter()]
        [switch]$ShowRest
    )
    initCommand
    $Route = '/types/bbus'
    $Route, $GetProperty = SetParametersForRequest $Route $BBUName
    
    $result = NewXtremRequest -Method GET -Endpoint $Route -XtremClusterName $XtremClusterName -Session $Session -ObjectSelection $ObjectSelection -GetProperty $GetProperty -Properties $Property -ShowRest:$ShowRest.IsPresent
    
    $result = formatOutPut $Property $result
    
    finalizeCommand
    return $result
}

Export-ModuleMember *-*