Update with ShouldProcess

This commit is contained in:
Wes Carroll
2019-04-04 21:12:53 -04:00
parent 3ae3a4be35
commit a823b4971e
5 changed files with 25 additions and 10 deletions
@@ -1,6 +1,6 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function New-ZertoVpgSettingsIdentifier { function New-ZertoVpgSettingsIdentifier {
[cmdletbinding()] [cmdletbinding( SupportsShouldProcess = $true )]
param( param(
[Parameter( [Parameter(
HelpMessage = "Identifier of the VPG to create a VPG settings identifier. If a vpgIdentifier is not provided, a new VPG settings object is created without any configured settings. This would be used for creating a new VPG from scratch.", HelpMessage = "Identifier of the VPG to create a VPG settings identifier. If a vpgIdentifier is not provided, a new VPG settings object is created without any configured settings. This would be used for creating a new VPG from scratch.",
@@ -33,9 +33,12 @@ function New-ZertoVpgSettingsIdentifier {
} }
process { process {
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
} }
}
end { end {
} }
@@ -1,6 +1,6 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Start-ZertoCloneVpg { function Start-ZertoCloneVpg {
[cmdletbinding()] [cmdletbinding( SupportsShouldProcess = $true )]
param( param(
[Parameter( [Parameter(
HelpMessage = "Name of the VPG you wish to clone.", HelpMessage = "Name of the VPG you wish to clone.",
@@ -53,8 +53,10 @@ function Start-ZertoCloneVpg {
$body['VmIdentifiers'] = $vmIdentifiers $body['VmIdentifiers'] = $vmIdentifiers
} }
Write-Verbose $body Write-Verbose $body
if ($PSCmdlet.ShouldProcess("Clone Vpg")) {
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST"
} }
}
end { end {
Write-Verbose "Call Submitted to $uri" Write-Verbose "Call Submitted to $uri"
@@ -1,6 +1,6 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Start-ZertoFailoverTest { function Start-ZertoFailoverTest {
[cmdletbinding()] [cmdletbinding( SupportsShouldProcess = $true )]
param( param(
[Parameter( [Parameter(
HelpMessage = "Name of VPG to failover test", HelpMessage = "Name of VPG to failover test",
@@ -42,9 +42,13 @@ function Start-ZertoFailoverTest {
} }
$body['VmIdentifiers'] = $vmIdentifiers $body['VmIdentifiers'] = $vmIdentifiers
} }
if ($PSCmdlet.ShouldProcess("Starting Failover Test")) {
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
} }
}
end { end {
#Nothing to do #Nothing to do
} }
@@ -1,6 +1,6 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Stop-ZertoCloneVpg { function Stop-ZertoCloneVpg {
[cmdletbinding()] [cmdletbinding( SupportsShouldProcess = $true )]
param( param(
[Parameter( [Parameter(
HelpMessage = "Name of the VPG to stop cloning", HelpMessage = "Name of the VPG to stop cloning",
@@ -16,9 +16,12 @@ function Stop-ZertoCloneVpg {
process { process {
$uri = "{0}/{1}/CloneAbort" -f $baseUri, $vpgIdentifier $uri = "{0}/{1}/CloneAbort" -f $baseUri, $vpgIdentifier
if ($PSCmdlet.ShouldProcess("Stopping VPG Clone Operation")) {
invoke-ZertoRestRequest -uri $uri -method "POST" invoke-ZertoRestRequest -uri $uri -method "POST"
} }
}
end { end {
# Nothing to do # Nothing to do
} }
@@ -1,6 +1,6 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Stop-ZertoFailoverTest { function Stop-ZertoFailoverTest {
[cmdletbinding()] [cmdletbinding( SupportsShouldProcess = $true )]
param( param(
[Parameter( [Parameter(
HelpMessage = "Name(s) of VPG(s) to stop testing.", HelpMessage = "Name(s) of VPG(s) to stop testing.",
@@ -26,8 +26,11 @@ function Stop-ZertoFailoverTest {
foreach ($name in $vpgName) { foreach ($name in $vpgName) {
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
$uri = "{0}/{1}/FailoverTestStop" -f $baseUri, $vpgId $uri = "{0}/{1}/FailoverTestStop" -f $baseUri, $vpgId
if ($PSCmdlet.ShouldProcess("Stopping Failover Test")) {
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
} }
}
} }
end { end {