-
Notifications
You must be signed in to change notification settings - Fork 6
/
Atlassian.Bitbucket.Project.psm1
50 lines (43 loc) · 1.54 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
using module .\Atlassian.Bitbucket.Authentication.psm1
<#
.SYNOPSIS
Returns all Projects in the workspace.
.DESCRIPTION
Returns all the Bitbucket Projects in the workspace, or the specific project if specified.
.EXAMPLE
C:\PS> Get-BitbucketProject
Returns all projects for the currently selected workspace.
.EXAMPLE
C:\PS> Get-BitbucketProject -ProjectKey 'KEY'
Returns the project specified by the key if found.
.PARAMETER Workspace
Name of the workspace in Bitbucket. Defaults to selected workspace if not provided.
.PARAMETER ProjectKey
Project key in Bitbucket
#>
function Get-BitbucketProject {
[CmdletBinding()]
param(
[Parameter( ValueFromPipelineByPropertyName = $true,
HelpMessage = 'Name of the workspace in Bitbucket. Defaults to selected workspace if not provided.')]
[Alias("Team")]
[string]$Workspace = (Get-BitbucketSelectedWorkspace),
[Parameter( Mandatory = $false,
Position = 0,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
HelpMessage = 'Project key in Bitbucket')]
[string]$ProjectKey
)
Process {
$endpoint = "workspaces/$Workspace/projects/"
if ($ProjectKey) {
# Fetch a specific project
$endpoint += $ProjectKey
return Invoke-BitbucketAPI -Path $endpoint
}
else {
return Invoke-BitbucketAPI -Path $endpoint -Paginated
}
}
}