public/Get-VolumeSnapshot.ps1
|
function Get-ZStackVolumeSnapshot { # .SYNOPSIS # Returns individual volume snapshots. # .DESCRIPTION # ZStack PowerCLI (ZStack.PowerCLI 1.1.4) uses CLI 1.1.4, commit dca13b1d898c80c0f7189b5adb4a5537685ad4a6. # Connection configuration namespace: zstack-powershell. # .LINK # https://github.com/terraform-zstack-modules/zstack-cli-go/blob/main/docs/powershell.md [CmdletBinding(DefaultParameterSetName = 'Inventory')] param( [Parameter(Mandatory, ParameterSetName = 'ByVolume', ValueFromPipeline)] [ValidateNotNullOrEmpty()] [object[]] $Volume, [ValidateNotNullOrEmpty()] [string[]] $Name, [ValidatePattern('\A[A-Za-z0-9-]{1,128}\z')] [string[]] $Id, [object] $Server ) begin { $targets = [System.Collections.Generic.List[object]]::new() } process { if ($PSCmdlet.ParameterSetName -ceq 'ByVolume') { $targets.AddRange($Volume) } } end { if ($PSCmdlet.ParameterSetName -ceq 'Inventory') { Get-CloudInventory -Type VolumeSnapshot -Server $Server -Name $Name -Id $Id } else { Get-CloudInventory -Type VolumeSnapshot -Server $Server -Name $Name -Id $Id -ParentField volumeUuid -ParentType @('Volume', 'HardDisk') -Parent ($targets.ToArray()) } } } |