Modules/settings.psm1
# /rest/v3.0/dd-systems/{SYSTEM-ID}/settings function Get-DDSettings { [CmdletBinding()] param ( [CmdletBinding()] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "GET" } process { switch ($PsCmdlet.ParameterSetName) { default { $apiver = "rest/v3.0" $uri = "dd-systems/$($SYSTEM_ID)/settings" } 'byID' { $apiver = "rest/v3.0" $uri = "dd-systems/$($SYSTEM_ID)/settings" } } $parameters = @{ uri = $uri apiver = $apiver Method = $METHOD body = $body RequestMethod = "REST" Verbose = $PSBoundParameters['Verbose'] -eq $true } try { $Response += Invoke-DDapirequest @Parameters } catch { Get-DDWebException -ExceptionMessage $_ break } write-verbose ($response | Out-String) } end { switch ($PsCmdlet.ParameterSetName) { default { $response[-1] | Select-Object -ExcludeProperty link } } } } # /rest/v3.0/dd-systems/{SYSTEM-ID}/settings function Set-DDSettings { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $true, ParameterSetName = 'set_timezone')] [string]$timezone, # [Parameter(Mandatory = $true, ParameterSetName = 'set_admin_email')] [string]$admin_email, # [Parameter(Mandatory = $true, ParameterSetName = 'set_location')] [string]$location, # [Parameter(Mandatory = $true, ParameterSetName = 'set_mail_server')] [string]$mail_server, [Parameter(Mandatory = $true, ParameterSetName = 'set_mail_server')] [int]$port, [Parameter(Mandatory = $true, ParameterSetName = 'set_mail_server')] [string]$username, [Parameter(Mandatory = $true, ParameterSetName = 'set_mail_server')] [securestring]$password, # [Parameter(Mandatory = $true, ParameterSetName = 'reset_timezone')] [switch]$reset_timezone, [Parameter(Mandatory = $true, ParameterSetName = 'reset_admin_info')] [switch]$reset_admin_info, [Parameter(Mandatory = $true, ParameterSetName = 'reset_admin_host')] [switch]$reset_admin_host, [Parameter(Mandatory = $true, ParameterSetName = 'reset_mail_server')] [switch]$reset_mail_server, [Parameter(Mandatory = $true, ParameterSetName = 'reset_location')] [switch]$reset_location, [Parameter(Mandatory = $true, ParameterSetName = 'reset_admin_email')] [switch]$reset_admin_email, [Parameter(Mandatory = $true, ParameterSetName = 'create')] [switch]$create, [Parameter(Mandatory = $true, ParameterSetName = 'clean_start')] [switch]$clean_start, [string] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "PUT" } process { $apiver = "rest/v3.0" $uri = "dd-systems/$($SYSTEM_ID)/settings" $json = @{ operation = $PsCmdlet.ParameterSetName } # creating body by pset switch ($PsCmdlet.ParameterSetName) { 'set_timezone' { $json.Add('timezone', $timezone) } 'set_admin_email' { $json.Add('admin_email', $admin_email) } 'set_location' { $json.Add('location', $location) } 'set_mail_server' { $json.Add('mail_server_info', @{}) $json.mail_server_info.Add('mail_server',$mail_server) $json.mail_server_info.Add('port',$port) $json.mail_server_info.Add('mail_server_auth_info',@{}) $json.mail_server_info.mail_server_auth_info.Add('username',$username) $json.mail_server_info.mail_server_auth_info.Add('password',[System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))) } } $json = $json | ConvertTo-Json Write-Verbose ($json | out-string) $parameters = @{ uri = $uri apiver = $apiver Method = $METHOD body = $json RequestMethod = "REST" Verbose = $PSBoundParameters['Verbose'] -eq $true } try { $Response += Invoke-DDapirequest @Parameters } catch { Get-DDWebException -ExceptionMessage $_ break } write-verbose ($response | Out-String) } end { switch ($PsCmdlet.ParameterSetName) { default { $response[-1] | Select-Object -ExcludeProperty link } } } } <# { "description": "Settings modification parameters", "required": [ "operation" ], "type": "object", "properties": { "operation": { "description": "An operation type must be included for a static image modify request", "enum": [ "set_timezone", "set_all", "set_admin_info", "set_location", "set_mail_server", "set_admin_email", "reset_all", "set_admin_host" ], "type": "string" }, "admin_email": { "type": "string" }, "admin_host": { "type": "string" }, "location": { "type": "string" }, "timezone": { "type": "string" }, "mail_server_info": { "type": "object", "properties": { "mail_server": { "type": "string" }, "port": { "format": "int32", "minimum": 0, "type": "integer" }, "mail_server_auth_info": { "type": "object", "properties": { "username": { "type": "string" }, "password": { "type": "string" } } } } } } }#> |