VConnectAppSettings.psm1

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
function Get-VConnectAppSetting {
    param (
          [Parameter(Mandatory=$true, Position= 0)]
          $endpointName,
          [Parameter(Mandatory=$true, Position= 1)]
          $group,
          [Parameter(Mandatory=$false, Position= 2)]
          $key
    )
    if($key -eq $null ) {
        return Invoke-RestApiRequest -endpointName $endpointName -relativeUrl "admin/config/GetAppSettings?groups=$group" -method 'GET'
    }
    return Invoke-RestApiRequest -endpointName $endpointName -relativeUrl "admin/config/GetAppSetting?group=$group&key=$key" -method 'GET'
}

function Get-VConnectAppSettingGroups {
    param (
          [Parameter(Mandatory=$true, Position= 0)]
          $endpointName
    )
    return Invoke-RestApiRequest -endpointName $endpointName -relativeUrl "admin/config/ListAppSettingGroups" -method 'GET'
}

function Set-VConnectAppSetting {
    param (
          $endpointName,
          $group,
          $key,
          $value,
          [bool]$isEncrypted
    )
    $data = @{
                Key = $key
                Group = $group
                Value = $value
                IsEncrypted = $isEncrypted
    }
    $dataJson = $data | ConvertTo-Json
    return Invoke-RestApiRequest -endpointName $endpointName -relativeUrl 'admin/config/AddOrUpdateAppSetting' -method 'POST' -jsonBody $dataJson
}