gitlab 4.5.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +0 -267
  3. data/LICENSE.txt +1 -1
  4. data/README.md +40 -30
  5. data/exe/gitlab +5 -1
  6. data/lib/gitlab/api.rb +7 -3
  7. data/lib/gitlab/cli.rb +13 -9
  8. data/lib/gitlab/cli_helpers.rb +49 -45
  9. data/lib/gitlab/client/access_requests.rb +10 -1
  10. data/lib/gitlab/client/application_settings.rb +172 -0
  11. data/lib/gitlab/client/avatar.rb +21 -0
  12. data/lib/gitlab/client/award_emojis.rb +5 -3
  13. data/lib/gitlab/client/boards.rb +62 -4
  14. data/lib/gitlab/client/branches.rb +47 -8
  15. data/lib/gitlab/client/broadcast_messages.rb +75 -0
  16. data/lib/gitlab/client/build_variables.rb +19 -12
  17. data/lib/gitlab/client/builds.rb +13 -11
  18. data/lib/gitlab/client/commits.rb +73 -21
  19. data/lib/gitlab/client/container_registry.rb +85 -0
  20. data/lib/gitlab/client/deployments.rb +3 -1
  21. data/lib/gitlab/client/environments.rb +5 -3
  22. data/lib/gitlab/client/epic_issues.rb +23 -0
  23. data/lib/gitlab/client/epics.rb +73 -0
  24. data/lib/gitlab/client/events.rb +6 -4
  25. data/lib/gitlab/client/features.rb +48 -0
  26. data/lib/gitlab/client/group_badges.rb +88 -0
  27. data/lib/gitlab/client/group_boards.rb +141 -0
  28. data/lib/gitlab/client/group_labels.rb +88 -0
  29. data/lib/gitlab/client/group_milestones.rb +7 -6
  30. data/lib/gitlab/client/groups.rb +326 -12
  31. data/lib/gitlab/client/issue_links.rb +48 -0
  32. data/lib/gitlab/client/issues.rb +47 -13
  33. data/lib/gitlab/client/jobs.rb +96 -8
  34. data/lib/gitlab/client/keys.rb +13 -0
  35. data/lib/gitlab/client/labels.rb +6 -4
  36. data/lib/gitlab/client/lint.rb +19 -0
  37. data/lib/gitlab/client/markdown.rb +23 -0
  38. data/lib/gitlab/client/merge_request_approvals.rb +164 -9
  39. data/lib/gitlab/client/merge_requests.rb +148 -11
  40. data/lib/gitlab/client/merge_trains.rb +55 -0
  41. data/lib/gitlab/client/milestones.rb +19 -5
  42. data/lib/gitlab/client/namespaces.rb +4 -2
  43. data/lib/gitlab/client/notes.rb +38 -9
  44. data/lib/gitlab/client/packages.rb +95 -0
  45. data/lib/gitlab/client/pipeline_schedules.rb +36 -10
  46. data/lib/gitlab/client/pipeline_triggers.rb +10 -8
  47. data/lib/gitlab/client/pipelines.rb +65 -3
  48. data/lib/gitlab/client/project_badges.rb +85 -0
  49. data/lib/gitlab/client/project_clusters.rb +83 -0
  50. data/lib/gitlab/client/project_exports.rb +54 -0
  51. data/lib/gitlab/client/project_release_links.rb +76 -0
  52. data/lib/gitlab/client/project_releases.rb +90 -0
  53. data/lib/gitlab/client/projects.rb +307 -26
  54. data/lib/gitlab/client/protected_tags.rb +59 -0
  55. data/lib/gitlab/client/remote_mirrors.rb +51 -0
  56. data/lib/gitlab/client/repositories.rb +77 -6
  57. data/lib/gitlab/client/repository_files.rb +21 -3
  58. data/lib/gitlab/client/repository_submodules.rb +27 -0
  59. data/lib/gitlab/client/resource_label_events.rb +82 -0
  60. data/lib/gitlab/client/resource_state_events.rb +57 -0
  61. data/lib/gitlab/client/runners.rb +170 -18
  62. data/lib/gitlab/client/search.rb +66 -0
  63. data/lib/gitlab/client/services.rb +4 -1
  64. data/lib/gitlab/client/sidekiq.rb +2 -0
  65. data/lib/gitlab/client/snippets.rb +5 -3
  66. data/lib/gitlab/client/system_hooks.rb +9 -7
  67. data/lib/gitlab/client/tags.rb +10 -9
  68. data/lib/gitlab/client/templates.rb +100 -0
  69. data/lib/gitlab/client/todos.rb +7 -5
  70. data/lib/gitlab/client/user_snippets.rb +114 -0
  71. data/lib/gitlab/client/users.rb +302 -31
  72. data/lib/gitlab/client/versions.rb +18 -0
  73. data/lib/gitlab/client/wikis.rb +79 -0
  74. data/lib/gitlab/client.rb +48 -9
  75. data/lib/gitlab/configuration.rb +9 -6
  76. data/lib/gitlab/error.rb +73 -3
  77. data/lib/gitlab/file_response.rb +4 -2
  78. data/lib/gitlab/headers/page_links.rb +37 -0
  79. data/lib/gitlab/headers/total.rb +29 -0
  80. data/lib/gitlab/help.rb +16 -16
  81. data/lib/gitlab/objectified_hash.rb +27 -10
  82. data/lib/gitlab/paginated_response.rb +43 -25
  83. data/lib/gitlab/request.rb +51 -37
  84. data/lib/gitlab/shell.rb +6 -4
  85. data/lib/gitlab/shell_history.rb +11 -13
  86. data/lib/gitlab/version.rb +3 -1
  87. data/lib/gitlab.rb +23 -9
  88. metadata +59 -45
  89. data/.gitignore +0 -22
  90. data/CONTRIBUTING.md +0 -195
  91. data/Gemfile +0 -4
  92. data/Rakefile +0 -17
  93. data/bin/console +0 -10
  94. data/bin/setup +0 -6
  95. data/gitlab.gemspec +0 -33
  96. data/lib/gitlab/page_links.rb +0 -33
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to merge requests.
3
5
  # @see https://docs.gitlab.com/ce/api/merge_requests.html
