.requirements/PSNeo4j/0.0.31/Public/Get-Neo4jHeader.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
function Get-Neo4jHeader { <# .SYNOPSIS Generate a header for the Neo4j API call .DESCRIPTION Generate a header for the Neo4j API call .EXAMPLE Get-Neo4jHeader -Credential $Credential .PARAMETER Credential Credential to use in the header. Note that the output is insecure (base64 based) We default to the value specified by Set-PSNeo4jConfiguration (Initially, neo4j:neo4j) .PARAMETER ContentType Content-Type for the header. Defaults to 'application/json' .PARAMETER Accept Accept for the header. Defaults to 'application/json; charset=UTF-8' .PARAMETER Streaming Transmits responses from HTTP API as JSON streams (better performance, lower memory overhead on the server) We default to the value specified by Set-PSNeo4jConfiguration ($true) .FUNCTIONALITY Neo4j #> [cmdletbinding()] param( [System.Management.Automation.PSCredential] [System.Management.Automation.Credential()] $Credential = $PSNeo4jConfig.Credential, [string]$ContentType = 'application/json', [string]$Accept = 'application/json; charset=UTF-8', [bool]$Streaming = $PSNeo4jConfig.Streaming ) # Thanks to Bloodhound authors, borrowed their code! $Headers = @{} if($Credential -ne [System.Management.Automation.PSCredential]::Empty) { $Base64UserPass = [System.Convert]::ToBase64String( [System.Text.Encoding]::UTF8.GetBytes( $('{0}:{1}' -f $Credential.UserName, $Credential.GetNetworkCredential().Password ) ) ) $Headers.add('Authorization', "Basic $Base64UserPass") } if($ContentType) { $Headers.Add('Content-Type', $ContentType) } if($Accept) { $Headers.Add('Accept', $Accept) } if($Streaming) { $Headers.Add('X-Stream', $True) } $Headers } |