gitlab-faraday 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 (79) hide show
  1. checksums.yaml +7 -0
  2. data/lib/gitlab/api.rb +16 -0
  3. data/lib/gitlab/client/access_requests.rb +103 -0
  4. data/lib/gitlab/client/application_settings.rb +172 -0
  5. data/lib/gitlab/client/avatar.rb +21 -0
  6. data/lib/gitlab/client/award_emojis.rb +137 -0
  7. data/lib/gitlab/client/boards.rb +146 -0
  8. data/lib/gitlab/client/branches.rb +135 -0
  9. data/lib/gitlab/client/broadcast_messages.rb +75 -0
  10. data/lib/gitlab/client/build_variables.rb +135 -0
  11. data/lib/gitlab/client/builds.rb +108 -0
  12. data/lib/gitlab/client/commits.rb +216 -0
  13. data/lib/gitlab/client/container_registry.rb +90 -0
  14. data/lib/gitlab/client/deployments.rb +34 -0
  15. data/lib/gitlab/client/environments.rb +89 -0
  16. data/lib/gitlab/client/epic_issues.rb +23 -0
  17. data/lib/gitlab/client/epics.rb +73 -0
  18. data/lib/gitlab/client/events.rb +60 -0
  19. data/lib/gitlab/client/features.rb +48 -0
  20. data/lib/gitlab/client/group_badges.rb +88 -0
  21. data/lib/gitlab/client/group_boards.rb +141 -0
  22. data/lib/gitlab/client/group_labels.rb +88 -0
  23. data/lib/gitlab/client/group_milestones.rb +94 -0
  24. data/lib/gitlab/client/groups.rb +526 -0
  25. data/lib/gitlab/client/issue_links.rb +48 -0
  26. data/lib/gitlab/client/issues.rb +242 -0
  27. data/lib/gitlab/client/jobs.rb +250 -0
  28. data/lib/gitlab/client/keys.rb +29 -0
  29. data/lib/gitlab/client/labels.rb +88 -0
  30. data/lib/gitlab/client/lint.rb +19 -0
  31. data/lib/gitlab/client/markdown.rb +23 -0
  32. data/lib/gitlab/client/merge_request_approvals.rb +265 -0
  33. data/lib/gitlab/client/merge_requests.rb +415 -0
  34. data/lib/gitlab/client/merge_trains.rb +55 -0
  35. data/lib/gitlab/client/milestones.rb +106 -0
  36. data/lib/gitlab/client/namespaces.rb +22 -0
  37. data/lib/gitlab/client/notes.rb +313 -0
  38. data/lib/gitlab/client/packages.rb +95 -0
  39. data/lib/gitlab/client/pipeline_schedules.rb +159 -0
  40. data/lib/gitlab/client/pipeline_triggers.rb +103 -0
  41. data/lib/gitlab/client/pipelines.rb +130 -0
  42. data/lib/gitlab/client/project_badges.rb +85 -0
  43. data/lib/gitlab/client/project_clusters.rb +83 -0
  44. data/lib/gitlab/client/project_exports.rb +54 -0
  45. data/lib/gitlab/client/project_release_links.rb +76 -0
  46. data/lib/gitlab/client/project_releases.rb +90 -0
  47. data/lib/gitlab/client/projects.rb +792 -0
  48. data/lib/gitlab/client/protected_tags.rb +59 -0
  49. data/lib/gitlab/client/remote_mirrors.rb +90 -0
  50. data/lib/gitlab/client/repositories.rb +130 -0
  51. data/lib/gitlab/client/repository_files.rb +131 -0
  52. data/lib/gitlab/client/repository_submodules.rb +27 -0
  53. data/lib/gitlab/client/resource_label_events.rb +82 -0
  54. data/lib/gitlab/client/resource_state_events.rb +57 -0
  55. data/lib/gitlab/client/runners.rb +278 -0
  56. data/lib/gitlab/client/search.rb +66 -0
  57. data/lib/gitlab/client/services.rb +53 -0
  58. data/lib/gitlab/client/sidekiq.rb +39 -0
  59. data/lib/gitlab/client/snippets.rb +95 -0
  60. data/lib/gitlab/client/system_hooks.rb +64 -0
  61. data/lib/gitlab/client/tags.rb +97 -0
  62. data/lib/gitlab/client/templates.rb +100 -0
  63. data/lib/gitlab/client/todos.rb +46 -0
  64. data/lib/gitlab/client/user_snippets.rb +114 -0
  65. data/lib/gitlab/client/users.rb +521 -0
  66. data/lib/gitlab/client/versions.rb +18 -0
  67. data/lib/gitlab/client/wikis.rb +79 -0
  68. data/lib/gitlab/client.rb +96 -0
  69. data/lib/gitlab/configuration.rb +36 -0
  70. data/lib/gitlab/error.rb +114 -0
  71. data/lib/gitlab/file_response.rb +43 -0
  72. data/lib/gitlab/headers/page_links.rb +32 -0
  73. data/lib/gitlab/headers/total.rb +24 -0
  74. data/lib/gitlab/objectified_hash.rb +44 -0
  75. data/lib/gitlab/paginated_response.rb +114 -0
  76. data/lib/gitlab/request.rb +144 -0
  77. data/lib/gitlab/version.rb +5 -0
  78. data/lib/gitlab.rb +36 -0
  79. metadata +156 -0