@@ -25,7 +27,7 @@ class Gitlab::Client
25
27
  # @option options [Integer] :page The page number.
26
28
  # @option options [Integer] :per_page The number of results per page.
27
29
  # @return [Array<Gitlab::ObjectifiedHash>]
28
- def merge_requests(project, options={})
30
+ def merge_requests(project, options = {})
29
31
  get("/projects/#{url_encode project}/merge_requests", query: options)
30
32
  end
31
33
 
@@ -33,12 +35,71 @@ class Gitlab::Client
33
35
  #
34
36
  # @example
35
37
  # Gitlab.merge_request(5, 36)
38
+ # Gitlab.merge_request(5, 36, { include_diverged_commits_count: true })
36
39
  #
37
40
  # @param [Integer, String] project The ID or name of a project.
38
41
  # @param [Integer] id The ID of a merge request.
42
+ # @option options [Boolean] :render_html If true response includes rendered HTML for title and description.
43
+ # @option options [Boolean] :include_diverged_commits_count If true response includes the commits behind the target branch.
44
+ # @option options [Boolean] :include_rebase_in_progress If true response includes whether a rebase operation is in progress.
39
45
  # @return <Gitlab::ObjectifiedHash]
40
- def merge_request(project, id)
41
- get("/projects/#{url_encode project}/merge_requests/#{id}")
46
+ def merge_request(project, id, options = {})
47
+ get("/projects/#{url_encode project}/merge_requests/#{id}", query: options)
48
+ end
49
+
50
+ # Gets a list of merge request pipelines.
51
+ #
52
+ # @example
53
+ # Gitlab.merge_request_pipelines(5, 36)
54
+ #
55
+ # @param [Integer, String] project The ID or name of a project.
56
+ # @param [Integer] id The ID of a merge request.
57
+ # @return [Array<Gitlab::ObjectifiedHash>]
58
+ def merge_request_pipelines(project, id)
59
+ get("/projects/#{url_encode project}/merge_requests/#{id}/pipelines")
60
+ end
61
+
62
+ # Shows information about the merge request dependencies that must be resolved before merging.
63
+ #
64
+ # @example
65
+ # Gitlab.merge_request_dependencies(5, 36)
66
+ #
67
+ # @param [Integer, String] project The ID or name of a project.
68
+ # @param [Integer] id The ID of a merge request.
69
+ # @return [Array<Gitlab::ObjectifiedHash>]
70
+ def merge_request_dependencies(project, id)
71
+ get("/projects/#{url_encode project}/merge_requests/#{id}/blocks")
72
+ end
73
+
74
+ # Create a new pipeline for a merge request.
75
+ # A pipeline created via this endpoint doesnt run a regular branch/tag pipeline.
76
+ # It requires .gitlab-ci.yml to be configured with only: [merge_requests] to create jobs.
77
+ #
78
+ # The new pipeline can be:
79
+ #
80
+ # A detached merge request pipeline.
81
+ # A pipeline for merged results if the project setting is enabled.
82
+ #
83
+ # @example
84
+ # Gitlab.create_merge_request_pipeline(5, 36)
85
+ #
86
+ # @param [Integer, String] project The ID or name of a project.
87
+ # @param [Integer] iid The internal ID of a merge request.
88
+ # @return [Gitlab::ObjectifiedHash]
89
+ def create_merge_request_pipeline(project, iid)
90
+ post("/projects/#{url_encode project}/merge_requests/#{iid}/pipelines")
91
+ end
92
+
93
+ # Get a list of merge request participants.
94
+ #
95
+ # @example
96
+ # Gitlab.merge_request_participants(5, 36)
97
+ #
98
+ # @param [Integer, String] project The ID or name of a project.
99
+ # @param [Integer] id The ID of a merge request.
100
+ # @return [Array<Gitlab::ObjectifiedHash>]
101
+ def merge_request_participants(project, id)
102
+ get("/projects/#{url_encode project}/merge_requests/#{id}/participants")
42
103
  end
