gitlab 4.5.0 → 4.6.0

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