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-GitLabProjectMergeRequestNote.ps1
74 lines (63 loc) · 1.94 KB
/
New-GitLabProjectMergeRequestNote.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
function New-GitLabProjectMergeRequestNote
{
<#
.SYNOPSIS
Adds a singel note to a Merge Request
.DESCRIPTION
The New-GitLabProjectIssueNote function adds a single note to a Merge Request.
By specifying -PassThru the created MR Note is returned.
.EXAMPLE
New-GitLabProjectMergeRequestNote -ProjectID 20 -MergeRequestID 1 -Body 'Elaborate on readme.md'
---------------------------------------------------------------
Creates a new note 'Elaborate on readme.md' on merge request 1 in project 20.
#>
[CmdletBinding()]
[Alias('New-GitLabProjectMRNote')]
[OutputType()]
Param
(
#The ID of the project
[Parameter(
HelpMessage = 'ProjectID',
Mandatory = $true)]
[Alias('ID')]
[int]$ProjectID,
#The ID of a projects MergeRequest
[Parameter(HelpMessage = 'MergeRequestID',
Mandatory = $true)]
[Alias('merge_request_id','MRID')]
[string]$MergeRequestID,
# The content of the note
[Parameter(HelpMessage = 'The content of a note',
Mandatory = $true)]
[string]$Body,
# The time the note was created
[Parameter(HelpMessage = 'time of creation',
Mandatory = $false)]
[Alias('created_at')]
[DateTime]$CreatedAt,
# Specify Existing GitlabConnector
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect),
# Return the created Merge Request Note
[Parameter(HelpMessage = 'Passthru the created object',
Mandatory = $false)]
[switch]$PassThru
)
$httpmethod = 'post'
$apiurl = "projects/$ProjectID/merge_requests/$MergeRequestID/notes"
$parameters = @{
body = $body
}
if($CreatedAt)
{
$parameters.'created_at' = $CreatedAt.ToUniversalTime().tostring('s') +'Z'
}
$newnote = $GitlabConnect.callapi($apiurl,$httpmethod,$parameters)
if($PassThru)
{
return $newnote
}
}