43
104
 
44
105
  # Creates a merge request.
@@ -55,10 +116,16 @@ class Gitlab::Client
55
116
  # @option options [String] :source_branch (required) The source branch name.
56
117
  # @option options [String] :target_branch (required) The target branch name.
57
118
  # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
119
+ # @option options [Array<Integer>] :assignee_ids (optional) The ID of the user(s) to assign the MR to. Set to 0 or provide an empty value to unassign all assignees.
120
+ # @option options [String] :description (optional) Description of MR. Limited to 1,048,576 characters.
58
121
  # @option options [Integer] :target_project_id (optional) The target project ID.
59
122
  # @option options [String] :labels (optional) Labels as a comma-separated list.
123
+ # @option options [Integer] :milestone_id (optional) The global ID of a milestone
124
+ # @option options [Boolean] :remove_source_branch (optional) Flag indicating if a merge request should remove the source branch when merging
125
+ # @option options [Boolean] :allow_collaboration (optional) Allow commits from members who can merge to the target branch
126
+ # @option options [Boolean] :squash (optional) Squash commits into a single commit when merging
60
127
  # @return [Gitlab::ObjectifiedHash] Information about created merge request.
61
- def create_merge_request(project, title, options={})
128
+ def create_merge_request(project, title, options = {})
62
129
  body = { title: title }.merge(options)
63
130
  post("/projects/#{url_encode project}/merge_requests", body: body)
64
131
  end
@@ -77,7 +144,7 @@ class Gitlab::Client
77
144
  # @option options [Integer] :assignee_id The ID of a user to assign merge request.
78
145
  # @option options [String] :state_event New state (close|reopen|merge).
79
146
  # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
80
- def update_merge_request(project, id, options={})
147
+ def update_merge_request(project, id, options = {})
81
148
  put("/projects/#{url_encode project}/merge_requests/#{id}", body: options)
82
149
  end
83
150
 
