PSGpfsApi/Public/GpfsQuota.ps1

72 lines
1.9 KiB
PowerShell

function Get-GpfsQuota {
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter()]
[ValidateSet('USR', 'GRP', 'FILESET')]
[string]$QuotaType,
[Parameter()]
[string]$ObjectName,
[Parameter()]
[string]$FilesetName
)
$query = @{}
if ($QuotaType) { $query['quotaType'] = $QuotaType }
if ($ObjectName) { $query['objectName'] = $ObjectName }
if ($FilesetName){ $query['filesetName']= $FilesetName }
$params = @{ Method = 'GET'; Endpoint = "filesystems/$FilesystemName/quotas" }
if ($query.Count -gt 0) { $params['QueryParameters'] = $query }
Invoke-GpfsApiRequest @params
}
function New-GpfsQuota {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Create quota')) {
Invoke-GpfsApiRequest -Method POST -Endpoint "filesystems/$FilesystemName/quotas" -Body $Settings
}
}
function Set-GpfsQuota {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Update quota')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "filesystems/$FilesystemName/quotas" -Body $Settings
}
}
function Remove-GpfsQuota {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Filter
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Remove quota')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/quotas" -Body $Filter
}
}