Create Get-ZAAlert Function and Tests
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
#Requires -Modules Pester
|
||||||
|
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||||
|
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||||
|
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||||
|
$file = Get-ChildItem "$here\$sut"
|
||||||
|
$modulePath = $here -replace "Public", ""
|
||||||
|
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||||
|
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||||
|
Import-Module $moduleFile -Force
|
||||||
|
|
||||||
|
Describe $file.BaseName -Tag 'Unit' {
|
||||||
|
|
||||||
|
It "is valid Powershell (Has no script errors)" {
|
||||||
|
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||||
|
$errors = $null
|
||||||
|
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||||
|
$errors | Should -HaveCount 0
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
|
function Get-ZAAlert {
|
||||||
|
[cmdletbinding( DefaultParameterSetName = "zOrg")]
|
||||||
|
param(
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "The ZORG identifier by which to filter the alert list. If the ZORG identifier is omitted, a list of all the alerts is retrieved.",
|
||||||
|
ParameterSetName = "zOrg"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$zOrgIdentifier,
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "The maximum number of alerts to return.",
|
||||||
|
ParameterSetName = "zOrg"
|
||||||
|
)]
|
||||||
|
[ValidateRange(1, 1000000)]
|
||||||
|
[int]$limitTo,
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "The VPG Idnetifier",
|
||||||
|
ParameterSetName = "vpgId"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$vpgIdentifier
|
||||||
|
)
|
||||||
|
$uri = "monitoring/alerts"
|
||||||
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
|
zOrg {
|
||||||
|
if ( $PSBoundParameters.Keys.Count -gt 0 ) {
|
||||||
|
$filterString = Get-ZertoApiFilter -filterTable $PSBoundParameters
|
||||||
|
$uri = "{0}{1}" -f $uri, $filterString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vpgId {
|
||||||
|
$uri = "{0}/{1}" -f $uri, $vpgIdentifier
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Invoke-ZARestRequest -uri $uri
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user