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

Updated bool to switch and made function names singular nouns - Issue 326 and 509 #510

Merged
merged 18 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## 2019-11-06

### Changed [Get-RubrikVcd & Get-RubrikVApp Options function names]

* Renamed Get-RubrikVAppExportOptions to `Get-RubrikVAppExportOption` to use singular nouns
* Renamed Get-RubrikVAppRecoverOptions to `Get-RubrikVAppRecoverOption` to use singular nouns
* Renamed Get-RubrikVcdTemplateExportOptions to `Get-RubrikVcdTemplateExportOption` to use singular nouns
* Updated documentation and unit tests where required
* Addresses [Issue 509](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/509)

### Changed [parameter type from boolean to switch]

* Changed this for the following functions:
* `Export-RubrikVAPP`
* `New-RubrikBootstrap`
* `Restore-RubrikVAPP`
* Addresses [Issue 326](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/326)

## 2019-11-05

### Changed [Submit-Request]
Expand Down
6 changes: 3 additions & 3 deletions Rubrik/Private/Get-RubrikAPIData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ function Get-RubrikAPIData($endpoint) {
Success = '200'
}
}
'Get-RubrikVAppExportOptions' = @{
'Get-RubrikVAppExportOption' = @{
'1.0' = @{
Description = 'Retrieves export options for a vCD vApp'
URI = '/api/internal/vcd/vapp/snapshot/{id}/export/options'
Expand All @@ -1068,7 +1068,7 @@ function Get-RubrikAPIData($endpoint) {
Success = '200'
}
}
'Get-RubrikVAppRecoverOptions' = @{
'Get-RubrikVAppRecoverOption' = @{
'1.0' = @{
Description = 'Retrieves instant recovery options for a vCD vApp'
URI = '/api/internal/vcd/vapp/snapshot/{id}/instant_recover/options'
Expand All @@ -1080,7 +1080,7 @@ function Get-RubrikAPIData($endpoint) {
Success = '200'
}
}
'Get-RubrikVcdTemplateExportOptions' = @{
'Get-RubrikVcdTemplateExportOption' = @{
'1.0' = @{
Description = 'Retrieves export options for a vCD Template'
URI = '/api/v1/vcd/vapp/template/snapshot/{id}/export/options'
Expand Down
2 changes: 1 addition & 1 deletion Rubrik/Public/Export-RubrikVApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function Export-RubrikVApp
# Power on vApp after restoration.
[Parameter(ParameterSetName='Full',Mandatory = $true)]
[Parameter(ParameterSetName='Partial',Mandatory = $true)]
[Bool]$PowerOn,
[switch]$PowerOn,
# Rubrik server IP or FQDN
[Parameter(ParameterSetName='Full')]
[Parameter(ParameterSetName='Partial')]
Expand Down
2 changes: 1 addition & 1 deletion Rubrik/Public/Export-RubrikVCDTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Export-RubrikVCDTemplate
Write-Verbose -Message "Using $($name) for export"
}
if(!$orgvdcid) {
$options = Get-RubrikVcdTemplateExportOptions -id $id -catalogid $catalogid -name $name
$options = Get-RubrikVcdTemplateExportOption -id $id -catalogid $catalogid -name $name
$orgvdcid = $options.originalVdcExportOptions.orgVdcId
Write-Verbose -Message "Using Org VDC $($orgvdc) for export"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#requires -Version 3
function Get-RubrikVAppExportOptions
function Get-RubrikVAppExportOption
{
<#
.SYNOPSIS
Retrieves export for a vCD vApp known to a Rubrik cluster

.DESCRIPTION
The Get-RubrikVAppExportOptions cmdlet retrieves export options for a vCD vApp known to a Rubrik cluster
The Get-RubrikVAppExportOption cmdlet retrieves export options for a vCD vApp known to a Rubrik cluster

.NOTES
Written by Matt Elliott for community usage
Twitter: @NetworkBrouhaha
GitHub: shamsway

.LINK
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/Get-RubrikVAppExportOptions
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/Get-RubrikVAppExportOption

.EXAMPLE
$SnapshotID = (Get-RubrikVApp -Name 'vApp01' | Get-RubrikSnapshot -Latest).id
Get-RubrikVAppExportOptions -id $SnapshotID -ExportMode 'ExportToNewVapp'
Get-RubrikVAppExportOption -id $SnapshotID -ExportMode 'ExportToNewVapp'
This returns available export options for the specific snapshot.
#>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#requires -Version 3
function Get-RubrikVAppRecoverOptions
function Get-RubrikVAppRecoverOption
{
<#
.SYNOPSIS
Retrieves instant recovery options a vCD vApp known to a Rubrik cluster

.DESCRIPTION
The Get-RubrikVAppRecoverOptions cmdlet is used to retrieve instant recovery options for a vCD vApp known to a Rubrik cluster
The Get-RubrikVAppRecoverOption cmdlet is used to retrieve instant recovery options for a vCD vApp known to a Rubrik cluster

.NOTES
Written by Matt Elliott for community usage
Twitter: @NetworkBrouhaha
Github: shamsway

.LINK
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/Get-RubrikVAppRecoverOptions
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/Get-RubrikVAppRecoverOption

.EXAMPLE
$SnapshotID = (Get-RubrikVApp -Name 'vApp01' | Get-RubrikSnapshot -Latest).id
Get-RubrikVAppRecoverOptions -id $SnapshotID
Get-RubrikVAppRecoverOption -id $SnapshotID
This will return recovery options on the specific snapshot.
#>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#requires -Version 3
function Get-RubrikVCDTemplateExportOptions
function Get-RubrikVCDTemplateExportOption
{
<#
.SYNOPSIS
Retrieves export options for a vCD Template known to a Rubrik cluster

.DESCRIPTION
The Get-RubrikVCDTemplateExportOptions cmdlet retrieves export options for a vCD Template known to a Rubrik cluster
The Get-RubrikVCDTemplateExportOption cmdlet retrieves export options for a vCD Template known to a Rubrik cluster

.NOTES
Written by Matt Elliott for community usage
Twitter: @NetworkBrouhaha
GitHub: shamsway

.LINK
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/Get-RubrikVCDTemplateExportOptions
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/Get-RubrikVCDTemplateExportOption

.EXAMPLE
$SnapshotID = (Get-RubrikVApp -Name 'vAppTemplate01' | Get-RubrikSnapshot -Latest).id
Get-RubrikVCDTemplateExportOptions -id $SnapshotID -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567' -Name 'vAppTemplate01-export'
Get-RubrikVCDTemplateExportOption -id $SnapshotID -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567' -Name 'vAppTemplate01-export'
This will return export options details on the specific snapshot.
#>

Expand Down
4 changes: 2 additions & 2 deletions Rubrik/Public/New-RubrikBootStrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function New-RubrikBootStrap
[System.Object]
$nodeConfigs,
# Software Encryption
[bool]
$enableSoftwareEncryptionAtRest = $false,
[switch]
$enableSoftwareEncryptionAtRest,
# Cluster/Edge Name
[ValidateNotNullOrEmpty()]
[string]
Expand Down
12 changes: 6 additions & 6 deletions Rubrik/Public/Restore-RubrikVApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ function Restore-RubrikVApp

.EXAMPLE
$id = (Get-RubrikVApp -Name "vApp01" -PrimaryClusterID local | Get-RubrikSnapshot -Latest ).id
$recoveropts = Get-RubrikVAppRecoverOptions -Id $id
$recoveropts = Get-RubrikVAppRecoverOption -Id $id
$restorableVms = $recoveropts.restorableVms
$vm = @()
$vm += $restorableVms[0]
Restore-RubrikVApp -id $id -Partial $vm -PowerOn:$false
This retreives the latest snapshot from the given vApp 'vApp01' and performs a partial restore on the first VM in the vApp.
This is an advanced use case and the user is responsible for parsing the output from Get-RubrikVAppRecoverOptions.
Syntax of the object passed with the -Partial Parameter must match the format of the object returned from (Get-RubrikVAppRecoverOptions).restorableVms
This is an advanced use case and the user is responsible for parsing the output from Get-RubrikVAppRecoverOption.
Syntax of the object passed with the -Partial Parameter must match the format of the object returned from (Get-RubrikVAppRecoverOption).restorableVms
#>

[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')]
Expand Down Expand Up @@ -76,7 +76,7 @@ function Restore-RubrikVApp
# Power on vApp after restoration.
[Parameter(ParameterSetName='Full',Mandatory = $true)]
[Parameter(ParameterSetName='Partial',Mandatory = $true)]
[Bool]$PowerOn,
[switch]$PowerOn,
# Rubrik server IP or FQDN
[Parameter(ParameterSetName='Full')]
[Parameter(ParameterSetName='Partial')]
Expand Down Expand Up @@ -120,7 +120,7 @@ function Restore-RubrikVApp
}
else {
Write-Verbose -Message "Performing Full vApp Recovery"
$recoveropts = Get-RubrikVAppRecoverOptions -id $id
$recoveropts = Get-RubrikVAppRecoverOption -id $id
$resources.Body.vmsToRestore = $recoveropts.restorableVms
$resources.Body.shouldPowerOnVmsAfterRecovery = $PowerOn

Expand Down Expand Up @@ -150,7 +150,7 @@ function Restore-RubrikVApp
}

if($NetworkMapping) {
# Check RubrikVAppRecoverOptions to verify
# Check RubrikVAppRecoverOption to verify
$found = $false
Write-Verbose -Message "Validating $($NetworkMapping) network"
foreach($network in $recoveropts.availableVappNetworks) {
Expand Down
6 changes: 3 additions & 3 deletions Rubrik/Rubrik.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Rubrik.psm1'

# Version number of this module.
ModuleVersion = '4.0.513'
ModuleVersion = '4.0.0.514'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -97,9 +97,9 @@ FunctionsToExport = @('Connect-Rubrik', 'Disconnect-Rubrik', 'Export-RubrikDatab
'Get-RubrikOracleDB', 'Get-RubrikOrganization', 'Get-RubrikReport', 'Get-RubrikNetworkThrottle'
'Get-RubrikProxySetting', 'Get-RubrikReportData', 'Get-RubrikRequest', 'Get-RubrikSetting',
'Get-RubrikSLA', 'Get-RubrikSnapshot', 'Get-RubrikSNMPSetting', 'Get-RubrikSoftwareVersion',
'Get-RubrikSQLInstance', 'Get-RubrikSupportTunnel', 'Get-RubrikVAppExportOptions',
'Get-RubrikSQLInstance', 'Get-RubrikSupportTunnel', 'Get-RubrikVAppExportOption',
'Get-RubrikObject', 'Get-RubrikUserRole', 'Get-RubrikLoginBanner', 'Get-RubrikNotificationSetting',
'Get-RubrikVAppRecoverOptions', 'Get-RubrikVCDTemplateExportOptions', 'Get-RubrikUnmanagedObject',
'Get-RubrikVAppRecoverOption', 'Get-RubrikVCDTemplateExportOption', 'Get-RubrikUnmanagedObject',
'Get-RubrikUser', 'Get-RubrikVApp', 'Get-RubrikVAppSnapshot', 'Get-RubrikVCD',
'Get-RubrikVCenter', 'Get-RubrikVersion', 'Get-RubrikVM', 'Get-RubrikVMSnapshot',
'Get-RubrikVMwareDatastore', 'Get-RubrikVMwareHost', 'Get-RubrikVolumeGroup',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ foreach ( $privateFunctionFilePath in ( Get-ChildItem -Path './Rubrik/Private' |
. $privateFunctionFilePath
}

Describe -Name 'Public/Get-RubrikVAppExportOptions' -Tag 'Public', 'Get-RubrikVAppExportOptions' -Fixture {
Describe -Name 'Public/Get-RubrikVAppExportOption' -Tag 'Public', 'Get-RubrikVAppExportOption' -Fixture {
#region init
$global:rubrikConnection = @{
id = 'test-id'
Expand Down Expand Up @@ -74,7 +74,7 @@ Describe -Name 'Public/Get-RubrikVAppExportOptions' -Tag 'Public', 'Get-RubrikVA
}

It -Name 'Expected results returned' -Test {
$result = Get-RubrikVAppExportOptions -id '01234567-8910-1abc-d435-0abc1234d567' -ExportMode 'ExportToNewVapp'
$result = Get-RubrikVAppExportOption -id '01234567-8910-1abc-d435-0abc1234d567' -ExportMode 'ExportToNewVapp'
$result.allChildVmsWithDefaultNetworkConnections[0].name | Should -BeExactly 'vApp01'
$result.targetVappNetworks[0].name | Should -BeExactly 'network01'
}
Expand All @@ -85,11 +85,11 @@ Describe -Name 'Public/Get-RubrikVAppExportOptions' -Tag 'Public', 'Get-RubrikVA
}
Context -Name 'Parameter Validation' {
It -Name 'Parameter ID cannot be null' -Test {
{ Get-RubrikVAppExportOptions -id $null } |
{ Get-RubrikVAppExportOption -id $null } |
Should -Throw "Cannot validate argument on parameter 'id'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
}
It -Name 'Parameter ID cannot be empty' -Test {
{ Get-RubrikVAppExportOptions -id '' } |
{ Get-RubrikVAppExportOption -id '' } |
Should -Throw "Cannot validate argument on parameter 'id'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ foreach ( $privateFunctionFilePath in ( Get-ChildItem -Path './Rubrik/Private' |
. $privateFunctionFilePath
}

Describe -Name 'Public/Get-RubrikVAppRecoverOptions' -Tag 'Public', 'Get-RubrikVAppRecoverOptions' -Fixture {
Describe -Name 'Public/Get-RubrikVAppRecoverOption' -Tag 'Public', 'Get-RubrikVAppRecoverOption' -Fixture {
#region init
$global:rubrikConnection = @{
id = 'test-id'
Expand Down Expand Up @@ -67,7 +67,7 @@ Describe -Name 'Public/Get-RubrikVAppRecoverOptions' -Tag 'Public', 'Get-RubrikV
}

It -Name 'Expected results returned' -Test {
$result = Get-RubrikVAppRecoverOptions -id '01234567-8910-1abc-d435-0abc1234d567'
$result = Get-RubrikVAppRecoverOption -id '01234567-8910-1abc-d435-0abc1234d567'
$result.restorableVms[0].name | Should -BeExactly 'vApp01'
$result.availableVappNetworks[0].name | Should -BeExactly 'network01'
}
Expand All @@ -78,11 +78,11 @@ Describe -Name 'Public/Get-RubrikVAppRecoverOptions' -Tag 'Public', 'Get-RubrikV
}
Context -Name 'Parameter Validation' {
It -Name 'Parameter ID cannot be null' -Test {
{ Get-RubrikVAppRecoverOptions -id $null } |
{ Get-RubrikVAppRecoverOption -id $null } |
Should -Throw "Cannot validate argument on parameter 'id'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
}
It -Name 'Parameter ID cannot be empty' -Test {
{ Get-RubrikVAppRecoverOptions -id '' } |
{ Get-RubrikVAppRecoverOption -id '' } |
Should -Throw "Cannot validate argument on parameter 'id'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ foreach ( $privateFunctionFilePath in ( Get-ChildItem -Path './Rubrik/Private' |
. $privateFunctionFilePath
}

Describe -Name 'Public/Get-RubrikVcdTemplateExportOptions' -Tag 'Public', 'Get-RubrikVcdTemplateExportOptions' -Fixture {
Describe -Name 'Public/Get-RubrikVcdTemplateExportOption' -Tag 'Public', 'Get-RubrikVcdTemplateExportOption' -Fixture {
#region init
$global:rubrikConnection = @{
id = 'test-id'
Expand Down Expand Up @@ -46,7 +46,7 @@ Describe -Name 'Public/Get-RubrikVcdTemplateExportOptions' -Tag 'Public', 'Get-R
}

It -Name 'Expected results returned' -Test {
$result = Get-RubrikVcdTemplateExportOptions -id '01234567-8910-1abc-d435-0abc1234d567' -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567' -name 'Template-Export'
$result = Get-RubrikVcdTemplateExportOption -id '01234567-8910-1abc-d435-0abc1234d567' -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567' -name 'Template-Export'
$result.originalVdcExportOptions.orgVdcId | Should -BeExactly '01234567-8910-1abc-d435-0abc1234d567'
$result.defaultCatalogExportOptions.orgVdcId | Should -BeExactly '01234567-8910-1abc-d435-0abc1234d567'
}
Expand All @@ -73,7 +73,7 @@ Describe -Name 'Public/Get-RubrikVcdTemplateExportOptions' -Tag 'Public', 'Get-R
}

It -Name 'Expected results returned' -Test {
$result = Get-RubrikVcdTemplateExportOptions -id '01234567-8910-1abc-d435-0abc1234d567' -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567' -orgvdcid 'VcdOrgVdc:::665f23c6-1fc3-4d49-bb58-5841b0c20818' -name 'Template-Export'
$result = Get-RubrikVcdTemplateExportOption -id '01234567-8910-1abc-d435-0abc1234d567' -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567' -orgvdcid 'VcdOrgVdc:::665f23c6-1fc3-4d49-bb58-5841b0c20818' -name 'Template-Export'
$result.advancedExportOptions.orgVdcId | Should -BeExactly '01234567-8910-1abc-d435-0abc1234d567'
}

Expand Down Expand Up @@ -114,7 +114,7 @@ Describe -Name 'Public/Get-RubrikVcdTemplateExportOptions' -Tag 'Public', 'Get-R
}

It -Name 'Expected results returned' -Test {
$result = Get-RubrikVcdTemplateExportOptions -id '01234567-8910-1abc-d435-0abc1234d567' -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567'
$result = Get-RubrikVcdTemplateExportOption -id '01234567-8910-1abc-d435-0abc1234d567' -catalogid 'VcdCatalog:::01234567-8910-1abc-d435-0abc1234d567'
$result.originalVdcExportOptions.orgVdcId | Should -BeExactly '01234567-8910-1abc-d435-0abc1234d567'
$result.defaultCatalogExportOptions.orgVdcId | Should -BeExactly '01234567-8910-1abc-d435-0abc1234d567'
}
Expand All @@ -127,11 +127,11 @@ Describe -Name 'Public/Get-RubrikVcdTemplateExportOptions' -Tag 'Public', 'Get-R
}
Context -Name 'Parameter Validation' {
It -Name 'Parameter ID cannot be null' -Test {
{ Get-RubrikVcdTemplateExportOptions -id $null } |
{ Get-RubrikVcdTemplateExportOption -id $null } |
Should -Throw "Cannot validate argument on parameter 'id'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
}
It -Name 'Parameter ID cannot be empty' -Test {
{ Get-RubrikVcdTemplateExportOptions -id '' } |
{ Get-RubrikVcdTemplateExportOption -id '' } |
Should -Throw "Cannot validate argument on parameter 'id'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Restore-RubrikVApp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Describe -Name 'Public/Restore-RubrikVApp' -Tag 'Public', 'Restore-RubrikVApp' -
#endregion

Context -Name 'Test script logic' {
Mock -CommandName Get-RubrikVAppRecoverOptions -Verifiable -ModuleName 'Rubrik' -MockWith {
Mock -CommandName Get-RubrikVAppRecoverOption -Verifiable -ModuleName 'Rubrik' -MockWith {
return $recoveropts
}

Expand All @@ -112,7 +112,7 @@ Describe -Name 'Public/Restore-RubrikVApp' -Tag 'Public', 'Restore-RubrikVApp' -
}

Assert-VerifiableMock
Assert-MockCalled -CommandName Get-RubrikVAppRecoverOptions -ModuleName 'Rubrik' -Exactly 2
Assert-MockCalled -CommandName Get-RubrikVAppRecoverOption -ModuleName 'Rubrik' -Exactly 2
Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Exactly 3

}
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ try {
}
$version = (Invoke-WebRequest @WebRequestSplat) -split '\n' -match 'ModuleVersion' -replace "\s|'|ModuleVersion|="
$version = [version][string]$version
[String]$newVersion = "$($version.Major).$($version.Minor).$($manifest.version.revision+1)"
[String]$newVersion = "$($version.Major).$($version.Minor).$($version.Build).$($manifest.version.revision+1)"
Write-Output "New Version: $newVersion"
else {
$newVersion = $manifest.Version
Expand Down