Functions/DeployProject/Get-BambooDeployProject.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
31
32
<#
.SYNOPSIS
    Gets all deploy projects or describes a single Bamboo Deploy Project.
.DESCRIPTION
    If -DeploymentProjectId is specified it describes only that deploy project.
.PARAMETER DeploymentProjectId
    Optional - Key for the Bamboo Deploy Project to be described
.EXAMPLE
    Get-BambooDeployProject
.EXAMPLE
    Get-BambooDeployProject -DeploymentProjectId 'PRJ'
#>

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

    $ContentType = 'application/json'
    Write-Warning "Get-BambooDeployProject: The Bamboo API for 'Deploy Projects' only supports JSON response format. Using content-type: $ContentType"

    $resource = 'deploy/project/all'
    if ($DeploymentProjectId) {
        $resource = "deploy/project/$DeploymentProjectId"
    }

    Invoke-BambooRestMethod -Resource $resource -ContentType $ContentType |
    Add_ObjectType -TypeName 'PsBamboo.DeployProject'
}