@@ -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
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to milestones.
5
+ # @see https://docs.gitlab.com/ce/api/milestones.html
6
+ module Milestones
7
+ # Gets a list of project's milestones.
8
+ #
9
+ # @example
10
+ # Gitlab.milestones(5)
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 [Integer] :page The page number.
15
+ # @option options [Integer] :per_page The number of results per page.
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def milestones(project, options = {})
18
+ get("/projects/#{url_encode project}/milestones", query: options)
19
+ end
20
+
21
+ # Gets a single milestone.
22
+ #
23
+ # @example
24
+ # Gitlab.milestone(5, 36)
25
+ #
26
+ # @param [Integer, String] project The ID or name of a project.
27
+ # @param [Integer] id The ID of a milestone.
28
+ # @return [Gitlab::ObjectifiedHash]
29
+ def milestone(project, id)
30
+ get("/projects/#{url_encode project}/milestones/#{id}")
31
+ end
32
+
33
+ # Gets the issues of a given milestone.
34
+ #
35
+ # @example
36
+ # Gitlab.milestone_issues(5, 2)
37
+ #
38
+ # @param [Integer, String] project The ID or name of a project.
39
+ # @param [Integer, String] milestone The ID of a milestone.
40
+ # @option options [Integer] :page The page number.
41
+ # @option options [Integer] :per_page The number of results per page.
42
+ # @return [Array<Gitlab::ObjectifiedHash>]
43
+ def milestone_issues(project, milestone, options = {})
44
+ get("/projects/#{url_encode project}/milestones/#{milestone}/issues", query: options)
45
+ end
46
+
47
+ # Gets the merge_requests of a given milestone.
48
+ #
49
+ # @example
50
+ # Gitlab.milestone_merge_requests(5, 2)
51
+ #
52
+ # @param [Integer, String] project The ID or name of a project.
53
+ # @param [Integer, String] milestone The ID of a milestone.
54
+ # @option options [Integer] :page The page number.
55
+ # @option options [Integer] :per_page The number of results per page.
56
+ # @return [Array<Gitlab::ObjectifiedHash>]
57
+ def milestone_merge_requests(project, milestone, options = {})
58
+ get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options)
59
+ end
60
+
61
+ # Creates a new milestone.
62
+ #
63
+ # @example
64
+ # Gitlab.create_milestone(5, 'v1.0')
65
+ #
66
+ # @param [Integer, String] project The ID or name of a project.
67
+ # @param [String] title The title of a milestone.
68
+ # @param [Hash] options A customizable set of options.
69
+ # @option options [String] :description The description of a milestone.
70
+ # @option options [String] :due_date The due date of a milestone.
71
+ # @return [Gitlab::ObjectifiedHash] Information about created milestone.
72
+ def create_milestone(project, title, options = {})
73
+ body = { title: title }.merge(options)
74
+ post("/projects/#{url_encode project}/milestones", body: body)
75
+ end
76
+
77
+ # Updates a milestone.
78
+ #
79
+ # @example
80
+ # Gitlab.edit_milestone(5, 2, { state_event: 'activate' })
81
+ #
82
+ # @param [Integer, String] project The ID or name of a project.
83
+ # @param [Integer] id The ID of a milestone.
84
+ # @param [Hash] options A customizable set of options.
85
+ # @option options [String] :title The title of a milestone.
86
+ # @option options [String] :description The description of a milestone.
87
+ # @option options [String] :due_date The due date of a milestone.
88
+ # @option options [String] :state_event The state of a milestone ('close' or 'activate').
89
+ # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
90
+ def edit_milestone(project, id, options = {})
91
+ put("/projects/#{url_encode project}/milestones/#{id}", body: options)
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
105
+ end
106
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to namespaces
5
+ # @see https://docs.gitlab.com/ce/api/namespaces.html
6
+ module Namespaces
7
+ # Gets a list of namespaces.
8
+ # @see https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces
9
+ #
10
+ # @example
11
+ # Gitlab.namespaces
12
+ #
13
+ # @param [Hash] options A customizable set of options.
14
+ # @options options [Integer] :page The page number.
15
+ # @options options [Integer] :per_page The number of results per page.
16
+ # @options opttion [String] :search The string to search for.
17
+ # @return [Array<Gitlab::ObjectifiedHash>]
18
+ def namespaces(options = {})
19
+ get('/namespaces', query: options)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to notes.
5
+ # @see https://docs.gitlab.com/ce/api/notes.html
6
+ module Notes
7
+ # Gets a list of projects notes.
8
+ #
9
+ # @example
10
+ # Gitlab.notes(5)
11
+ #
12
+ # @param [Integer] project The ID of a project.
13
+ # @option options [Integer] :page The page number.
14
+ # @option options [Integer] :per_page The number of results per page.
15
+ # @return [Array<Gitlab::ObjectifiedHash>]
16
+ def notes(project, options = {})
17
+ get("/projects/#{url_encode project}/notes", query: options)
18
+ end
19
+
20
+ # Gets a list of notes for a issue.
21
+ #
22
+ # @example
23
+ # Gitlab.issue_notes(5, 10)
24
+ #
25
+ # @param [Integer] project The ID of a project.
26
+ # @param [Integer] issue The ID of an issue.
27
+ # @option options [Integer] :page The page number.
28
+ # @option options [Integer] :per_page The number of results per page.
29
+ # @return [Array<Gitlab::ObjectifiedHash>]
30
+ def issue_notes(project, issue, options = {})
31
+ get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options)
32
+ end
33
+
34
+ # Gets a list of notes for a snippet.
35
+ #
36
+ # @example
37
+ # Gitlab.snippet_notes(5, 1)
38
+ #
39
+ # @param [Integer] project The ID of a project.
40
+ # @param [Integer] snippet The ID of a snippet.
41
+ # @option options [Integer] :page The page number.
42
+ # @option options [Integer] :per_page The number of results per page.
43
+ # @return [Array<Gitlab::ObjectifiedHash>]
44
+ def snippet_notes(project, snippet, options = {})
45
+ get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options)
46
+ end
47
+
48
+ # Gets a list of notes for a merge request.
49
+ #
50
+ # @example
51
+ # Gitlab.merge_request_notes(5, 1)
52
+ #
53
+ # @param [Integer] project The ID of a project.
54
+ # @param [Integer] merge_request The ID of a merge request.
55
+ # @option options [Integer] :page The page number.
56
+ # @option options [Integer] :per_page The number of results per page.
57
+ # @return [Array<Gitlab::ObjectifiedHash>]
58
+ def merge_request_notes(project, merge_request, options = {})
59
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
60
+ end
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
76
+
77
+ # Gets a single wall note.
78
+ #
79
+ # @example
80
+ # Gitlab.note(5, 15)
81
+ #
82
+ # @param [Integer] project The ID of a project.
83
+ # @param [Integer] id The ID of a note.
84
+ # @return [Gitlab::ObjectifiedHash]
85
+ def note(project, id)
86
+ get("/projects/#{url_encode project}/notes/#{id}")
87
+ end
88
+
89
+ # Gets a single issue note.
90
+ #
91
+ # @example
92
+ # Gitlab.issue_note(5, 10, 1)
93
+ #
94
+ # @param [Integer] project The ID of a project.
95
+ # @param [Integer] issue The ID of an issue.
96
+ # @param [Integer] id The ID of a note.
97
+ # @return [Gitlab::ObjectifiedHash]
98
+ def issue_note(project, issue, id)
99
+ get("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
100
+ end
101
+
102
+ # Gets a single snippet note.
103
+ #
104
+ # @example
105
+ # Gitlab.snippet_note(5, 11, 3)
106
+ #
107
+ # @param [Integer] project The ID of a project.
108
+ # @param [Integer] snippet The ID of a snippet.
109
+ # @param [Integer] id The ID of a note.
110
+ # @return [Gitlab::ObjectifiedHash]
111
+ def snippet_note(project, snippet, id)
112
+ get("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
113
+ end
114
+
115
+ # Gets a single merge_request note.
116
+ #
117
+ # @example
118
+ # Gitlab.merge_request_note(5, 11, 3)
119
+ #
120
+ # @param [Integer] project The ID of a project.
121
+ # @param [Integer] merge_request The ID of a merge_request.
122
+ # @param [Integer] id The ID of a note.
123
+ # @return [Gitlab::ObjectifiedHash]
124
+ def merge_request_note(project, merge_request, id)
125
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
126
+ end
127
+
128
+ # Creates a new wall note.
129
+ #
130
+ # @example
131
+ # Gitlab.create_note(5, 'This is a wall note!')
132
+ #
133
+ # @param [Integer, String] project The ID or name of a project.
134
+ # @param [String] body The body of a note.
135
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
136
+ def create_note(project, body)
137
+ post("/projects/#{url_encode project}/notes", body: { body: body })
138
+ end
139
+
140
+ # Creates a new issue note.
141
+ #
142
+ # @example
143
+ # Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
144
+ #
145
+ # @param [Integer, String] project The ID or name of a project.
146
+ # @param [Integer] issue The ID of an issue.
147
+ # @param [String] body The body of a note.
148
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
149
+ def create_issue_note(project, issue, body)
150
+ post("/projects/#{url_encode project}/issues/#{issue}/notes", body: { body: body })
151
+ end
152
+
153
+ # Creates a new snippet note.
154
+ #
155
+ # @example
156
+ # Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
157
+ #
158
+ # @param [Integer, String] project The ID or name of a project.
159
+ # @param [Integer] snippet The ID of a snippet.
160
+ # @param [String] body The body of a note.
161
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
162
+ def create_snippet_note(project, snippet, body)
163
+ post("/projects/#{url_encode project}/snippets/#{snippet}/notes", body: { body: body })
164
+ end
165
+
166
+ # Creates a new note for a single merge request.
167
+ #
168
+ # @example
169
+ # Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
170
+ #
171
+ # @param [Integer] project The ID of a project.
172
+ # @param [Integer] merge_request The ID of a merge request.
173
+ # @param [String] body The content of a note.
174
+ def create_merge_request_note(project, merge_request, body)
175
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
176
+ end
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
191
+
192
+ # Deletes a wall note.
193
+ #
194
+ # @example
195
+ # Gitlab.delete_note(5, 15)
196
+ #
197
+ # @param [Integer] project The ID of a project.
198
+ # @param [Integer] id The ID of a note.
199
+ # @return [Gitlab::ObjectifiedHash]
200
+ def delete_note(project, id)
201
+ delete("/projects/#{url_encode project}/notes/#{id}")
202
+ end
203
+
204
+ # Deletes an issue note.
205
+ #
206
+ # @example
207
+ # Gitlab.delete_issue_note(5, 10, 1)
208
+ #
209
+ # @param [Integer] project The ID of a project.
210
+ # @param [Integer] issue The ID of an issue.
211
+ # @param [Integer] id The ID of a note.
212
+ # @return [Gitlab::ObjectifiedHash]
213
+ def delete_issue_note(project, issue, id)
214
+ delete("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
215
+ end
216
+
217
+ # Deletes a snippet note.
218
+ #
219
+ # @example
220
+ # Gitlab.delete_snippet_note(5, 11, 3)
221
+ #
222
+ # @param [Integer] project The ID of a project.
223
+ # @param [Integer] snippet The ID of a snippet.
224
+ # @param [Integer] id The ID of a note.
225
+ # @return [Gitlab::ObjectifiedHash]
226
+ def delete_snippet_note(project, snippet, id)
227
+ delete("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
228
+ end
229
+
230
+ # Deletes a merge_request note.
231
+ #
232
+ # @example
233
+ # Gitlab.delete_merge_request_note(5, 11, 3)
234
+ #
235
+ # @param [Integer] project The ID of a project.
236
+ # @param [Integer] merge_request The ID of a merge_request.
237
+ # @param [Integer] id The ID of a note.
238
+ # @return [Gitlab::ObjectifiedHash]
239
+ def delete_merge_request_note(project, merge_request, id)
240
+ delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
241
+ end
242
+ alias delete_merge_request_comment delete_merge_request_note
243
+
244
+ # Modifies a wall note.
245
+ #
246
+ # @example
247
+ # Gitlab.edit_note(5, 15, 'This is an edited note')
248
+ #
249
+ # @param [Integer] project The ID of a project.
250
+ # @param [Integer] id The ID of a note.
251
+ # @param [String] body The content of a note.
252
+ # @return [Gitlab::ObjectifiedHash]
253
+ def edit_note(project, id, body)
254
+ put("/projects/#{url_encode project}/notes/#{id}", body: note_content(body))
255
+ end
256
+
257
+ # Modifies an issue note.
258
+ #
259
+ # @example
260
+ # Gitlab.edit_issue_note(5, 10, 1, 'This is an edited issue note')
261
+ #
262
+ # @param [Integer] project The ID of a project.
263
+ # @param [Integer] issue The ID of an issue.
264
+ # @param [Integer] id The ID of a note.
265
+ # @param [String] body The content of a note.
266
+ # @return [Gitlab::ObjectifiedHash]
267
+ def edit_issue_note(project, issue, id, body)
268
+ put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: note_content(body))
269
+ end
270
+
271
+ # Modifies a snippet note.
272
+ #
273
+ # @example
274
+ # Gitlab.edit_snippet_note(5, 11, 3, 'This is an edited snippet note')
275
+ #
276
+ # @param [Integer] project The ID of a project.
277
+ # @param [Integer] snippet The ID of a snippet.
278
+ # @param [Integer] id The ID of a note.
279
+ # @param [String] body The content of a note.
280
+ # @return [Gitlab::ObjectifiedHash]
281
+ def edit_snippet_note(project, snippet, id, body)
282
+ put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: note_content(body))
283
+ end
284
+
285
+ # Modifies a merge_request note.
286
+ #
287
+ # @example
288
+ # Gitlab.edit_merge_request_note(5, 11, 3, 'This is an edited merge request note')
289
+ #
290
+ # @param [Integer] project The ID of a project.
291
+ # @param [Integer] merge_request The ID of a merge_request.
292
+ # @param [Integer] id The ID of a note.
293
+ # @param [String] body The content of a note.
294
+ # @return [Gitlab::ObjectifiedHash]
295
+ def edit_merge_request_note(project, merge_request, id, body)
296
+ put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: note_content(body))
297
+ end
298
+ alias edit_merge_request_comment edit_merge_request_note
299
+
300
+ private
301
+
302
+ # TODO: Remove this method after a couple deprecation cycles. Replace calls with the code
303
+ # in the 'else'.
304
+ def note_content(body)
305
+ if body.is_a?(Hash)
306
+ warn 'Passing the note body as a Hash is deprecated. You should just pass the String.'
307
+ body
308
+ else
309
+ { body: body }
310
+ end
311
+ end
312
+ end
313
+ end
@@ -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