gitlab 4.6.0 → 4.6.1

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