Public/Get-DuneResourceGroupSequence.ps1
|
<# .SYNOPSIS Retrieve sequences for a resource group. .DESCRIPTION Gets sequence objects for a specific resource group. Identify the resource group by `Id` or by passing a `DuneResourceGroup` object via pipeline. Supports filtering by `Usage` and `-Raw` output. .PARAMETER Id The GUID of the resource group whose sequences should be returned. Mandatory in the `Id` parameter set. .PARAMETER ResourceGroup A `DuneResourceGroup` object; use this parameter (or pipeline input) to return sequences for the provided resource group. .PARAMETER Usage Filter sequences by `SequenceUsage`. .PARAMETER Raw If set, returns raw API objects instead of `DuneSequence` objects. .EXAMPLE PS> Get-DuneResourceGroupSequence -Id 3d8f6b5a-... Returns sequences for the resource group with the given `Id`. .EXAMPLE PS> Get-DuneResourceGroup -Name "rg-app" | Get-DuneResourceGroupSequence Pipeline example using the `ResourceGroup` parameter set. #> function Get-DuneResourceGroupSequence { [CmdletBinding(DefaultParameterSetName = "Default")] param ( [Parameter(Mandatory, ParameterSetName = "Id")] [guid]$Id, [Parameter(Mandatory, ParameterSetName = "ResourceGroup", ValueFromPipeline)] [DuneResourcegroup]$ResourceGroup, [Parameter()] [SequenceUsage]$Usage, [Parameter()] [switch]$Raw ) begin { Write-Debug "$($MyInvocation.MyCommand)|begin" $ReturnObjects = @() $BaseUri = 'resourcegroups/{0}/sequences' $Method = 'GET' } process { Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)" if ($PSCmdlet.ParameterSetName -eq 'ResourceGroup') { $Id = $ResourceGroup.Id } # Build Uri $Uri = $BaseUri -f $Id $ResultItems = Invoke-DuneApiRequest -Method $Method -Uri $Uri -ExtractItems $ReturnObjects += $ResultItems | ForEach-Object { if ($Raw) { $_ } else { ConvertTo-DuneClassObject -Class DuneSequence -InputObject $_ } } # Filter for Usage if ($Usage) { $ReturnObjects = $ReturnObjects | Where-Object Usage -eq $Usage } } end { Write-Debug "$($MyInvocation.MyCommand)|end" return $ReturnObjects } } |