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
/
Set-GitLabGroup.ps1
132 lines (117 loc) · 4.75 KB
/
Set-GitLabGroup.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
function Set-GitLabGroup {
<#
.SYNOPSIS
Update settings of existing gitlab group
.DESCRIPTION
Updates the settings of an existing gitlab group with given id.
.EXAMPLE
Set-GitLabGroup -GroupId 10 -Name "NewName"
---------------------------------------------------------------
Changes the name of group with id 10 to "NewName".
#>
[Alias()]
[OutputType()]
Param (
#Group id
[Parameter(HelpMessage='id of the group',
Mandatory=$true)]
[Alias("ID")]
[String]$GroupId,
#The Name of the new group
[Parameter(HelpMessage='new group name',
Mandatory=$false)]
[string]$Name,
#The path of the new group
[Parameter(HelpMessage='path of the group',
Mandatory=$false)]
[string]$Path,
#The description of the new group
[Parameter(HelpMessage='description of the group',
Mandatory=$false)]
[string]$Description,
#Membership lock
[Parameter(HelpMessage='prevent adding new members to project membership within this group',
Mandatory=$false)]
[Alias("membership_lock")]
[bool]$MembershipLock,
#Membership lock
[Parameter(HelpMessage='prevent sharing a project with another group within this group',
Mandatory=$false)]
[Alias("share_with_group_lock")]
[bool]$ShareWithGroupLock,
#The visibility of the new group
[Parameter(HelpMessage='visibility of the group',
Mandatory=$false)]
[validateset("private","internal","public")]
[string]$Visibility,
#The lfs settings for the new group
[Parameter(HelpMessage='enable/disable lfs support',
Mandatory=$false)]
[Alias("lfs_enabled")]
[bool]$LfsEnabled,
#request_access_enabled
[Parameter(HelpMessage='allow users to request member access',
Mandatory=$false)]
[Alias("request_access_enabled")]
[bool]$RequestAccessEnabled,
#parent id
[Parameter(HelpMessage='(premium) The ID of a project to load custom file templates from',
Mandatory=$false)]
[Alias("file_template_project_id")]
[int]$FileTemplateProjectId,
#shared_runners_minutes_limit
[Parameter(HelpMessage='(admin-only) Pipeline minutes quota for this group',
Mandatory=$false)]
[Alias("shared_runners_minutes_limit")]
[int]$SharedRunnersLimit,
# Existing GitlabConnector Object, can be retrieved with Get-GitlabConnect
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect),
# Passthru the created project
[Parameter(HelpMessage='Passthru the created project',
Mandatory=$false)]
[switch]$PassThru
)
$httpmethod = "put"
$apiurl = "groups/$([System.Web.HttpUtility]::UrlEncode($groupId))"
$parameters = @{}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'Name'){
$parameters.name=$name
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'Path'){
$parameters.path=$path
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'Description'){
$parameters.description=$description
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'MembershipLock'){
$parameters.membership_lock=$membershipLock
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'ShareWithGroupLock'){
$parameters.share_with_group_lock=$shareWithGroupLock
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'Visibility'){
$parameters.visibility=$visibility
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'LfsEnabled'){
$parameters.lfs_enabled=$lfsEnabled
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'RequestAccessEnabled'){
$parameters.request_access_enabled=$requestAccessEnabled
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'FileTemplateProjectId'){
$parameters.file_template_project_id=$fileTemplateProjectId
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'ParentID'){
$parameters.parent_id=$parentID
}
if($PSCmdlet.MyInvocation.BoundParameters.keys -contains 'SharedRunnersLimit'){
$parameters.shared_runners_minutes_limit=$sharedRunnersLimit
}
$group= $GitlabConnect.callapi($apiurl,$httpmethod,$parameters)
if($passThru){
return $group
}
}