Modules/file-systems.psm1
# GET /rest/v1.0/dd-systems/{SYSTEM-ID}/file-systems function Get-DDFileSystems { [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 = "rest/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/file-systems" } } $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 } } } } # PUT /rest/v1.0/dd-systems/{SYSTEM-ID}/file-systems function Set-DDFileSystems { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $true, ParameterSetName = 'enable')] [switch]$enable, [Parameter(Mandatory = $true, ParameterSetName = 'disable')] [switch]$disable, [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/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/file-systems" # creating body by pset switch ($PsCmdlet.ParameterSetName) { default { $json = @{ operation = $PsCmdlet.ParameterSetName } | ConvertTo-Json } } $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 } } } } # /api/v1/dd-systems/{SYSTEM-ID}/file-systems/block-storages function Set-DDFileSystemsBlockStorage { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]# , ParameterSetName = 'enable')] [Alias("device")] [string[]]$devices, [string] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "PUT" } process { $apiver = "api/v1" $uri = "dd-systems/$($SYSTEM_ID)/file-systems/block-storages" # creating body by pset switch ($PsCmdlet.ParameterSetName) { default { $json = @{ disks = @( $devices ) } | 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 } } } } |