Modules/support.psm1
# GET/api/v2/dd-systems/{SYSTEM-ID}/supports function Get-DDSupport { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $false, ParameterSetName = 'default')] [string] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "GET" } process { switch ($PsCmdlet.ParameterSetName) { default { $apiver = "api/v2" $uri = "dd-systems/$($SYSTEM_ID)/supports" } } $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 | Select-Object -ExcludeProperty links, link } } } } # PUT /api/v2/dd-systems/{SYSTEM-ID}/supports function Set-DDSupport { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $false, ParameterSetName = 'set_notification_status')] [string][ValidateSet('enabled', 'disabled')]$status, [Parameter(Mandatory = $true, ParameterSetName = 'set_notification_status')] [string][ValidateSet( "autosupport", "alerts", "all")]$notification, # [Parameter(Mandatory = $true, ParameterSetName = 'set_notification_status')] # [string]$destinationAddress, [Parameter(Mandatory = $true, ParameterSetName = 'set_notification')] [string][ValidateSet('email', 'esrs')]$notificationMethod, [Parameter(Mandatory = $true, ParameterSetName = 'del_gateway')] [Parameter(Mandatory = $true, ParameterSetName = 'set_gateway')] [string]$gateway, [Parameter(Mandatory = $true, ParameterSetName = 'set_gateway')] [string]$serial_number, [Parameter(Mandatory = $true, ParameterSetName = 'set_gateway')] [string]$device_key, [Parameter(Mandatory = $true, ParameterSetName = 'set_gateway')] [string]$device_type, [Parameter(Mandatory = $true, ParameterSetName = 'set_gateway')] [string]$transfer_type, [Parameter(Mandatory = $true, ParameterSetName = 'del_gateway')] [SWITCH]$del_gateway, $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "PUT" } process { $apiver = "api/v2" $uri = "dd-systems/$($SYSTEM_ID)/supports" $json = @{ operation = $PsCmdlet.ParameterSetName } switch ($PsCmdlet.ParameterSetName) { default { } 'set_notification_status' { $json.add('notificationStatus', @{}) if ($status) { $json.notificationStatus.Add("status", $status) } $json.notificationStatus.Add("notification", $notification) # if ($destinationAddress) { # $json.Add('destinationAddress', $destinationAddress) # } } 'set_notification' { $json.add('notificationMethod', $notificationMethod) } 'set_gateway' { $json.add('gatewayDetails', @{}) $json.gatewayDetails.Add("gateway", $gateway) $json.gatewayDetails.Add("serial_number", $serial_number) $json.gatewayDetails.Add("device_key", $device_key) $json.gatewayDetails.Add("device_type", $device_type) $json.gatewayDetails.Add("transfer_type", $transfer_type) } 'del_gateway' { $json.add('gatewayDetails', @{}) $json.gatewayDetails.Add("gateway", $gateway) } } $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 | Select-Object -ExcludeProperty link, links # , ddboost_options # -ExpandProperty ddboost_options } } } } <# { "description": "Support setting inputs", "required": [ "operation" ], "type": "object", "properties": { "operation": { "description": "An operation type for support modifications.", "enum": [ "set_gateway", "del_gateway", "set_notification", "set_notification_status" ], "type": "string" }, "notificationMethod": { "description": "Notification methods supported.", "enum": [ "esrs", "email" ], "type": "string" }, "gatewayDetails": { "description": "ESRS (Secure Remote Services) gateway settings", "type": "object", "properties": { "gateway": { "type": "string" }, "serial_number": { "type": "string" }, "device_key": { "type": "string" }, "device_type": { "type": "string" }, "transfer_type": { "type": "string" } } }, "notificationStatus": { "description": "Support notification status input", "type": "object", "properties": { "notification": { "description": "Notification type, autosupport (and am-email), or alerts, or all.", "enum": [ "autosupport", "alerts", "all" ], "type": "string" }, "status": { "description": "Notification enabled status", "enum": [ "disabled", "enabled" ], "type": "string" } } } } } #> <# { "description": "Support setting details", "required": [ "notificationMethod" ], "type": "object", "properties": { "notificationMethod": { "type": "string" }, "esrsGateways": { "type": "array", "minItems": 0, "items": { "description": "ESRS (Secure Remote Services) gateway settings", "type": "object", "properties": { "gateway": { "type": "string" }, "serial_number": { "type": "string" }, "device_key": { "type": "string" }, "device_type": { "type": "string" }, "transfer_type": { "type": "string" } } } }, "notificationStatus": { "type": "array", "minItems": 0, "items": { "description": "Support notification status", "type": "object", "properties": { "notification": { "description": "Notification type, autosupport (and am-email), or alerts, or all.", "enum": [ "autosupport", "alerts", "all" ], "type": "string" }, "status": { "description": "Notification enabled status", "enum": [ "disabled", "enabled" ], "type": "string" }, "destinationAddress": { "type": "string" } } } } } } #> |