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

Bug fix 2020 04 #114

Merged
merged 8 commits into from
Apr 6, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Various:
Added pipline support
Added Architecture
Added LogOn
Nillth committed Apr 3, 2020
commit 50d957d218169a4c11b62be5509b92afadf713d3
68 changes: 55 additions & 13 deletions resources/dataconnection.ps1
Original file line number Diff line number Diff line change
@@ -21,43 +21,85 @@ function New-QlikDataConnection {
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "password", Justification = "Deprecation warning")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingUserNameAndPassWordParams", "", Justification = "Deprecation warning")]
param (
[parameter(Position = 0)]
param
(
[Parameter(ValueFromPipelineByPropertyName = $true,
Position = 0)]
[string]$name,
[parameter(Position = 1)]
[Parameter(ValueFromPipelineByPropertyName = $true,
Position = 1)]
[string]$connectionstring,
[parameter(Position = 2)]
[Parameter(ValueFromPipelineByPropertyName = $true,
Position = 2)]
[string]$type,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string[]]$customProperties,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string[]]$tags,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$username,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$password,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$architecture,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[string]$logOn,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[PSCredential]$Credential,
[Parameter(ValueFromPipelineByPropertyName = $true)]
[object]$owner
)

PROCESS {
if ( $username -Or $password ) {
if ($username -Or $password) {
Write-Warning "Use of username/password parameters is deprecated, please use Credential instead."
}
if ( $Credential ) {
if ($Credential) {
$username = $Credential.GetNetworkCredential().Username
$password = $Credential.GetNetworkCredential().Password
}
if ($password.Trim().Length -gt 0) {
if ($password.IndexOf("%2") -eq 10) {
$password = $password.Substring(12, $password.Length - 14)
}
}
else {
$Pass = ""
}
if ($username.Trim().Length -eq 0) {
$username = ""
}

switch ($architecture) {
{ ($_ -eq "0") -or ($_ -eq "Undefined") }{ $architecture = 0 }
{ ($_ -eq "1") -or ($_ -eq "x86") }{ $architecture = 1 }
{ ($_ -eq "2") -or ($_ -eq "x64") }{ $architecture = 2 }
default{ $architecture = 0 }
}

switch ($logOn) {
{ ($_ -eq "0") -or ($_ -eq "LOG_ON_SERVICE_USER") }{ $logOn = 0 }
{ ($_ -eq "1") -or ($_ -eq "LOG_ON_CURRENT_USER") }{ $logOn = 1 }
default{ $logOn = 0 }
}

$qdc = @{
name = $name;
connectionstring = $connectionstring;
type = $type
LogOn = $logOn
Architecture = $architecture
customProperties = @();
tags = @();
engineObjectId = [Guid]::NewGuid();
username = $username;
password = $password;
name = $name;
connectionstring = $connectionstring;
type = $type
}

if ($PSBoundParameters.ContainsKey("customProperties")) { $qdc.customProperties = @(GetCustomProperties $customProperties) }
if ($PSBoundParameters.ContainsKey("tags")) { $qdc.tags = @(GetTags $tags) }
if ($PSBoundParameters.ContainsKey("tags")) { $qdc.tags = GetTags $tags }
if ($PSBoundParameters.ContainsKey("owner")) { $qdc.owner = GetUser $owner }

$json = $qdc | ConvertTo-Json -Compress -Depth 10

return Invoke-QlikPost "/qrs/dataconnection" $json