Create Set-ZertoAlert function and tests

This commit is contained in:
Wes Carroll
2019-02-24 20:18:02 -05:00
parent 04dba27f0c
commit 89bb9704df
3 changed files with 66 additions and 2 deletions
+2 -2
View File
@@ -69,9 +69,9 @@ function Get-ZertoAlert {
[string]$entity,
[Parameter(
ParameterSetName = "filter",
HelpMessage = "Returns alerts that are dismissed"
HelpMessage = 'Returns alerts that are dismissed when set to $true an undismissed alerts when set to $false'
)]
[switch]$isDismissed
[bool]$isDismissed
)
begin {
+42
View File
@@ -0,0 +1,42 @@
function Set-ZertoAlert {
[cmdletbinding( SupportsShouldProcess = $true )]
param (
[Alias("identifier")]
[Parameter(
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Mandatory = $true,
HelpMessage = "Alert identifier(s) to be dismissed or undismissed."
)]
[string[]]$alertId,
[Parameter(
ParameterSetName = "dismiss",
Mandatory = $true,
HelpMessage = "Will dismiss the selected alert."
)]
[switch]$dismiss,
[Parameter(
ParameterSetName = "undismiss",
Mandatory = $true,
HelpMessage = "Will undismiss the selected alert."
)]
[switch]$undismiss
)
begin {
$baseUri = "alerts"
}
process {
foreach ($id in $alertId) {
$uri = "{0}/{1}/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName
if ($PSCmdlet.ShouldProcess($PSCmdlet.ParameterSetName + " alertId $id")) {
Invoke-ZertoRestRequest -uri $uri -method "POST" | Out-Null
}
}
}
end {
# Nothing to do.
}
}