@@ -89,9 +156,14 @@ class Gitlab::Client
89
156
  # @param [Integer, String] project The ID or name of a project.
90
157
  # @param [Integer] id The ID of a merge request.
91
158
  # @param [Hash] options A customizable set of options.
92
- # @option options [String] :merge_commit_message Custom merge commit message
159
+ # @option options [String] :merge_commit_message(optional) Custom merge commit message
160
+ # @option options [String] :squash_commit_message(optional) Custom squash commit message
161
+ # @option options [Boolean] :squash(optional) if true the commits will be squashed into a single commit on merge
162
+ # @option options [Boolean] :should_remove_source_branch(optional) if true removes the source branch
163
+ # @option options [Boolean] :merge_when_pipeline_succeeds(optional) if true the MR is merged when the pipeline succeeds
164
+ # @option options [String] :sha(optional) if present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail
93
165
  # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
94
- def accept_merge_request(project, id, options={})
166
+ def accept_merge_request(project, id, options = {})
95
167
  put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
96
168
  end
97
169
 
@@ -127,7 +199,7 @@ class Gitlab::Client
127
199
  # @param [Integer] project The ID of a project
128
200
  # @param [Integer] iid The internal ID of a merge request
129
201
  def merge_request_closes_issues(project_id, merge_request_iid)
130
- get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
202
+ get("/projects/#{url_encode project_id}/merge_requests/#{merge_request_iid}/closes_issues")
131
203
  end
132
204
 
133
205
  # Subscribes to a merge request.
@@ -163,9 +235,11 @@ class Gitlab::Client
163
235
  # Gitlab.merge_request_discussions('gitlab', 1)
164
236
  # @param [Integer, String] project The ID or name of a project.
165
237
  # @param [Integer] id The ID of a merge request.
238
+ # @option options [Integer] :page The page number.
239
+ # @option options [Integer] :per_page The number of results per page.
166
240
  # @return [Gitlab::ObjectifiedHash] List of the merge request discussions.
167
- def merge_request_discussions(project, merge_request_id)
168
- get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions")
241
+ def merge_request_discussions(project, merge_request_id, options = {})
242
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", query: options)
169
243
  end
170
244
 
171
245
  # Get single merge request discussion
@@ -205,7 +279,7 @@ class Gitlab::Client
205
279
  # * :x (Integer) X coordinate (for 'image' diff notes)
206
280
  # * :y (Integer) Y coordinate (for 'image' diff notes)
207
281
  # @return [Gitlab::ObjectifiedHash] The created merge request discussion.
208
- def create_merge_request_discussion(project, merge_request_id, options={})
282
+ def create_merge_request_discussion(project, merge_request_id, options = {})
209
283
  post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", body: options)
210
284
  end
211
285
 
@@ -271,5 +345,68 @@ class Gitlab::Client
271
345
  def delete_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id)
272
346
  delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}")
273
347
  end
