Functions/Project/Get-BambooProject.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<#
.SYNOPSIS
    Gets all projects or describes a single Bamboo Project.
.DESCRIPTION
    If -ProjectKey is specified it describes only that project.
.PARAMETER ProjectKey
    Optional - Key for the Bamboo Project to be described
.EXAMPLE
    Get-BambooProject
.EXAMPLE
    Get-BambooProject -ProjectKey 'PRJ'
#>

function Get-BambooProject {
    [CmdletBinding()]
    param(
        [Parameter()]
        [ValidatePattern('\w+')]
        [string]$ProjectKey
    )

    $resource = 'project'
    if ($ProjectKey) {
        $resource = "project/$ProjectKey"
    }

    Invoke-BambooRestMethod -Resource $resource |
    Expand-BambooResource -ResourceName 'project' |
    Add_ObjectType -TypeName 'PsBamboo.Project'
}