Modules/cloud.psm1
#get rest/v1.0/dd-systems/{SYSTEM-ID}/cloud-units function Get-DDCloudUnits { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $true, ParameterSetName = 'byID')] [string]$id, [Parameter(Mandatory = $false, ParameterSetName = 'byID')] [Parameter(Mandatory = $false, ParameterSetName = 'default')] [string] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "GET" } process { switch ($PsCmdlet.ParameterSetName) { default { $apiver = "rest/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/cloud-units" } 'byID' { $apiver = "api/v1" $uri = "dd-systems/$($SYSTEM_ID)/cloud-units/$ID" } } $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.cloud_units| Select-Object -ExcludeProperty link } 'byID' { $response[-1] | Select-Object -Property * -ExcludeProperty link } } } } #get rest/v1.0/dd-systems/{SYSTEM-ID}/cloud-profiles function Get-DDCloudProfiles { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $true, ParameterSetName = 'byID')] [string]$id, [Parameter(Mandatory = $false, ParameterSetName = 'byID')] [Parameter(Mandatory = $false, ParameterSetName = 'default')] [string] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "GET" } process { switch ($PsCmdlet.ParameterSetName) { default { $apiver = "rest/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/cloud-profiles" } 'byID' { $apiver = "api/v1" $uri = "dd-systems/$($SYSTEM_ID)/cloud-profiles/$ID" } } $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.cloud_profile | Select-Object -ExcludeProperty link } 'byID' { $response[-1] | Select-Object -Property * -ExcludeProperty link } } } } |