Modules/protocols.psm1
<# GET
/rest/v1.0/dd-systems/{SYSTEM-ID}/protocols/ddboost Get the DDBoost configuration #> function Get-DDProtocols { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $true, ParameterSetName = 'nfs')] [switch]$nfs, [Parameter(Mandatory = $true, ParameterSetName = 'ddboost')] [switch]$ddboost, [Parameter(Mandatory = $true, ParameterSetName = 'cifs')] [switch]$cifs, [Parameter(Mandatory = $false)] [string] $SYSTEM_ID = $Global:DD_UUID, $body = @{} ) begin { $Response = @() $METHOD = "GET" } process { switch ($PsCmdlet.ParameterSetName) { 'cifs' { $apiver = "rest/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/protocols/cifs" } 'ddboost' { $apiver = "rest/v1.0" $uri = "dd-systems/$($SYSTEM_ID)/protocols/ddboost" } 'nfs' { $apiver = "api/v2" $uri = "dd-systems/$($SYSTEM_ID)/protocols/nfs" } } $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) { 'byID' { write-output $response } default { write-output $response } } } } function Get-DDCifsShares { [CmdletBinding()] param ( [CmdletBinding()] [Parameter(Mandatory = $false)] [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)/protocols/cifs/shares" } } $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 { write-output $response } } } } #/rest/v1.0/dd-systems/{SYSTEM-ID}/protocols/ddboost/storage-units function Get-DDBoostStorageUnits { [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)/protocols/ddboost/storage-units" } 'byID' { $apiver = "api/v3" $uri = "dd-systems/$($SYSTEM_ID)/protocols/ddboost/storage-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) { 'byID' { $response[-1] | Select-Object -Property * -ExcludeProperty link } 'default' { $Response.storage_units | Select-Object -ExcludeProperty link } } } } function Get-DDNfsExports { [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/v2.0" $uri = "dd-systems/$($SYSTEM_ID)/protocols/nfs/exports" } 'byID' { $apiver = "rest/v2.0" $uri = "dd-systems/$($SYSTEM_ID)/protocols/nfs/exports/$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.exports | Select-Object -ExcludeProperty link } 'byID' { $response[-1] | Select-Object -Property * -ExcludeProperty link } } } } |