forked from beyondcomputing-org/Atlassian.Bitbucket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtlassian.Bitbucket.Project.psm1
51 lines (44 loc) · 1.49 KB
/
Atlassian.Bitbucket.Project.psm1
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using module .\Atlassian.Bitbucket.Authentication.psm1
<#
.SYNOPSIS
Returns all Projects in the team.
.DESCRIPTION
Returns all the Bitbucket Projects in the team, or the specific project if specified.
.EXAMPLE
C:\PS> Get-BitbucketProject
Returns all projects for the currently selected team.
.EXAMPLE
C:\PS> Get-BitbucketProject -ProjectKey 'KEY'
Returns the project specified by the key if found.
.PARAMETER Team
Name of the team in Bitbucket. Defaults to selected team if not provided.
.PARAMETER ProjectKey
Project key in Bitbucket
#>
function Get-BitbucketProject {
[CmdletBinding()]
param(
[Parameter( ValueFromPipelineByPropertyName=$true,
HelpMessage='Name of the team in Bitbucket. Defaults to selected team if not provided.')]
[string]$Team = (Get-BitbucketSelectedTeam),
[Parameter( Mandatory=$false,
Position=0,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage='Project key in Bitbucket')]
[string]$ProjectKey
)
Process {
$endpoint = "teams/$Team/projects/"
if($ProjectKey)
{
# Fetch a specific project
$endpoint += $ProjectKey
return Invoke-BitbucketAPI -Path $endpoint
}
else
{
return Invoke-BitbucketAPI -Path $endpoint -Paginated
}
}
}