gitlab 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/stale.yml +18 -0
- data/.rubocop_todo.yml +46 -0
- data/Gemfile +2 -0
- data/README.md +22 -22
- data/Rakefile +3 -5
- data/bin/console +1 -0
- data/exe/gitlab +5 -1
- data/gitlab.gemspec +9 -6
- data/lib/gitlab.rb +6 -3
- data/lib/gitlab/api.rb +5 -3
- data/lib/gitlab/cli.rb +11 -5
- data/lib/gitlab/cli_helpers.rb +31 -22
- data/lib/gitlab/client.rb +7 -8
- data/lib/gitlab/client/access_requests.rb +100 -93
- data/lib/gitlab/client/award_emojis.rb +127 -127
- data/lib/gitlab/client/boards.rb +82 -82
- data/lib/gitlab/client/branches.rb +89 -89
- data/lib/gitlab/client/build_variables.rb +117 -117
- data/lib/gitlab/client/builds.rb +98 -98
- data/lib/gitlab/client/commits.rb +154 -154
- data/lib/gitlab/client/deployments.rb +29 -29
- data/lib/gitlab/client/environments.rb +80 -80
- data/lib/gitlab/client/events.rb +54 -54
- data/lib/gitlab/client/group_milestones.rb +85 -86
- data/lib/gitlab/client/groups.rb +178 -178
- data/lib/gitlab/client/issues.rb +195 -196
- data/lib/gitlab/client/jobs.rb +150 -150
- data/lib/gitlab/client/keys.rb +14 -14
- data/lib/gitlab/client/labels.rb +79 -79
- data/lib/gitlab/client/merge_request_approvals.rb +102 -102
- data/lib/gitlab/client/merge_requests.rb +281 -256
- data/lib/gitlab/client/milestones.rb +85 -85
- data/lib/gitlab/client/namespaces.rb +18 -18
- data/lib/gitlab/client/notes.rb +260 -260
- data/lib/gitlab/client/pipeline_schedules.rb +123 -123
- data/lib/gitlab/client/pipeline_triggers.rb +93 -93
- data/lib/gitlab/client/pipelines.rb +62 -62
- data/lib/gitlab/client/projects.rb +526 -505
- data/lib/gitlab/client/repositories.rb +68 -55
- data/lib/gitlab/client/repository_files.rb +103 -103
- data/lib/gitlab/client/runners.rb +113 -115
- data/lib/gitlab/client/services.rb +46 -45
- data/lib/gitlab/client/sidekiq.rb +32 -32
- data/lib/gitlab/client/snippets.rb +86 -86
- data/lib/gitlab/client/system_hooks.rb +57 -57
- data/lib/gitlab/client/tags.rb +87 -88
- data/lib/gitlab/client/todos.rb +41 -41
- data/lib/gitlab/client/users.rb +242 -228
- data/lib/gitlab/client/versions.rb +16 -0
- data/lib/gitlab/configuration.rb +7 -5
- data/lib/gitlab/error.rb +3 -1
- data/lib/gitlab/file_response.rb +4 -2
- data/lib/gitlab/help.rb +9 -9
- data/lib/gitlab/objectified_hash.rb +5 -4
- data/lib/gitlab/page_links.rb +9 -7
- data/lib/gitlab/paginated_response.rb +14 -4
- data/lib/gitlab/request.rb +8 -5
- data/lib/gitlab/shell.rb +6 -4
- data/lib/gitlab/shell_history.rb +7 -5
- data/lib/gitlab/version.rb +3 -1
- metadata +8 -5
@@ -1,507 +1,528 @@
|
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines methods related to projects.
|
4
|
+
# @see https://docs.gitlab.com/ce/api/projects.html
|
5
|
+
module Projects
|
6
|
+
# Gets a list of projects owned by the authenticated user.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# Gitlab.projects
|
10
|
+
#
|
11
|
+
# @param [Hash] options A customizable set of options.
|
12
|
+
# @option options [Integer] :page The page number.
|
13
|
+
# @option options [Integer] :per_page The number of results per page.
|
14
|
+
# (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#list-all-projects Gitlab docs} for all valid options)
|
15
|
+
#
|
16
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
17
|
+
def projects(options = {})
|
18
|
+
get('/projects', query: options)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Search for projects by name.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# Gitlab.project_search('gitlab')
|
25
|
+
# Gitlab.project_search('gitlab', { order_by: 'last_activity_at' })
|
26
|
+
# Gitlab.search_projects('gitlab', { order_by: 'name', sort: 'asc' })
|
27
|
+
#
|
28
|
+
# @param [Hash] options A customizable set of options.
|
29
|
+
# @option options [String] :per_page Number of projects to return per page
|
30
|
+
# @option options [String] :page The page to retrieve
|
31
|
+
# @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
|
32
|
+
# @option options [String] :sort Return requests sorted in asc or desc order
|
33
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
34
|
+
def project_search(query, options = {})
|
35
|
+
get('/projects', query: options.merge(search: query))
|
36
|
+
end
|
37
|
+
alias search_projects project_search
|
38
|
+
|
39
|
+
# Gets information about a project.
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# Gitlab.project(3)
|
43
|
+
# Gitlab.project('gitlab')
|
44
|
+
#
|
45
|
+
# @param [Integer, String] id The ID or path of a project.
|
46
|
+
# @return [Gitlab::ObjectifiedHash]
|
47
|
+
def project(id)
|
48
|
+
get("/projects/#{url_encode id}")
|
49
|
+
end
|
50
|
+
|
51
|
+
# Creates a new project.
|
52
|
+
#
|
53
|
+
# @example
|
54
|
+
# Gitlab.create_project('gitlab')
|
55
|
+
# Gitlab.create_project('viking', { description: 'Awesome project' })
|
56
|
+
# Gitlab.create_project('Red', { wall_enabled: false })
|
57
|
+
#
|
58
|
+
# @param [String] name The name of a project.
|
59
|
+
# @param [Hash] options A customizable set of options.
|
60
|
+
# @option options [String] :description The description of a project.
|
61
|
+
# @option options [String] :default_branch The default branch of a project.
|
62
|
+
# @option options [String] :path Repository name for new project. (Default is lowercase name with dashes)
|
63
|
+
# @option options [String] :namespace_id The namespace in which to create a project.
|
64
|
+
# @option options [Boolean] :wiki_enabled The wiki integration for a project (0 = false, 1 = true).
|
65
|
+
# @option options [Boolean] :wall_enabled The wall functionality for a project (0 = false, 1 = true).
|
66
|
+
# @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
|
67
|
+
# @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
|
68
|
+
# @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
|
69
|
+
# @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true).
|
70
|
+
# @option options [Integer] :user_id The user/owner id of a project.
|
71
|
+
# @return [Gitlab::ObjectifiedHash] Information about created project.
|
72
|
+
def create_project(name, options = {})
|
73
|
+
url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : '/projects'
|
74
|
+
post(url, body: { name: name }.merge(options))
|
75
|
+
end
|
76
|
+
|
77
|
+
# Deletes a project.
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# Gitlab.delete_project(4)
|
81
|
+
#
|
82
|
+
# @param [Integer, String] id The ID or path of a project.
|
83
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted project.
|
84
|
+
def delete_project(id)
|
85
|
+
delete("/projects/#{url_encode id}")
|
86
|
+
end
|
87
|
+
|
88
|
+
# Gets a list of project team members.
|
89
|
+
#
|
90
|
+
# @example
|
91
|
+
# Gitlab.team_members(42)
|
92
|
+
# Gitlab.team_members('gitlab')
|
93
|
+
#
|
94
|
+
# @param [Integer, String] project The ID or path of a project.
|
95
|
+
# @param [Hash] options A customizable set of options.
|
96
|
+
# @option options [String] :query The search query.
|
97
|
+
# @option options [Integer] :page The page number.
|
98
|
+
# @option options [Integer] :per_page The number of results per page.
|
99
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
100
|
+
def team_members(project, options = {})
|
101
|
+
get("/projects/#{url_encode project}/members", query: options)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Gets a project team member.
|
105
|
+
#
|
106
|
+
# @example
|
107
|
+
# Gitlab.team_member('gitlab', 2)
|
108
|
+
#
|
109
|
+
# @param [Integer, String] project The ID or path of a project.
|
110
|
+
# @param [Integer] id The ID of a project team member.
|
111
|
+
# @return [Gitlab::ObjectifiedHash]
|
112
|
+
def team_member(project, id)
|
113
|
+
get("/projects/#{url_encode project}/members/#{id}")
|
114
|
+
end
|
115
|
+
|
116
|
+
# Adds a user to project team.
|
117
|
+
#
|
118
|
+
# @example
|
119
|
+
# Gitlab.add_team_member('gitlab', 2, 40)
|
120
|
+
# Gitlab.add_team_member('gitlab', 2, 40, { expires_at: "2018-12-31"})
|
121
|
+
#
|
122
|
+
# @param [Integer, String] project The ID or path of a project.
|
123
|
+
# @param [Integer] id The ID of a user.
|
124
|
+
# @param [Integer] access_level The access level to project.
|
125
|
+
# @param [Hash] options A customizable set of options.
|
126
|
+
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
127
|
+
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
128
|
+
def add_team_member(project, id, access_level, options = {})
|
129
|
+
body = { user_id: id, access_level: access_level }.merge(options)
|
130
|
+
post("/projects/#{url_encode project}/members", body: body)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Updates a team member's project access level.
|
134
|
+
#
|
135
|
+
# @example
|
136
|
+
# Gitlab.edit_team_member('gitlab', 3, 20)
|
137
|
+
# Gitlab.edit_team_member('gitlab', 3, 20, { expires_at: "2018-12-31"})
|
138
|
+
#
|
139
|
+
# @param [Integer, String] project The ID or path of a project.
|
140
|
+
# @param [Integer] id The ID of a user.
|
141
|
+
# @param [Integer] access_level The access level to project.
|
142
|
+
# @param [Hash] options A customizable set of options.
|
143
|
+
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
144
|
+
# @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
|
145
|
+
def edit_team_member(project, id, access_level, options = {})
|
146
|
+
body = { access_level: access_level }.merge(options)
|
147
|
+
put("/projects/#{url_encode project}/members/#{id}", body: body)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Removes a user from project team.
|
151
|
+
#
|
152
|
+
# @example
|
153
|
+
# Gitlab.remove_team_member('gitlab', 2)
|
154
|
+
#
|
155
|
+
# @param [Integer, String] project The ID or path of a project.
|
156
|
+
# @param [Integer] id The ID of a user.
|
157
|
+
# @param [Hash] options A customizable set of options.
|
158
|
+
# @return [Gitlab::ObjectifiedHash] Information about removed team member.
|
159
|
+
def remove_team_member(project, id)
|
160
|
+
delete("/projects/#{url_encode project}/members/#{id}")
|
161
|
+
end
|
162
|
+
|
163
|
+
# Gets a list of project hooks.
|
164
|
+
#
|
165
|
+
# @example
|
166
|
+
# Gitlab.project_hooks(42)
|
167
|
+
# Gitlab.project_hooks('gitlab')
|
168
|
+
#
|
169
|
+
# @param [Integer, String] project The ID or path of a project.
|
170
|
+
# @param [Hash] options A customizable set of options.
|
171
|
+
# @option options [Integer] :page The page number.
|
172
|
+
# @option options [Integer] :per_page The number of results per page.
|
173
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
174
|
+
def project_hooks(project, options = {})
|
175
|
+
get("/projects/#{url_encode project}/hooks", query: options)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Gets a project hook.
|
179
|
+
#
|
180
|
+
# @example
|
181
|
+
# Gitlab.project_hook(42, 5)
|
182
|
+
# Gitlab.project_hook('gitlab', 5)
|
183
|
+
#
|
184
|
+
# @param [Integer, String] project The ID or path of a project.
|
185
|
+
# @param [Integer] id The ID of a hook.
|
186
|
+
# @return [Gitlab::ObjectifiedHash]
|
187
|
+
def project_hook(project, id)
|
188
|
+
get("/projects/#{url_encode project}/hooks/#{id}")
|
189
|
+
end
|
190
|
+
|
191
|
+
# Adds a new hook to the project.
|
192
|
+
#
|
193
|
+
# @example
|
194
|
+
# Gitlab.add_project_hook(42, 'https://api.example.net/v1/webhooks/ci')
|
195
|
+
#
|
196
|
+
# @param [Integer, String] project The ID or path of a project.
|
197
|
+
# @param [String] url The hook URL.
|
198
|
+
# @param [Hash] options A customizable set of options.
|
199
|
+
# @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
|
200
|
+
# @param option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
|
201
|
+
# @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
|
202
|
+
# @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
|
203
|
+
# @return [Gitlab::ObjectifiedHash] Information about added hook.
|
204
|
+
def add_project_hook(project, url, options = {})
|
205
|
+
body = { url: url }.merge(options)
|
206
|
+
post("/projects/#{url_encode project}/hooks", body: body)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Updates a project hook URL.
|
210
|
+
#
|
211
|
+
# @example
|
212
|
+
# Gitlab.edit_project_hook(42, 1, 'https://api.example.net/v1/webhooks/ci')
|
213
|
+
#
|
214
|
+
# @param [Integer, String] project The ID or path of a project.
|
215
|
+
# @param [Integer] id The ID of the hook.
|
216
|
+
# @param [String] url The hook URL.
|
217
|
+
# @param [Hash] options A customizable set of options.
|
218
|
+
# @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
|
219
|
+
# @param option [Boolean] :issues_events Trigger hook on issues events (0 = false, 1 = true)
|
220
|
+
# @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
|
221
|
+
# @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
|
222
|
+
# @return [Gitlab::ObjectifiedHash] Information about updated hook.
|
223
|
+
def edit_project_hook(project, id, url, options = {})
|
224
|
+
body = { url: url }.merge(options)
|
225
|
+
put("/projects/#{url_encode project}/hooks/#{id}", body: body)
|
226
|
+
end
|
227
|
+
|
228
|
+
# Deletes a hook from project.
|
229
|
+
#
|
230
|
+
# @example
|
231
|
+
# Gitlab.delete_project_hook('gitlab', 4)
|
232
|
+
#
|
233
|
+
# @param [Integer, String] project The ID or path of a project.
|
234
|
+
# @param [String] id The ID of the hook.
|
235
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted hook.
|
236
|
+
def delete_project_hook(project, id)
|
237
|
+
delete("/projects/#{url_encode project}/hooks/#{id}")
|
238
|
+
end
|
239
|
+
|
240
|
+
# Gets a project push rule.
|
241
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#show-project-push-rules
|
242
|
+
#
|
243
|
+
# @example
|
244
|
+
# Gitlab.push_rule(42)
|
245
|
+
#
|
246
|
+
# @param [Integer] id The ID of a project.
|
247
|
+
# @return [Gitlab::ObjectifiedHash]
|
248
|
+
def push_rule(id)
|
249
|
+
get("/projects/#{url_encode id}/push_rule")
|
250
|
+
end
|
251
|
+
|
252
|
+
# Adds a project push rule.
|
253
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#add-project-push-rule
|
254
|
+
#
|
255
|
+
# @example
|
256
|
+
# Gitlab.add_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
|
257
|
+
#
|
258
|
+
# @param [Integer] id The ID of a project.
|
259
|
+
# @param [Hash] options A customizable set of options.
|
260
|
+
# @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
|
261
|
+
# @param option [String] :commit_message_regex Commit message regex
|
262
|
+
# @return [Gitlab::ObjectifiedHash] Information about added push rule.
|
263
|
+
def add_push_rule(id, options = {})
|
264
|
+
post("/projects/#{url_encode id}/push_rule", body: options)
|
265
|
+
end
|
266
|
+
|
267
|
+
# Updates a project push rule.
|
268
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#edit-project-push-rule
|
269
|
+
#
|
270
|
+
# @example
|
271
|
+
# Gitlab.edit_push_rule(42, { deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b' })
|
272
|
+
#
|
273
|
+
# @param [Integer] id The ID of a project.
|
274
|
+
# @param [Hash] options A customizable set of options.
|
275
|
+
# @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
|
276
|
+
# @param option [String] :commit_message_regex Commit message regex
|
277
|
+
# @return [Gitlab::ObjectifiedHash] Information about updated push rule.
|
278
|
+
def edit_push_rule(id, options = {})
|
279
|
+
put("/projects/#{url_encode id}/push_rule", body: options)
|
280
|
+
end
|
281
|
+
|
282
|
+
# Deletes a push rule from a project.
|
283
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#delete-project-push-rule
|
284
|
+
#
|
285
|
+
# @example
|
286
|
+
# Gitlab.delete_push_rule(42)
|
287
|
+
#
|
288
|
+
# @param [Integer] id The ID of a project.
|
289
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
|
290
|
+
def delete_push_rule(id)
|
291
|
+
delete("/projects/#{url_encode id}/push_rule")
|
292
|
+
end
|
293
|
+
|
294
|
+
# Mark this project as forked from the other
|
295
|
+
#
|
296
|
+
# @example
|
297
|
+
# Gitlab.make_forked(42, 24)
|
298
|
+
#
|
299
|
+
# @param [Integer, String] project The ID or path of a project.
|
300
|
+
# @param [Integer] id The ID of the project it is forked from.
|
301
|
+
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
302
|
+
def make_forked_from(project, id)
|
303
|
+
post("/projects/#{url_encode project}/fork/#{id}")
|
304
|
+
end
|
305
|
+
|
306
|
+
# Remove a forked_from relationship for a project.
|
307
|
+
#
|
308
|
+
# @example
|
309
|
+
# Gitlab.remove_forked(42)
|
310
|
+
#
|
311
|
+
# @param [Integer, String] project The ID or path of a project.
|
312
|
+
# @param [Integer] project The ID of the project it is forked from
|
313
|
+
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
314
|
+
def remove_forked(project)
|
315
|
+
delete("/projects/#{url_encode project}/fork")
|
316
|
+
end
|
317
|
+
|
318
|
+
# Gets a project deploy keys.
|
319
|
+
#
|
320
|
+
# @example
|
321
|
+
# Gitlab.deploy_keys(42)
|
322
|
+
#
|
323
|
+
# @param [Integer, String] project The ID or path of a project.
|
324
|
+
# @param [Hash] options A customizable set of options.
|
325
|
+
# @option options [Integer] :page The page number.
|
326
|
+
# @option options [Integer] :per_page The number of results per page.
|
327
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
328
|
+
def deploy_keys(project, options = {})
|
329
|
+
get("/projects/#{url_encode project}/deploy_keys", query: options)
|
330
|
+
end
|
331
|
+
|
332
|
+
# Gets a single project deploy key.
|
333
|
+
#
|
334
|
+
# @example
|
335
|
+
# Gitlab.deploy_key(42, 1)
|
336
|
+
#
|
337
|
+
# @param [Integer, String] project The ID or path of a project.
|
338
|
+
# @param [Integer] id The ID of a deploy key.
|
339
|
+
# @return [Gitlab::ObjectifiedHash]
|
340
|
+
def deploy_key(project, id)
|
341
|
+
get("/projects/#{url_encode project}/deploy_keys/#{id}")
|
342
|
+
end
|
343
|
+
|
344
|
+
# Creates a new deploy key.
|
345
|
+
#
|
346
|
+
# @example
|
347
|
+
# Gitlab.create_deploy_key(42, 'My Key', 'Key contents', can_push: true)
|
348
|
+
#
|
349
|
+
# @param [Integer, String] project The ID or path of a project.
|
350
|
+
# @param [String] title The title of a deploy key.
|
351
|
+
# @param [String] key The content of a deploy key.
|
352
|
+
# @param [Hash] options A customizable set of options.
|
353
|
+
# @return [Gitlab::ObjectifiedHash] Information about created deploy key.
|
354
|
+
def create_deploy_key(project, title, key, options = {})
|
355
|
+
post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key }.merge(options))
|
356
|
+
end
|
357
|
+
|
358
|
+
# Enables a deploy key at the project.
|
359
|
+
#
|
360
|
+
# @example
|
361
|
+
# Gitlab.enable_deploy_key(42, 66)
|
362
|
+
#
|
363
|
+
# @param [Integer, String] project The ID or path of a project.
|
364
|
+
# @param [Integer] key The ID of a deploy key.
|
365
|
+
# @return [Gitlab::ObjectifiedHash] Information about the enabled deploy key.
|
366
|
+
def enable_deploy_key(project, key)
|
367
|
+
post("/projects/#{url_encode project}/deploy_keys/#{key}/enable", body: { id: project, key_id: key })
|
368
|
+
end
|
369
|
+
|
370
|
+
# Disables a deploy key at the project.
|
371
|
+
#
|
372
|
+
# @example
|
373
|
+
# Gitlab.disable_deploy_key(42, 66)
|
374
|
+
#
|
375
|
+
# @param [Integer, String] project The ID or path of a project.
|
376
|
+
# @param [Integer] key The ID of a deploy key.
|
377
|
+
# @return [Gitlab::ObjectifiedHash] Information about the disabled deploy key.
|
378
|
+
def disable_deploy_key(project, key)
|
379
|
+
post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
|
380
|
+
end
|
381
|
+
|
382
|
+
# Deletes a deploy key from project.
|
383
|
+
#
|
384
|
+
# @example
|
385
|
+
# Gitlab.delete_deploy_key(42, 1)
|
386
|
+
#
|
387
|
+
# @param [Integer, String] project The ID or path of a project.
|
388
|
+
# @param [Integer] id The ID of a deploy key.
|
389
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted deploy key.
|
390
|
+
def delete_deploy_key(project, id)
|
391
|
+
delete("/projects/#{url_encode project}/deploy_keys/#{id}")
|
392
|
+
end
|
393
|
+
|
394
|
+
# Forks a project into the user namespace.
|
395
|
+
#
|
396
|
+
# @example
|
397
|
+
# Gitlab.create_fork(42)
|
398
|
+
# Gitlab.create_fork(42, { sudo: 'another_username' })
|
399
|
+
#
|
400
|
+
# @param [Integer, String] project The ID or path of a project.
|
401
|
+
# @param [Hash] options A customizable set of options.
|
402
|
+
# @option options [String] :sudo The username the project will be forked for
|
403
|
+
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
404
|
+
def create_fork(id, options = {})
|
405
|
+
post("/projects/#{url_encode id}/fork", body: options)
|
406
|
+
end
|
407
|
+
|
408
|
+
# Get a list of all visible projects across GitLab for the authenticated user.
|
409
|
+
# When accessed without authentication, only public projects are returned.
|
410
|
+
#
|
411
|
+
# Note: This feature was introduced in GitLab 10.1
|
412
|
+
#
|
413
|
+
# @example
|
414
|
+
# Gitlab.project_forks(42)
|
415
|
+
#
|
416
|
+
# @param [Hash] options A customizable set of options.
|
417
|
+
# @option options [Integer] :page The page number.
|
418
|
+
# @option options [Integer] :per_page The number of results per page.
|
419
|
+
# @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
|
420
|
+
# @option options [String] :sort Return requests sorted in asc or desc order
|
421
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
422
|
+
def project_forks(id, options = {})
|
423
|
+
get("/projects/#{url_encode id}/forks", query: options)
|
424
|
+
end
|
425
|
+
|
426
|
+
# Updates an existing project.
|
427
|
+
#
|
428
|
+
# @example
|
429
|
+
# Gitlab.edit_project(42)
|
430
|
+
# Gitlab.edit_project(42, { name: 'Project Name' })
|
431
|
+
# Gitlab.edit_project('project-name', { name: 'New Project Name', path: 'new-project-patth' })
|
432
|
+
#
|
433
|
+
# @param [Integer, String] project The ID or path of a project.
|
434
|
+
# @param [Hash] options A customizable set of options
|
435
|
+
# @option options [String] :name The name of a project
|
436
|
+
# @option options [String] :path The project's repository name, also used in Gitlab's URLs
|
437
|
+
# @option options [String] :description The description to show in Gitlab
|
438
|
+
# (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#edit-project Gitlab docs} for all valid options)
|
439
|
+
#
|
440
|
+
# @return [Gitlab::ObjectifiedHash] Information about the edited project.
|
441
|
+
def edit_project(id, options = {})
|
442
|
+
put("/projects/#{url_encode id}", body: options)
|
443
|
+
end
|
444
|
+
|
445
|
+
# Share project with group.
|
446
|
+
#
|
447
|
+
# @example
|
448
|
+
# Gitlab.share_project_with_group('gitlab', 2, 40)
|
449
|
+
#
|
450
|
+
# @param [Integer, String] project The ID or path of a project.
|
451
|
+
# @param [Integer] id The ID of a group.
|
452
|
+
# @param [Integer] group_access The access level to project.
|
453
|
+
def share_project_with_group(project, id, group_access)
|
454
|
+
post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access })
|
455
|
+
end
|
456
|
+
|
457
|
+
# Unshare project with group.
|
458
|
+
#
|
459
|
+
# @example
|
460
|
+
# Gitlab.unshare_project_with_group('gitlab', 2)
|
461
|
+
#
|
462
|
+
# @param [Integer, String] project The ID or path of a project.
|
463
|
+
# @param [Integer] id The ID of a group.
|
464
|
+
# @return [void] This API call returns an empty response body.
|
465
|
+
def unshare_project_with_group(project, id)
|
466
|
+
delete("/projects/#{url_encode project}/share/#{id}")
|
467
|
+
end
|
468
|
+
|
469
|
+
# Stars a project.
|
470
|
+
# @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
|
471
|
+
#
|
472
|
+
# @example
|
473
|
+
# Gitlab.star_project(42)
|
474
|
+
# Gitlab.star_project('gitlab-org/gitlab-ce')
|
475
|
+
#
|
476
|
+
# @param [Integer, String] id The ID or path of a project.
|
477
|
+
# @return [Gitlab::ObjectifiedHash] Information about starred project.
|
478
|
+
def star_project(id)
|
479
|
+
post("/projects/#{url_encode id}/star")
|
480
|
+
end
|
481
|
+
|
482
|
+
# Unstars a project.
|
483
|
+
# @see https://docs.gitlab.com/ce/api/projects.html#unstar-a-project
|
484
|
+
#
|
485
|
+
# @example
|
486
|
+
# Gitlab.unstar_project(42)
|
487
|
+
# Gitlab.unstar_project('gitlab-org/gitlab-ce')
|
488
|
+
#
|
489
|
+
# @param [Integer, String] id The ID or path of a project.
|
490
|
+
# @return [Gitlab::ObjectifiedHash] Information about unstarred project.
|
491
|
+
def unstar_project(id)
|
492
|
+
delete("/projects/#{url_encode id}/star")
|
493
|
+
end
|
494
|
+
|
495
|
+
# Get a list of visible projects for the given user.
|
496
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
|
497
|
+
#
|
498
|
+
# @example
|
499
|
+
# Gitlab.user_projects(1)
|
500
|
+
# Gitlab.user_projects(1, { order_by: 'last_activity_at' })
|
501
|
+
# Gitlab.user_projects('username', { order_by: 'name', sort: 'asc' })
|
502
|
+
#
|
503
|
+
# @param [Integer, String] user_id The ID or username of the user.
|
504
|
+
# @param [Hash] options A customizable set of options.
|
505
|
+
# @option options [String] :per_page Number of projects to return per page
|
506
|
+
# @option options [String] :page The page to retrieve
|
507
|
+
# @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
|
508
|
+
# @option options [String] :sort Return projects sorted in asc or desc order.
|
509
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
510
|
+
def user_projects(user_id, options = {})
|
511
|
+
get("/users/#{url_encode user_id}/projects", query: options)
|
512
|
+
end
|
513
|
+
|
514
|
+
# Uploads a file to the specified project to be used in an issue or
|
515
|
+
# merge request description, or a comment.
|
516
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#upload-a-file
|
517
|
+
#
|
518
|
+
# @example
|
519
|
+
# Gitlab.upload_file(1, File.open(File::NULL, 'r'))
|
520
|
+
# File.open('myfile') { |file| Gitlab.upload_file(1, file) }
|
521
|
+
#
|
522
|
+
# @param [Integer, String] id The ID or path of a project.
|
523
|
+
# @param [File] The file you are interested to upload.
|
524
|
+
# @return [Gitlab::ObjectifiedHash]
|
525
|
+
def upload_file(id, file)
|
526
|
+
post("/projects/#{url_encode id}/uploads", body: { file: file })
|
506
527
|
end
|
507
528
|
end
|