resources/object.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function Get-QlikObject {
    [CmdletBinding(DefaultParameterSetName = "Multi")]
    param (
        [parameter(ParameterSetName = "Single", Mandatory = $false, Position = 0)]
        [string]$id,
        [parameter(ParameterSetName = "Multi", Mandatory = $false)]
        [string]$filter,
        [parameter(ParameterSetName = "Multi", Mandatory = $false)]
        [switch]$full,
        [switch]$raw
    )

    PROCESS {
        $path = "/qrs/app/object"
        If ($id) { $path += "/$id" }
        If ($full) { $path += "/full" }
        If ($raw) { $rawOutput = $true }
        return Invoke-QlikGet $path $filter
    }
}

function Publish-QlikObject {
    [CmdletBinding()]
    param (
        [parameter(Mandatory = $true, Position = 0, ValueFromPipelinebyPropertyName = $True)]
        [string]$id
    )

    PROCESS {
        $path = "/qrs/app/object/$id/publish"

        return Invoke-QlikPut $path
    }
}

function Remove-QlikObject {
    [CmdletBinding()]
    param (
        [parameter(Mandatory = $true, Position = 0, ValueFromPipelinebyPropertyName = $true)]
        [string]$id
    )

    PROCESS {
        return Invoke-QlikDelete "/qrs/app/object/$id"
    }
}

function Unpublish-QlikObject {
    [CmdletBinding()]
    param (
        [parameter(Mandatory = $true, Position = 0, ValueFromPipelinebyPropertyName = $True)]
        [string]$id
    )

    PROCESS {
        $path = "/qrs/app/object/$id/unpublish"

        return Invoke-QlikPut $path
    }
}

function Update-QlikObject {
    [CmdletBinding()]
    param (
        [parameter(Mandatory = $true, ValueFromPipelinebyPropertyName = $True, Position = 0)]
        [string]$id,

        [string]$name,
        [object]$owner,
        [bool]$approved
    )

    PROCESS {
        $obj = Get-QlikObject $id -raw
        If ( $name ) {
            $obj.name = $name
        }
        If ($psBoundParameters.ContainsKey("approved")) { $obj.approved = $approved }

        If ($PSBoundParameters.ContainsKey("owner")) { $obj.owner = GetUser $owner }

        $json = $obj | ConvertTo-Json -Compress -Depth 10
        return Invoke-QlikPut "/qrs/app/object/$id" $json
    }
}