348
+
349
+ # Delete a merge request
350
+ #
351
+ # @example
352
+ # Gitlab.delete_merge_request(5, 1)
353
+ # Gitlab.delete_merge_request('gitlab', 1)
354
+ # @param [Integer, String] project The ID or name of a project.
355
+ # @param [Integer] id The ID of a merge request.
356
+ # @return [Gitlab::ObjectifiedHash] An empty response.
357
+ def delete_merge_request(project, merge_request_id)
358
+ delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}")
359
+ end
360
+
361
+ # Gets a list of merge request diffs
362
+ #
363
+ # @example
364
+ # Gitlab.merge_request_diffs(5, 1)
365
+ # Gitlab.merge_request_diffs('gitlab', 1)
366
+ # @param [Integer, String] project The ID or name of a project.
367
+ # @param [Integer] id The ID of a merge request.
368
+ # @return [Gitlab::ObjectifiedHash] A list of the merge request diffs.
369
+ def merge_request_diffs(project, merge_request_id)
370
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/diffs")
371
+ end
372
+
373
+ # Gets a list of merge request diff versions
374
+ #
375
+ # @example
376
+ # Gitlab.merge_request_versions(5, 1)
377
+ # Gitlab.merge_request_versions('gitlab', 1)
378
+ # @param [Integer, String] project The ID or name of a project.
379
+ # @param [Integer] id The ID of a merge request.
380
+ # @return [Gitlab::ObjectifiedHash] A list of the merge request versions.
381
+ def merge_request_diff_versions(project, merge_request_id)
382
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions")
383
+ end
384
+
385
+ # Gets the diff a single merge request diff version\
386
+ #
387
+ # @example
388
+ # Gitlab.merge_request_diff_version(5, 1, 1)
389
+ # Gitlab.merge_request_diff_version('gitlab', 1, 1)
390
+ # @param [Integer, String] project The ID or name of a project.
391
+ # @param [Integer] id The ID of a merge request.
392
+ # @param [Integer] id The ID of a merge request diff version.
393
+ # @return [Gitlab::ObjectifiedHash] Record of the specific diff
394
+ def merge_request_diff_version(project, merge_request_id, version_id)
395
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions/#{version_id}")
396
+ end
397
+
398
+ # Rebase a merge request.
399
+ #
400
+ # @example
401
+ # Gitlab.rebase_merge_request(5, 42, { skip_ci: true })
402
+ #
403
+ # @param [Integer, String] project The ID or name of a project.
404
+ # @param [Integer] id The ID of a merge request.
405
+ # @param [Hash] options A customizable set of options.
406
+ # @option options [String] :skip_ci Set to true to skip creating a CI pipeline
407
+ # @return [Gitlab::ObjectifiedHash] Rebase progress status
408
+ def rebase_merge_request(project, id, options = {})
409
+ put("/projects/#{url_encode project}/merge_requests/#{id}/rebase", body: options)
410
+ end
274
411
  end
275
412
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to merge trains.
5
+ # @see https://docs.gitlab.com/ee/api/merge_trains.html
6
+ module MergeTrains
7
+ # Get list of merge trains for a project.
8
+ #
9
+ # @example
10
+ # Gitlab.merge_trains(1, scope: :active, sort: :asc)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @param [Hash] options A customizable set of options.
14
+ # @option options [String] :scope The scope of merge trains to return, one of: :active, :complete
15
+ # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def merge_trains(project, options = {})
18
+ get("/projects/#{url_encode project}/merge_trains", query: options)
19
+ end
20
+
21
+ # Get all merge requests added to a merge train for the requested target branch.
22
+ #
23
+ # @param [Integer, String] project The ID or name of a project.
24
+ # @param [String] target_branch The target branch of the merge train.
25
+ # @param [Hash] options A customizable set of options.
26
+ # @option options [String] :scope The scope of merge trains to return, one of: :active, :complete
27
+ # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
28
+ # @return [Array<Gitlab::ObjectifiedHash>]
29
+ def merge_train_merge_requests(project, target_branch, options = {})
30
+ get("/projects/#{url_encode project}/merge_trains/#{target_branch}", query: options)
31
+ end
32
+
33
+ # Get merge train information for the requested merge request.
34
+ #
35
+ # @param [Integer, String] project The ID or name of a project.
36
+ # @param [Integer] merge_request_iid The IID of the merge request.
37
+ # @return [Gitlab::ObjectifiedHash]
38
+ def merge_train_status(project, merge_request_iid)
39
+ get("/projects/#{url_encode project}/merge_trains/merge_requests/#{merge_request_iid}")
40
+ end
41
+
42
+ # Add a merge request to the merge train targeting the merge request’s target branch.
43
+ #
44
+ # @param [Integer, String] project The ID or name of a project.
45
+ # @param [Integer] merge_request_iid The IID of the merge request.
46
+ # @param [Hash] options A customizable set of options.
47
+ # @option options [Boolean] :when_pipeline_succeeds Add merge request to merge train when pipeline succeeds.
48
+ # @option options [String] :sha If present, the SHA must match the HEAD of the source branch, otherwise the merge fails.
49
+ # @option options [Boolean] :squash If true, the commits are squashed into a single commit on merge.
50
+ # @return [Array<Gitlab::ObjectifiedHash>] <description>
51
+ def add_merge_request_to_merge_train(project, merge_request_iid, options = {})
52
+ post("/projects/#{url_encode project}/merge_trains/merge_requests/#{merge_request_iid}", query: options)
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to milestones.
3
5
  # @see https://docs.gitlab.com/ce/api/milestones.html
