This repository was archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-GitLabProjectIssue.ps1
More file actions
97 lines (84 loc) · 2.65 KB
/
Copy pathGet-GitLabProjectIssue.ps1
File metadata and controls
97 lines (84 loc) · 2.65 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
function Get-GitLabProjectIssue
{
<#
.SYNOPSIS
Gets GitLab Project Issue.
.DESCRIPTION
Gets GitLab Project Issue. Gets all Issues by Default.
All issues can be filtered by:
-State (opened:closed)
-Labels (comma seperated labels)
-Milestone (assigned Milestone)
If IssueID is passed only specified issue is retured.
.EXAMPLE
Get-GitLabProjectIssue -ProjectID 20
---------------------------------------------------------------
Gets all issues for project 20
.EXAMPLE
Get-GitLabProjectIssue -ProjectID 20 -IssueID 1
---------------------------------------------------------------
Gets issue 1 for project 20
.EXAMPLE
Get-GitLabProjectIssue -ProjectID 20 -State 'opened'
---------------------------------------------------------------
Gets all open issues for project 20
#>
[CmdletBinding(DefaultParameterSetName = 'AllIssues')]
[Alias()]
[OutputType()]
Param
(
# The ID of a project
[Parameter(
HelpMessage = 'ProjectID',
Mandatory = $true)]
[Alias('ID')]
[String]$ProjectID,
# If specified only returns opened or closed issues.
[Parameter(ParameterSetName = 'AllIssues',
HelpMessage = 'State (opened|closed)')]
[validateset('opened','closed')]
[string]$State,
# If list of label names is specified only issues with any of the labels will be returned
[Parameter(ParameterSetName = 'AllIssues',
HelpMessage = 'list of labels')]
[string[]]$Labels,
# If Specified only issues belonging to specified milestone will be returned
[Parameter(ParameterSetName = 'AllIssues',
HelpMessage = 'milestone title')]
[string[]]$Milestone,
#The ID of a projects issue
[Parameter(ParameterSetName = 'SingleIssue',
HelpMessage = 'IssueID',
Mandatory = $true)]
[string]$IssueID,
# Existing GitlabConnector Object, can be retrieved with Get-GitlabConnect
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect)
)
$httpmethod = 'get'
$apiurl = "projects/$([System.Web.HttpUtility]::UrlEncode($projectId))/issues"
$parameters = @{}
if($PSCmdlet.ParameterSetName -like 'AllIssues')
{
if($State)
{
$parameters.state = $State
}
if($Labels)
{
$parameters.labels = @($Labels) -join ','
}
if($Milestone)
{
$parameters.milestone = $Milestone
}
}
if($PSCmdlet.ParameterSetName -like 'SingleIssue')
{
$apiurl += "/$IssueID"
}
$GitlabConnect.callapi($apiurl,$httpmethod,$parameters)
}