This repository has been 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
/
New-GitLabProjectLabel.ps1
81 lines (71 loc) · 2.01 KB
/
New-GitLabProjectLabel.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
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
function New-GitLabProjectLabel
{
<#
.SYNOPSIS
Create a new label in a project.
.DESCRIPTION
The New-GitLabProjectLabel function creates a new label.
A label color can be passed using -Color #xxxxxx
.EXAMPLE
New-GitLabProjectLabel -ProjectID 20 -Name 'To Do'
---------------------------------------------------------------
Creates a New label named 'To Do' in project 20.
.EXAMPLE
New-GitLabProjectLabel -ProjectID 20 -Name 'To Do' -PassThru
---------------------------------------------------------------
Creates a New label named 'To Do' in project 20.
Returns the created Label.
#>
[CmdletBinding()]
[Alias()]
[OutputType()]
Param
(
# The ID of the project
[Parameter(HelpMessage = 'ProjectID',
Mandatory = $true)]
[Alias('ID')]
[int]$ProjectID,
# The Label Name
[Parameter(HelpMessage = 'Label Name',
Mandatory = $true)]
[Alias()]
[string]$Name,
# The label color HEX Notation
[Parameter(HelpMessage = 'Label Color Hex notation (#000000)',
Mandatory = $false)]
[Alias('HEXColor')]
[ValidatePattern('^#[A-Fa-f0-9]{6}$')]
[string]$Color = '#428bca',
# Description for the label
[Parameter(HelpMessage = 'Label Description',
Mandatory = $false)]
[Alias()]
[string]$description,
# Specify Existing GitlabConnector
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect),
# Passthru the created label
[Parameter(HelpMessage = 'Passthru the created label',
Mandatory = $false)]
[switch]$PassThru
)
$httpmethod = 'post'
$apiurl = "projects/$ProjectID/labels"
$parameters = @{
id = $ProjectID
name = $name
color = $Color
}
if($description)
{
$parameters.description = $description
}
$newlabel = $GitlabConnect.callapi($apiurl,$httpmethod,$parameters)
if($PassThru)
{
return $newlabel
}
}