From 7abcc4492d55fe31721fe756d7438bc097207c4b Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Mon, 27 Jan 2020 08:54:01 -0500 Subject: [PATCH 1/5] added isPassThrough param to cmdlet --- Rubrik/Public/New-RubrikFileset.ps1 | 33 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Rubrik/Public/New-RubrikFileset.ps1 b/Rubrik/Public/New-RubrikFileset.ps1 index 96976963d..82f35e3ea 100644 --- a/Rubrik/Public/New-RubrikFileset.ps1 +++ b/Rubrik/Public/New-RubrikFileset.ps1 @@ -36,7 +36,10 @@ function New-RubrikFileset # HostID - Used for Windows or Linux Filesets [String]$HostID, # ShareID - used for NAS shares - [String]$ShareID, + [String]$ShareID, + # DirectArchive - used to specify if data should be directly sent to archive (bypassing Rubrik Cluster) + [Alias('isPassThrough')] + [Switch]$DirectArchive , # Rubrik server IP or FQDN [String]$Server = $global:RubrikConnection.server, # API version @@ -65,13 +68,27 @@ function New-RubrikFileset Process { - $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) - $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body - $result = Test-ReturnFormat -api $api -result $result -location $resources.Result - $result = Test-FilterObject -filter ($resources.Filter) -result $result - + if ($DirectArchive) { + $uri = New-URIString -server $server -endpoint ('/api/internal/fileset/bulk') + $body = @{ + templateId = $TemplateId + shareId = $ShareId + isPassthrough = $true + } + $body = ConvertTo-Json @($body) + Write-Verbose "Body is: $body" + $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body + $result = Test-ReturnFormat -api $api -result $result -location $resources.Result + $result = Test-FilterObject -filter ($resources.Filter) -result $result + } + else { + $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) + $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body + $result = Test-ReturnFormat -api $api -result $result -location $resources.Result + $result = Test-FilterObject -filter ($resources.Filter) -result $result + } return $result } # End of process From 56efe99568b0984167f2308ea9e40d80c79c57ee Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Mon, 27 Jan 2020 09:29:10 -0500 Subject: [PATCH 2/5] added parameter sets --- Rubrik/Private/Get-RubrikAPIData.ps1 | 2 +- Rubrik/Public/New-RubrikFileset.ps1 | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Rubrik/Private/Get-RubrikAPIData.ps1 b/Rubrik/Private/Get-RubrikAPIData.ps1 index 3b0593aca..c4759480d 100644 --- a/Rubrik/Private/Get-RubrikAPIData.ps1 +++ b/Rubrik/Private/Get-RubrikAPIData.ps1 @@ -1673,7 +1673,7 @@ function Get-RubrikAPIData($endpoint) { templateId = 'templateId' } Query = '' - Result = '' + Result = 'data' Filter = '' Success = '202' } diff --git a/Rubrik/Public/New-RubrikFileset.ps1 b/Rubrik/Public/New-RubrikFileset.ps1 index 82f35e3ea..cda36edc4 100644 --- a/Rubrik/Public/New-RubrikFileset.ps1 +++ b/Rubrik/Public/New-RubrikFileset.ps1 @@ -31,12 +31,16 @@ function New-RubrikFileset [CmdletBinding()] Param( #Fileset Template ID to use for the new fileset - [Parameter(Mandatory=$true)] + [Parameter(ParameterSetName='Host',Mandatory=$true)] + [Parameter(ParameterSetName='NAS',Mandatory=$true)] [String]$TemplateID, # HostID - Used for Windows or Linux Filesets + [Parameter(ParameterSetName='Host',Mandatory=$true)] [String]$HostID, # ShareID - used for NAS shares + [Parameter(ParameterSetName='NAS',Mandatory=$true)] [String]$ShareID, + [Parameter(ParameterSetName='NAS')] # DirectArchive - used to specify if data should be directly sent to archive (bypassing Rubrik Cluster) [Alias('isPassThrough')] [Switch]$DirectArchive , From 2e3cf4164bd4fb295082df494c8f83469872c492 Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Mon, 27 Jan 2020 09:30:23 -0500 Subject: [PATCH 3/5] updated examples --- Rubrik/Public/New-RubrikFileset.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Rubrik/Public/New-RubrikFileset.ps1 b/Rubrik/Public/New-RubrikFileset.ps1 index cda36edc4..56242d144 100644 --- a/Rubrik/Public/New-RubrikFileset.ps1 +++ b/Rubrik/Public/New-RubrikFileset.ps1 @@ -26,6 +26,11 @@ function New-RubrikFileset New-RubrikFileset -TemplateID (Get-RubrikFilesetTemplate -Name 'FOO').id -ShareID (Get-RubrikNASShare -name 'BAR').id Creates a new fileset for the BAR NAS, using the FOO template. + + .EXAMPLE + New-RubrikFileset -TemplateID (Get-RubrikFilesetTemplate -Name 'FOO').id -ShareID (Get-RubrikNASShare -name 'BAR').id -DirectArchive + + Creates a new fileset for the BAR NAS, using the FOO template. Enables the NAS Direct Archive functionality on the share. #> [CmdletBinding()] From f2bdd2e2300ae915f522c3e1e0d5bbba4f3a8950 Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Mon, 27 Jan 2020 09:32:43 -0500 Subject: [PATCH 4/5] update unit test --- Tests/New-RubrikFileset.Tests.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/New-RubrikFileset.Tests.ps1 b/Tests/New-RubrikFileset.Tests.ps1 index b7b854520..d27136afd 100644 --- a/Tests/New-RubrikFileset.Tests.ps1 +++ b/Tests/New-RubrikFileset.Tests.ps1 @@ -51,6 +51,10 @@ Describe -Name 'Public/New-RubrikFileset' -Tag 'Public', 'New-RubrikFileset' -Fi It -Name 'HostId missing' -Test { { New-RubrikFileset -TemplateID 'Foo' -HostId } | Should -Throw "Missing an argument for parameter 'HostId'." - } + } + It -Name 'Test ParameterSets' -Test { + { New-RubrikFileset -TemplateId 'Foo' -HostId 'bar1' -shareId 'bar2' } | + Should -Throw "Parameter set cannot be resolved using the specified named parameters." + } } } \ No newline at end of file From b59350600f30b947a4b658f217c3903e054ef3ca Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Mon, 27 Jan 2020 09:35:09 -0500 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b758960..dfc9df018 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Added QUEUED as a value in the status ValidateSet within Get-RubrikEvent and updated Unit Tests. Addresses [Issue 539](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/539) * Added Get-RubrikVMwareDatacenter and Get-RubrikVMwareCluster along with associated Unit Tests. Addresses [Issue 463](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/463) * Added Object TypeNames for VCD Servers and vCD vApps as specified in [Issue 462](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/462) +* Added DirectArchive switch parameter and associated code to New-RubrikFileSet allowing the isPassthrough attribute to be set to enable NAS Direct Archive. Addresses [Issue 358](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/358) Updated Unit tests for cmdlets to reflect new parametersets. ### Changed