From a823b4971e62742a576392c6fb3be3cfcdfbea21 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 21:12:53 -0400 Subject: [PATCH] Update with ShouldProcess --- ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 | 7 +++++-- ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 | 6 ++++-- ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 | 8 ++++++-- ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 | 7 +++++-- ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 401b85d..9925d30 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpgSettingsIdentifier { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [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.", @@ -33,7 +33,10 @@ function New-ZertoVpgSettingsIdentifier { } process { - Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { + Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + } + } end { diff --git a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index 45ffd5b..03a9677 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Start-ZertoCloneVpg { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of the VPG you wish to clone.", @@ -53,7 +53,9 @@ function Start-ZertoCloneVpg { $body['VmIdentifiers'] = $vmIdentifiers } Write-Verbose $body - Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" + if ($PSCmdlet.ShouldProcess("Clone Vpg")) { + Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" + } } end { diff --git a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 index 6e8ce11..51d1e38 100644 --- a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Start-ZertoFailoverTest { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of VPG to failover test", @@ -42,7 +42,11 @@ function Start-ZertoFailoverTest { } $body['VmIdentifiers'] = $vmIdentifiers } - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + if ($PSCmdlet.ShouldProcess("Starting Failover Test")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } + + } end { diff --git a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 index 892c167..72e09f4 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Stop-ZertoCloneVpg { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of the VPG to stop cloning", @@ -16,7 +16,10 @@ function Stop-ZertoCloneVpg { process { $uri = "{0}/{1}/CloneAbort" -f $baseUri, $vpgIdentifier - invoke-ZertoRestRequest -uri $uri -method "POST" + if ($PSCmdlet.ShouldProcess("Stopping VPG Clone Operation")) { + invoke-ZertoRestRequest -uri $uri -method "POST" + } + } end { diff --git a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 index 56f7d1b..c8c63c9 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Stop-ZertoFailoverTest { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name(s) of VPG(s) to stop testing.", @@ -26,7 +26,10 @@ function Stop-ZertoFailoverTest { foreach ($name in $vpgName) { $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier $uri = "{0}/{1}/FailoverTestStop" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + if ($PSCmdlet.ShouldProcess("Stopping Failover Test")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } + } }