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
         }         
      } 
       
   }
}
 
function Get-DDFileSystemsObjectStoresAWS {
   [CmdletBinding()]
   [Alias('Get-DDAtosAWS','Get-PPDDAtosAWS')]
   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"
    method: GET
    method: GET
            $uri = "dd-systems/$($SYSTEM_ID)/file-systems/object-stores/aws"
         }
              
      }
      $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 = 'destroy')]
      [switch]$destroy,              
      [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
         }         
      } 
      
   }
}


<#
{
  "description": "Filesys modify",
  "required": [
    "operation"
  ],
  "type": "object",
  "properties": {
    "operation": {
      "description": "An operation type must be done on filesystem",
      "enum": [
        "clean_start",
        "clean_stop",
        "clean_throttle_set",
        "clean_schedule_set",
        "clean_frequency_set",
        "clean_throttle_reset",
        "clean_schedule_reset",
        "clean_frequency_reset",
        "create",
        "destroy",
        "enable",
        "disable",
        "set_options"
      ],
      "type": "string"
    },
    "write_zeros": {
      "type": "boolean"
    },
    "options": {
      "type": "array",
      "minItems": 0,
      "items": {
        "description": "Filesys option name and value",
        "required": [
          "fs_option",
          "value"
        ],
        "type": "object",
        "properties": {
          "fs_option": {
            "description": "Filesys Option name",
            "enum": [
              "local-compression-type",
              "staging-reserve",
              "report-replica-as-writable",
              "critical-space-usage",
              "warning-space-usage"
            ],
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      }
    },
    "clean_option_value": {
      "description": "Cleaning modify options",
      "required": [
        "tier_type"
      ],
      "type": "object",
      "properties": {
        "throttle": {
          "format": "int32",
          "minimum": 0,
          "type": "integer"
        },
        "schedule": {
          "description": "Filesys clean schedule.",
          "type": "object",
          "properties": {
            "occurrence": {
              "description": "Cleaning schedule occurrence",
              "enum": [
                "never",
                "daily",
                "weekly",
                "biweekly",
                "monthly"
              ],
              "type": "string"
            },
            "days": {
              "type": "array",
              "minItems": 0,
              "maxItems": 7,
              "items": {
                "description": "Days of the week",
                "enum": [
                  "Sun",
                  "Mon",
                  "Tue",
                  "Wed",
                  "Thu",
                  "Fri",
                  "Sat"
                ],
                "type": "string"
              }
            },
            "date": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            },
            "time": {
              "type": "string"
            },
            "next_scheduled_epoch": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            }
          }
        },
        "frequency": {
          "format": "int32",
          "minimum": 0,
          "type": "integer"
        },
        "tier_type": {
          "description": "Tier type",
          "enum": [
            "active",
            "cloud",
            "archive",
            "total"
          ],
          "type": "string"
        },
        "cloud_unit_name": {
          "type": "string"
        }
      }
    }
  }
}
#>


# /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
         }         
      } 
      
   }
}


function Set-DDFileSystemsObjectStoresAWS {
   [CmdletBinding()]
   [Alias('Set-DDAtosAWS','Set-PPDDAtosAWS')]
   param ( 
      [CmdletBinding()]
      [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]# , ParameterSetName = 'enable')]
      [Alias("device")]
      [string[]]$devices,
      [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]# , ParameterSetName = 'enable')]
      [Alias("blob")]
      [string]$bucket,                        
      [string]
      $SYSTEM_ID = $Global:DD_UUID,
      $body = @{}
   )
   begin {
      $Response = @()
      $METHOD = "PUT"
   }
   process {

      $apiver = "api/v1"
      $uri = "dd-systems/$($SYSTEM_ID)/file-systems/object-stores/aws"

      # creating body by pset
      switch ($PsCmdlet.ParameterSetName) {
         default {
            $json = @{
               disks = @(
                  $devices )
               acceptCertificate = $true
               bucketType =  $bucket                  
            } | 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
         }         
      } 
      
   }
}