Skip to content

Commit

Permalink
Merge pull request #569 from rubrikinc/melliott-568
Browse files Browse the repository at this point in the history
Fix malformed request body in New-RubrikBootstrap
  • Loading branch information
jaapbrasser authored Feb 22, 2020
2 parents 2911df7 + 8df5dd5 commit bc27b91
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* **Fixed** for any bug fixes.
* **Security** in case of vulnerabilities.

## [Unreleased] - 2019-02-21

### Fixed
* Updated New-RubrikBootstrap to address malformed request body and URI. This addresses issue [568](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/568)

## [Unreleased] - 2019-12-19

### Changed
Expand Down
28 changes: 26 additions & 2 deletions Rubrik/Public/New-RubrikBootStrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function New-RubrikBootStrap
Param(
# ID of the Rubrik cluster or me for self
[ValidateNotNullOrEmpty()]
[String] $id = 'me',
[String] $id,
# Rubrik server IP or FQDN
[ValidateNotNullOrEmpty()]
[String] $Server,
Expand Down Expand Up @@ -152,10 +152,34 @@ function New-RubrikBootStrap
}

Process {
#region oneoff
$id = "me"

# Construct Body based on parameters
$resources.Body.adminUserInfo = $adminUserInfo
$resources.Body.dnsNameservers = $dnsNameservers
if($dnsSearchDomains.Length -ne 0) {
$resources.Body.dnsSearchDomains = $dnsSearchDomains
} else {
$resources.Body.Remove('dnsSearchDomains')
}

if($enableSoftwareEncryptionAtRest) {
$resources.Body.enableSoftwareEncryptionAtRest = $true
} else {
$resources.Body.enableSoftwareEncryptionAtRest = $false
}
$resources.Body.name = $name
$resources.Body.nodeConfigs = $nodeConfigs
$resources.Body.ntpServerConfigs = $ntpServerConfigs

$body = ConvertTo-Json -InputObject $resources.Body -Depth 4
Write-Verbose -Message "Bootstrap REST Request Body `n$($body)"
#endregion

$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)
#$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
$result = Submit-Request -uri $uri -Header @{"content-type"="application/json"} -method $($resources.Method) -body $body
$result = Test-ReturnFormat -api $api -result $result -location $resources.Result
$result = Test-FilterObject -filter ($resources.Filter) -result $result
Expand Down

0 comments on commit bc27b91

Please sign in to comment.