Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft PR - Issue 352 - Converting booleans to swich #473

Merged
merged 28 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3da1014
Bool to Switch Get-RubrikOrganization and tests
mwpreston Oct 17, 2019
e4480fb
Bool - Switch Export-RubrikVM
mwpreston Oct 17, 2019
14de49e
doc update for Export-RubrikVM
mwpreston Oct 17, 2019
e94d614
Bool - Switch Get-RubrikEvent
mwpreston Oct 17, 2019
6189708
Bool-switch new-rubrikhost
mwpreston Oct 17, 2019
9ec584c
bool-switch New-RubrikMount and Tests
mwpreston Oct 17, 2019
8916b2f
bool-switch Set-RubrikMount and tests
mwpreston Oct 18, 2019
cd190cb
bool-switch Set-RubrikNutanixVM
mwpreston Oct 18, 2019
c6323fe
bool-switch Set-RubrikSupportTunnel and tests
mwpreston Oct 18, 2019
15966f1
bool-switch Set-RubrikVM and tests
mwpreston Oct 18, 2019
3009068
changelog and inline examples
mwpreston Oct 18, 2019
453e368
Merge branch 'master' into mwpreston-352
mwpreston Oct 18, 2019
fe35704
Added tests for new switch parameter
jaapbrasser Oct 21, 2019
498b8a8
Added switch tests for support tunnel
jaapbrasser Oct 21, 2019
c58edf8
Removed additional test
jaapbrasser Oct 21, 2019
8ce04cb
Added exactly and switch tests
jaapbrasser Oct 21, 2019
cec5383
Added linebreak
jaapbrasser Oct 21, 2019
91b1509
Added switch validation tests
jaapbrasser Oct 21, 2019
5eb95c0
Updated exactly
jaapbrasser Oct 21, 2019
b675c46
Added switch unit tests
jaapbrasser Oct 21, 2019
e0b9959
Fixed exactly statement
jaapbrasser Oct 21, 2019
76a9bb0
Added -isGlobal switch tests
jaapbrasser Oct 21, 2019
1f2aaa2
Updated exactly statements
jaapbrasser Oct 21, 2019
833bd00
Added switch param unit tests and fixed exactly
jaapbrasser Oct 21, 2019
9a4b721
Added new switch param context block
jaapbrasser Oct 21, 2019
1e0aad8
Added additional switch unit tests
jaapbrasser Oct 21, 2019
596e86c
Updated exactly
jaapbrasser Oct 21, 2019
590ef48
Updated psd1 for Set-RubrikUser
jaapbrasser Oct 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## 2019-10-18

### Changed [ Various cmdlets updated to remove boolean parameters and change to Switch]

* Migrated boolean parameters to switch parameters in order to provide a more consistent approach accross all cmdlets.
* **Note: This has the possibility of providing breaking changes as the syntax of calling the parameters like '-Parameter $true' will no longer be supported.**
* For Example: Export-RubrikVM -PowerOn $False will continue to run, however the $False gets assigned to the VM Name. Get-RubrikOrganization -isGlobal $true will now fail. Will need to ensure these are addressed in the release notes.
* Cmdlets affected are `Export-RubrikVM`, `Get-RubrikEvent`, `Get-RubrikOrganization`, `New-RubrikHost`, `New-RubrikMount`, `Set-RubrikMount`, `Set-RubrikNutanixVM`, `Set-RubrikSupportTunnel` and `Set-RubrikVM`
* Addresses [Issue 352](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/352)

## 2019-10-17

