Modules/mtree.psm1

#GET /rest/v1.0/dd-systems/{SYSTEM-ID}/mtrees
function Get-DDmtrees {
    [CmdletBinding()]
    param ( 
       [CmdletBinding()]
       [Parameter(Mandatory = $true, ParameterSetName = 'byID', ValueFromPipelineByPropertyName = $true)]
       [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)/mtrees"
          }
          'byID' {
             $apiver = "rest/v3.0"
             $uri = "dd-systems/$($SYSTEM_ID)/mtrees/$ID"
          }               
       }
       $parameters = @{
          uri           = $uri          
          apiver        = $apiver
          Method        = $METHOD
          body          = $body
          RequestMethod = "REST"
          Verbose       = $PSBoundParameters['Verbose'] -eq $true
          Debug       = $PSBoundParameters['Debug'] -eq $true
       }      
       try {
          $Response += Invoke-DDapirequest @Parameters
       }
       catch {
          Get-DDWebException  -ExceptionMessage $_
          break
       }
       write-verbose ($response | Out-String)
    }
    end {    
       switch ($PsCmdlet.ParameterSetName) {
          'default' {
             $response.mtree| Select-Object -ExcludeProperty link
          }
          'byID' {
             $response  | Select-Object -Property * -ExcludeProperty link
          }           
       } 
       
    }
 }

# get /rest/v3.0/dd-systems/{SYSTEM-ID}/stats/performances/mtrees/{ID}
<#
.SYNOPSIS
 
.PARAMETER 1
.PARAMETER 2
.Example
 
 
 
.Example
 
 
 
.Example
 
.example
Get-AVAclients -recursive -body @{fields = "id,name,domainFqdn"}
 
 
id name domainFqdn
-- ---- ----------
6b93fcb902b2365dd52f774b13d782d8c02e5025 avemaster.home.labbuildr.com /MC_SYSTEM
35bc9c1307b085d502d61e39a16521d27e0a2052 ave_vproxy1.home.labbuildr.com /clients
090ba46da2e10d10911110f11b21b432b6ebb762 mba.home.labbuildr.com /clients
b110c4ac0f1641b537879aca7e507a2493eebaf0 openhab2.home.labbuildr.com /clients
dad27693519375d4184179c21dead76f3cddf967 ubnt2in1 /clients
bcd8cff5b95b0fcfa09295b610cab949f30a6c7b pfSense /vcsa1.home.labbuildr.com/VirtualMachines
28a5140dd48b7ddef6e66b2d0242f29bde154463 sqlsinglenode /vcsa1.home.labbuildr.com/VirtualMachines
#>

function Get-DDmtreesPerformances {
   [CmdletBinding()]
   param ( 
      [CmdletBinding()]
      [Parameter(Mandatory = $true, ParameterSetName = 'byID', ValueFromPipelineByPropertyName = $true)]
      [string]$id,                 
      [Parameter(Mandatory = $false, ParameterSetName = 'byID')]
      [string]
      $SYSTEM_ID = $Global:DD_UUID,
      $body = @{}
   )
   begin {
      $Response = @()
      $METHOD = "GET"
   }
   process {
      switch ($PsCmdlet.ParameterSetName) {
         default {
            $apiver = "rest/v3.0"
            $uri = "dd-systems/$($SYSTEM_ID)/mtrees"
         }
         'byID' {
            $apiver = "rest/v3.0"
            $uri = "dd-systems/$($SYSTEM_ID)/stats/performances/mtrees/$ID"
         }               
      }
      $parameters = @{
         uri           = $uri          
         apiver        = $apiver
         Method        = $METHOD
         body          = $body
         RequestMethod = "REST"
         Verbose       = $PSBoundParameters['Verbose'] -eq $true
         Debug       = $PSBoundParameters['Debug'] -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
         }
         'byID' {
            $response.mtree_show_perf_detail  | Select-Object -Property @{N="id";E={$id}},* -ExcludeProperty link 
         }           
      } 
      
   }
}


#POST/rest/v1.0/dd-systems/{SYSTEM-ID}/mtrees
# Put /rest/v1.0/dd-systems/{SYSTEM-ID}/mtrees/{ID}