@@ -12,7 +14,7 @@ class Gitlab::Client
12
14
  # @option options [Integer] :page The page number.
13
15
  # @option options [Integer] :per_page The number of results per page.
14
16
  # @return [Array<Gitlab::ObjectifiedHash>]
15
- def milestones(project, options={})
17
+ def milestones(project, options = {})
16
18
  get("/projects/#{url_encode project}/milestones", query: options)
17
19
  end
18
20
 
@@ -38,7 +40,7 @@ class Gitlab::Client
38
40
  # @option options [Integer] :page The page number.
39
41
  # @option options [Integer] :per_page The number of results per page.
40
42
  # @return [Array<Gitlab::ObjectifiedHash>]
41
- def milestone_issues(project, milestone, options={})
43
+ def milestone_issues(project, milestone, options = {})
42
44
  get("/projects/#{url_encode project}/milestones/#{milestone}/issues", query: options)
43
45
  end
44
46
 
@@ -52,7 +54,7 @@ class Gitlab::Client
52
54
  # @option options [Integer] :page The page number.
53
55
  # @option options [Integer] :per_page The number of results per page.
54
56
  # @return [Array<Gitlab::ObjectifiedHash>]
55
- def milestone_merge_requests(project, milestone, options={})
57
+ def milestone_merge_requests(project, milestone, options = {})
56
58
  get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options)
57
59
  end
58
60
 
@@ -67,7 +69,7 @@ class Gitlab::Client
67
69
  # @option options [String] :description The description of a milestone.
68
70
  # @option options [String] :due_date The due date of a milestone.
69
71
  # @return [Gitlab::ObjectifiedHash] Information about created milestone.
70
- def create_milestone(project, title, options={})
72
+ def create_milestone(project, title, options = {})
71
73
  body = { title: title }.merge(options)
72
74
  post("/projects/#{url_encode project}/milestones", body: body)
73
75
  end
@@ -85,8 +87,20 @@ class Gitlab::Client
85
87
  # @option options [String] :due_date The due date of a milestone.
86
88
  # @option options [String] :state_event The state of a milestone ('close' or 'activate').
87
89
  # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
88
- def edit_milestone(project, id, options={})
90
+ def edit_milestone(project, id, options = {})
89
91
  put("/projects/#{url_encode project}/milestones/#{id}", body: options)
90
92
  end
93
+
94
+ # Delete a project milestone.
95
+ #
96
+ # @example
97
+ # Gitlab.delete_milestone(5, 2)
98
+ #
99
+ # @param [Integer, String] project The ID or name of a project.
100
+ # @param [Integer] id The ID of a milestone.
101
+ # @return [nil] This API call returns an empty response body.
102
+ def delete_milestone(project, id)
103
+ delete("/projects/#{url_encode project}/milestones/#{id}")
104
+ end
91
105
  end
92
106
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to namespaces
3
5
  # @see https://docs.gitlab.com/ce/api/namespaces.html
@@ -13,8 +15,8 @@ class Gitlab::Client
13
15
  # @options options [Integer] :per_page The number of results per page.
14
16
  # @options opttion [String] :search The string to search for.
15
17
  # @return [Array<Gitlab::ObjectifiedHash>]
16
- def namespaces(options={})
17
- get("/namespaces", query: options)
18
+ def namespaces(options = {})
19
+ get('/namespaces', query: options)
18
20
  end
19
21
  end
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to notes.
3
5
  # @see https://docs.gitlab.com/ce/api/notes.html
@@ -11,7 +13,7 @@ class Gitlab::Client
11
13
  # @option options [Integer] :page The page number.
12
14
  # @option options [Integer] :per_page The number of results per page.
13
15
  # @return [Array<Gitlab::ObjectifiedHash>]