### Changed [Added Nutanix/Hyper-V support to New-RubrikSnapshot]
Expand Down
20 changes: 14 additions & 6 deletions Rubrik/Public/Export-RubrikVM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ function Export-RubrikVM
# Name of the exported VM
[String]$VMName,
# Whether the network should be disabled upon restoration. This should be set true to avoid ip conflict if source VM still exists.
[Bool]$DisableNetwork,
[Switch]$DisableNetwork,
# Whether to remove network interfaces from the restored virtual machine. Default is false.
[Bool]$RemoveNetworkDevices,
[Switch]$RemoveNetworkDevices,
# Whether to assign MAC addresses from source virtual machine to exported virtual machine. Default is false.
[Bool]$KeepMACAddresses,
[Switch]$KeepMACAddresses,
# Whether the newly restored virtual machine is unregistered from vCenter. Default is false.
[Bool]$UnregisterVM,
[Switch]$UnregisterVM,
# Whether the VM should be powered on after restoration. Default is true.
[Bool]$PowerOn,
[Switch]$PowerOn,
# Whether to recover vSphere tags
[Alias('shouldRecoverTags')]
[Bool]$RecoverTags,
[Switch]$RecoverTags,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -79,6 +79,14 @@ function Export-RubrikVM

Process {

# If the switch parameter was not explicitly specified remove from body params
if(-not $PSBoundParameters.ContainsKey('DisableNetwork')) { $Resources.Body.Remove('disableNetwork') }
if(-not $PSBoundParameters.ContainsKey('RemoveNetworkDevices')) { $Resources.Body.Remove('removeNetworkDevices') }
if(-not $PSBoundParameters.ContainsKey('KeepMACAddresses')) { $Resources.Body.Remove('keepMacAddresses') }
if(-not $PSBoundParameters.ContainsKey('UnregisterVM')) { $Resources.Body.Remove('unregisterVm') }
if(-not $PSBoundParameters.ContainsKey('PowerOn')) { $Resources.Body.Remove('powerOn') }
if(-not $PSBoundParameters.ContainsKey('RecoverTags')) { $Resources.Body.Remove('shouldRecoverTags') }

$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
12 changes: 8 additions & 4 deletions Rubrik/Public/Get-RubrikEvent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ function Get-RubrikEvent
[Alias('object_type')]
[parameter()]
[string]$ObjectType,
# A Boolean value that determines whether to show only on the most recent event in the series. When 'true' only the most recent event in the series are shown. When 'false' all events in the series are shown. The default value is 'true'.
# A switch value that determines whether to show only on the most recent event in the series. When 'true' only the most recent event in the series are shown. When 'false' all events in the series are shown. The default value is 'true'.
[Alias('show_only_latest')]
[parameter()]
[bool]$ShowOnlyLatest,
# A Boolean value that determines whether to filter only on the most recent event in the series. When 'true' only the most recent event in the series are filtered. When 'false' all events in the series are filtered. The default value is 'true'.
[Switch]$ShowOnlyLatest,
# A Switch value that determines whether to filter only on the most recent event in the series. When 'true' only the most recent event in the series are filtered. When 'false' all events in the series are filtered. The default value is 'true'.
[Alias('filter_only_on_latest')]
[parameter()]
[bool]$FilterOnlyOnLatest,
[Switch]$FilterOnlyOnLatest,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -112,6 +112,10 @@ function Get-RubrikEvent

Process {

# If the switch parameter was not explicitly specified remove from query params
if(-not $PSBoundParameters.ContainsKey('ShowOnlyLatest')) { $Resources.Query.Remove('show_only_latest') }
if(-not $PSBoundParameters.ContainsKey('FilterOnlyOnLatest')) { $Resources.Query.Remove('filter_only_on_latest') }

$uri = New-URIString -server $Server -endpoint ($resources.URI)
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
13 changes: 10 additions & 3 deletions Rubrik/Public/Get-RubrikOrganization.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function Get-RubrikOrganization

.EXAMPLE
Get-RubrikOrganization

Returns a complete list of all Rubrik organizations.

.EXAMPLE
Get-RubrikOrganization -isGlobal:$false
Returns a list of non global of all Rubrik organizations.
#>

[CmdletBinding()]
Expand All @@ -31,7 +34,7 @@ function Get-RubrikOrganization
[String]$name,
# Filter results on if the org is global or not
[Alias('is_global')]
[bool]$isGlobal,
[Switch]$isGlobal,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -59,7 +62,11 @@ function Get-RubrikOrganization
}

Process {

# If the switch parameter was not explicitly specified remove from query params
if(-not $PSBoundParameters.ContainsKey('isGlobal')) {
$Resources.Query.Remove('is_global')
}

$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
7 changes: 4 additions & 3 deletions Rubrik/Public/New-RubrikHost.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function New-RubrikHost
This will register a host that resolves to the name "Server1.example.com"

.EXAMPLE
New-RubrikHost -Name 'NAS.example.com' -HasAgent $false
New-RubrikHost -Name 'NAS.example.com' -HasAgent:$false
This will register a host that resolves to the name "NAS.example.com" without using the Rubrik Backup Service
In this case, the example host is a NAS share.
#>
Expand All @@ -33,7 +33,7 @@ function New-RubrikHost
[Alias('Hostname')]
[String]$Name,
# Set to $false to register a host that will be accessed through network shares
[Bool]$HasAgent,
[Switch]$HasAgent,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -61,7 +61,8 @@ function New-RubrikHost
}

Process {

# If the switch parameter was not explicitly specified remove from query params
if(-not $PSBoundParameters.ContainsKey('HasAgent')) { $Resources.Body.Remove('hasAgent') }
$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
12 changes: 8 additions & 4 deletions Rubrik/Public/New-RubrikMount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ function New-RubrikMount
# Name of the data store to use/create on the host
[String]$DatastoreName,
# Whether the network should be disabled on mount.This should be set true to avoid ip conflict in case of static IPs.
[Bool]$DisableNetwork,
[Switch]$DisableNetwork,
# Whether the network devices should be removed on mount.
[Bool]$RemoveNetworkDevices,
[Switch]$RemoveNetworkDevices,
# Whether the VM should be powered on after mount.
[Bool]$PowerOn,
[Switch]$PowerOn,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -79,7 +79,11 @@ function New-RubrikMount
}

Process {

# If the switch parameter was not explicitly specified remove from body params
if(-not $PSBoundParameters.ContainsKey('DisableNetwork')) { $Resources.Body.Remove('disableNetwork') }
if(-not $PSBoundParameters.ContainsKey('RemoveNetworkDevices')) { $Resources.Body.Remove('removeNetworkDevices') }
if(-not $PSBoundParameters.ContainsKey('PowerOn')) { $Resources.Body.Remove('powerOn') }

$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
6 changes: 3 additions & 3 deletions Rubrik/Public/Set-RubrikMount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Set-RubrikMount
http://rubrikinc.github.io/rubrik-sdk-for-powershell/reference/Set-RubrikMount.html

.EXAMPLE
Get-RubrikMount -id '11111111-2222-3333-4444-555555555555' | Set-RubrikMount -PowerOn:$true
Get-RubrikMount -id '11111111-2222-3333-4444-555555555555' | Set-RubrikMount -PowerOn
This will send a power on request to "Server1"

.EXAMPLE
Expand All @@ -32,7 +32,7 @@ function Set-RubrikMount
[String]$id,
# Configuration for the change power status request
[Alias('powerStatus')]
[Bool]$PowerOn,
[Switch]$PowerOn,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -60,7 +60,7 @@ function Set-RubrikMount
}

Process {

if(-not $PSBoundParameters.ContainsKey('PowerOn')) { $Resources.Body.Remove('powerStatus') }
$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
7 changes: 6 additions & 1 deletion Rubrik/Public/Set-RubrikNutanixVM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function Set-RubrikNutanixVM
Get-RubrikNutanixVM 'Server1' | Set-RubrikNutanixVM -PauseBackups
This will pause backups on any virtual machine named "Server1"

.EXAMPLE
Get-RubrikNutanixVM 'Server1' | Set-RubrikNutanixVM -PauseBackups:$false
This will unpause backups on any virtual machine named "Server1"

.EXAMPLE
Get-RubrikNutanixVM -SLA Platinum | Set-RubrikNutanixVM -SnapConsistency 'CRASH_CONSISTENT' -MaxNestedSnapshots 2 -UseArrayIntegration
This will find all virtual machines in the Platinum SLA Domain and set their snapshot consistency to crash consistent (no application quiescence)
Expand All @@ -38,7 +42,7 @@ function Set-RubrikNutanixVM
[String]$SnapConsistency,
# Whether to pause or resume backups/archival for this VM.
[Alias('isPaused')]
[Bool]$PauseBackups,
[Switch]$PauseBackups,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -74,6 +78,7 @@ function Set-RubrikNutanixVM

Process {

if(-not $PSBoundParameters.ContainsKey('PauseBackups')) { $Resources.Body.Remove('isPaused') }

$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
Expand Down
12 changes: 6 additions & 6 deletions Rubrik/Public/Set-RubrikSupportTunnel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ function Set-RubrikSupportTunnel
http://rubrikinc.github.io/rubrik-sdk-for-powershell/

.EXAMPLE
Set-RubrikSupportTunnel -EnableTunnel $false
Set-RubrikSupportTunnel -EnableTunnel:$false
This will disable the Support Tunnel for the Rubrik cluster

.EXAMPLE
Set-RubrikSupportTunnel -EnableTunnel $true
Set-RubrikSupportTunnel -EnableTunnel
This will enable the Support Tunnel for the Rubrik cluster and set the inactivity timeout to infinite (no timeout)

.EXAMPLE
Set-RubrikSupportTunnel -EnableTunnel $true -Timeout 100
Set-RubrikSupportTunnel -EnableTunnel -Timeout 100
This will enable the Support Tunnel for the Rubrik cluster and set the inactivity timeout to 100 seconds
#>

[CmdletBinding()]
Param(
# Status of the Support Tunnel. Choose $true to enable or $false to disable.
# Status of the Support Tunnel. Choose to enable or -EnableTunnel:$false to disable.
[Parameter(Mandatory = $true)]
[Alias('isTunnelEnabled')]
[Bool]$EnableTunnel,
[Switch]$EnableTunnel,
# Tunnel inactivity timeout in seconds. Only valid when setting $EnableTunnel to $true.
[Alias('inactivityTimeoutInSeconds')]
[int]$Timeout,
Expand Down Expand Up @@ -66,7 +66,7 @@ function Set-RubrikSupportTunnel
}

Process {

if(-not $PSBoundParameters.ContainsKey('EnableTunnel')) { $Resources.Body.Remove('isTunnelEnabled') }
$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
11 changes: 8 additions & 3 deletions Rubrik/Public/Set-RubrikVM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function Set-RubrikVM
Get-RubrikVM 'Server1' | Set-RubrikVM -PauseBackups
This will pause backups on any virtual machine named "Server1"

.EXAMPLE
Get-RubrikVM 'Server1' | Set-RubrikVM -PauseBackups:$false
This will unpause backups on any virtual machine named "Server1"

.EXAMPLE
Get-RubrikVM -SLA Platinum | Set-RubrikVM -SnapConsistency 'CRASH_CONSISTENT' -MaxNestedSnapshots 2 -UseArrayIntegration
This will find all virtual machines in the Platinum SLA Domain and set their snapshot consistency to crash consistent (no application quiescence)
Expand All @@ -44,10 +48,10 @@ function Set-RubrikVM
[int]$MaxNestedSnapshots,
# Whether to pause or resume backups/archival for this VM.
[Alias('isVmPaused')]
[Bool]$PauseBackups,
[Switch]$PauseBackups,
# User setting to dictate whether to use storage array snaphots for ingest. This setting only makes sense for VMs where array based ingest is possible.
[Alias('isArrayIntegrationEnabled')]
[Bool]$UseArrayIntegration,
[Switch]$UseArrayIntegration,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -82,7 +86,8 @@ function Set-RubrikVM
$SnapConsistency = $SnapConsistency -replace 'AUTOMATIC', 'UNKNOWN'
}
#endregion

if(-not $PSBoundParameters.ContainsKey('PauseBackups')) { $Resources.Body.Remove('isVmPaused') }
if(-not $PSBoundParameters.ContainsKey('UseArrayIntegration')) { $Resources.Body.Remove('isArrayIntegrationEnabled') }
$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
Expand Down
Loading