PSGpfsApi/Public/GpfsSnapshot.ps1

54 lines
1.6 KiB
PowerShell

function Get-GpfsSnapshot {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 1)]
[string]$SnapshotName,
[Parameter(ParameterSetName = 'All')]
[string]$FilesetName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/snapshots/$SnapshotName"
}
else {
$params = @{ Method = 'GET'; Endpoint = "filesystems/$FilesystemName/snapshots" }
if ($FilesetName) {
$params['QueryParameters'] = @{ filesetName = $FilesetName }
}
Invoke-GpfsApiRequest @params
}
}
function New-GpfsSnapshot {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Create snapshot')) {
Invoke-GpfsApiRequest -Method POST -Endpoint "filesystems/$FilesystemName/snapshots" -Body $Settings
}
}
function Remove-GpfsSnapshot {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$SnapshotName
)
if ($PSCmdlet.ShouldProcess($SnapshotName, 'Remove snapshot')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/snapshots/$SnapshotName"
}
}