14
- def notes(project, options={})
16
+ def notes(project, options = {})
15
17
  get("/projects/#{url_encode project}/notes", query: options)
16
18
  end
17
19
 
@@ -25,7 +27,7 @@ class Gitlab::Client
25
27
  # @option options [Integer] :page The page number.
26
28
  # @option options [Integer] :per_page The number of results per page.
27
29
  # @return [Array<Gitlab::ObjectifiedHash>]
28
- def issue_notes(project, issue, options={})
30
+ def issue_notes(project, issue, options = {})
29
31
  get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options)
30
32
  end
31
33
 
@@ -39,7 +41,7 @@ class Gitlab::Client
39
41
  # @option options [Integer] :page The page number.
40
42
  # @option options [Integer] :per_page The number of results per page.
41
43
  # @return [Array<Gitlab::ObjectifiedHash>]
42
- def snippet_notes(project, snippet, options={})
44
+ def snippet_notes(project, snippet, options = {})
43
45
  get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options)
44
46
  end
45
47
 
@@ -53,10 +55,24 @@ class Gitlab::Client
53
55
  # @option options [Integer] :page The page number.
54
56
  # @option options [Integer] :per_page The number of results per page.
55
57
  # @return [Array<Gitlab::ObjectifiedHash>]
56
- def merge_request_notes(project, merge_request, options={})
58
+ def merge_request_notes(project, merge_request, options = {})
57
59
  get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
58
60
  end
59
- alias_method :merge_request_comments, :merge_request_notes
61
+ alias merge_request_comments merge_request_notes
62
+
63
+ # Gets a list of notes for an epic.
64
+ #
65
+ # @example
66
+ # Gitlab.epic_notes(5, 10)
67
+ #
68
+ # @param [Integer] project The ID of a group.
69
+ # @param [Integer] epic The ID of an epic.
70
+ # @option options [Integer] :page The page number.
71
+ # @option options [Integer] :per_page The number of results per page.
72
+ # @return [Array<Gitlab::ObjectifiedHash>]
73
+ def epic_notes(group, epic, options = {})
74
+ get("/groups/#{url_encode group}/epics/#{epic}/notes", query: options)
75
+ end
60
76
 
61
77
  # Gets a single wall note.
62
78
  #
@@ -158,7 +174,20 @@ class Gitlab::Client
158
174
  def create_merge_request_note(project, merge_request, body)
159
175
  post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
160
176
  end
161
- alias_method :create_merge_request_comment, :create_merge_request_note
177
+ alias create_merge_request_comment create_merge_request_note
178
+
179
+ # Creates a new epic note.
180
+ #
181
+ # @example
182
+ # Gitlab.create_epic_note(6, 1, 'Adding a note to my epic.')
183
+ #
184
+ # @param [Integer, String] group The ID or name of a group.
185
+ # @param [Integer] epic The ID of an epic.
186
+ # @param [String] body The body of a note.
187
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
188
+ def create_epic_note(group, epic, body)
189
+ post("/groups/#{url_encode group}/epics/#{epic}/notes", body: { body: body })
190
+ end
162
191
 
163
192
  # Deletes a wall note.
164
193
  #
@@ -210,7 +239,7 @@ class Gitlab::Client
210
239
  def delete_merge_request_note(project, merge_request, id)
211
240
  delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
212
241
  end
213
- alias_method :delete_merge_request_comment, :delete_merge_request_note
242
+ alias delete_merge_request_comment delete_merge_request_note
214
243
 
215
244
  # Modifies a wall note.
216
245
  #
@@ -266,7 +295,7 @@ class Gitlab::Client
266
295
  def edit_merge_request_note(project, merge_request, id, body)
267
296
  put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: note_content(body))
268
297
  end
269
- alias_method :edit_merge_request_comment, :edit_merge_request_note
298
+ alias edit_merge_request_comment edit_merge_request_note
270
299
 
271
300
  private
272
301
 
@@ -274,7 +303,7 @@ class Gitlab::Client
274
303
  # in the 'else'.
275
304
  def note_content(body)
