Public/Get-JiraPriority.ps1
function Get-JiraPriority { <# .SYNOPSIS Returns information about the available priorities in JIRA. .DESCRIPTION This function retrieves all the available Priorities on the JIRA server an returns them as JiraPS.Priority. This function can restrict the output to a subset of the available IssueTypes if told so. .EXAMPLE Get-JiraPriority This example returns all the IssueTypes on the JIRA server. .EXAMPLE Get-JiraPriority -ID 1 This example returns only the Priority with ID 1. .OUTPUTS This function outputs the JiraPS.Priority object retrieved. .NOTES This function requires either the -Credential parameter to be passed or a persistent JIRA session. See New-JiraSession for more details. If neither are supplied, this function will run with anonymous access to JIRA. #> [CmdletBinding( DefaultParameterSetName = '_All' )] param( # ID of the priority to get. [Parameter( Position = 0, Mandatory, ValueFromPipeline, ParameterSetName = '_Search' )] [Int[]] $Id, # Credentials to use to connect to JIRA. # If not specified, this function will use anonymous access. [PSCredential] $Credential ) begin { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started" $server = Get-JiraConfigServer -ErrorAction Stop $resourceURi = "$server/rest/api/latest/priority{0}" } process { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)" Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)" switch ($PSCmdlet.ParameterSetName) { '_All' { $parameter = @{ URI = $resourceURi -f "" Method = "GET" Credential = $Credential } Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter" $result = Invoke-JiraMethod @parameter Write-Output (ConvertTo-JiraPriority -InputObject $result) } '_Search' { foreach ($_id in $Id) { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_id]" Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_id [$_id]" $parameter = @{ URI = $resourceURi -f "/$_id" Method = "GET" Credential = $Credential } Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter" $result = Invoke-JiraMethod @parameter Write-Output (ConvertTo-JiraPriority -InputObject $result) } } } } end { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete" } } |