276
305
  if body.is_a?(Hash)
277
- STDERR.puts "Passing the note body as a Hash is deprecated. You should just pass the String."
306
+ warn 'Passing the note body as a Hash is deprecated. You should just pass the String.'
278
307
  body
279
308
  else
280
309
  { body: body }
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to GitLab Packages.
5
+ # @see https://docs.gitlab.com/ee/api/packages.html
6
+ module Packages
7
+ # Gets a list of project packages.
8
+ #
9
+ # @example
10
+ # Gitlab.project_packages(5)
11
+ # Gitlab.project_packages(5, { package_type: 'npm', sort: 'desc' })
12
+ #
13
+ # @param [Integer, String] :project the ID or name of a project.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
16
+ # @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
17
+ # @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
18
+ # @options options [String] :package_name Filter the project packages with a fuzzy search by name.
19
+ # @options options [String] :include_versionless When set to true, versionless packages are included in the response.
20
+ # @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
21
+ # @return [Array<Gitlab::ObjectifiedHash>]
22
+ def project_packages(project, options = {})
23
+ get("/projects/#{url_encode project}/packages", query: options)
24
+ end
25
+
26
+ # Gets a list of project packages.
27
+ #
28
+ # @example
29
+ # Gitlab.group_packages(5)
30
+ # Gitlab.group_packages(5, { package_type: 'npm', sort: 'desc' })
31
+ #
32
+ # @param [Integer, String] project the ID or name of a project.
33
+ # @param [Hash] options A customizable set of options.
34
+ # @options options [String] :exclude_subgroups If the parameter is included as true, packages from projects from subgroups are not listed. Default is false.
35
+ # @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
36
+ # @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
37
+ # @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
38
+ # @options options [String] :package_name Filter the project packages with a fuzzy search by name.
39
+ # @options options [String] :include_versionless When set to true, versionless packages are included in the response.
40
+ # @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
41
+ # @return [Array<Gitlab::ObjectifiedHash>]
42
+ def group_packages(group, options = {})
43
+ get("/groups/#{url_encode group}/packages", query: options)
44
+ end
45
+
46
+ # Get a single project package.
47
+ #
48
+ # @example
49
+ # Gitlab.project_package(5, 3)
50
+ #
51
+ # @param [Integer, String] project The ID or name of a project.
52
+ # @param [Integer] id ID of a package.
53
+ # @return [Gitlab::ObjectifiedHash]
54
+ def project_package(project, id)
55
+ get("/projects/#{url_encode project}/packages/#{id}")
56
+ end
57
+
58
+ # Get a list of package files of a single package.
59
+ #
60
+ # @example
61
+ # Gitlab.project_package_files(5, 3)
62
+ #
63
+ # @param [Integer, String] project The ID or name of a project.
64
+ # @param [Integer] id ID of a package.
65
+ # @return [Array<Gitlab::ObjectifiedHash>]
66
+ def project_package_files(project, id)
67
+ get("/projects/#{url_encode project}/packages/#{id}/package_files")
68
+ end
69
+
70
+ # Deletes a project package.
71
+ #
72
+ # @example
73
+ # Gitlab.delete_project_package(5, 3)
74
+ #
75
+ # @param [Integer, String] project The ID or name of a project.
76
+ # @param [Integer] id ID of a package.
77
+ # @return [void] This API call returns an empty response body.
78
+ def delete_project_package(project, id)
79
+ delete("/projects/#{url_encode project}/packages/#{id}")
80
+ end
81
+
82
+ # Delete a package file.
83
+ #
84
+ # @example
85
+ # Gitlab.delete_project_file(5, 3, 1)
86
+ #
87
+ # @param [Integer, String] project The ID or name of a project.
88
+ # @param [Integer] package_id ID of a package.
89
+ # @param [Integer] file_id ID of a package file.
90
+ # @return [void] This API call returns an empty response body.
91
+ def delete_project_package_file(project, package_id, file_id)
92
+ delete("/projects/#{url_encode project}/packages/#{package_id}/package_files/#{file_id}")
93
+ end
94
+ end
95
+ end