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,526 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to groups.
5
+ # @see https://docs.gitlab.com/ce/api/groups.html
6
+ module Groups
7
+ # Gets a list of groups.
8
+ #
9
+ # @example
10
+ # Gitlab.groups
11
+ # Gitlab.groups({ per_page: 40, page: 2 })
12
+ #
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 groups(options = {})
18
+ get('/groups', query: options)
19
+ end
20
+
21
+ # Gets a single group.
22
+ #
23
+ # @example
24
+ # Gitlab.group(42)
25
+ #
26
+ # @param [Integer] id The ID of a group.
27
+ # @param [Hash] options A customizable set of options.
28
+ # @option options [Boolean] :with_custom_attributes Include custom attributes in response (admins only)
29
+ # @option options [Boolean] :with_projects Include details about group projects (default: true)
30
+ # @return [Gitlab::ObjectifiedHash]
31
+ def group(id, options = {})
32
+ get("/groups/#{url_encode id}", query: options)
33
+ end
34
+
35
+ # Creates a new group.
36
+ #
37
+ # @example
38
+ # Gitlab.create_group('new-group', 'group-path')
39
+ # Gitlab.create_group('gitlab', 'gitlab-path', { description: 'New Gitlab project' })
40
+ #
41
+ # @param [String] name The name of a group.
42
+ # @param [String] path The path of a group.
43
+ # @return [Gitlab::ObjectifiedHash] Information about created group.
44
+ def create_group(name, path, options = {})
45
+ body = { name: name, path: path }.merge(options)
46
+ post('/groups', body: body)
47
+ end
48
+
49
+ # Delete's a group.
50
+ #
51
+ # @example
52
+ # Gitlab.delete_group(42)
53
+ # @param [Integer] id The ID of a group
54
+ # @return [Gitlab::ObjectifiedHash] Information about the deleted group.
55
+ def delete_group(id)
56
+ delete("/groups/#{url_encode id}")
57
+ end
58
+
59
+ # Get a list of group members.
60
+ #
61
+ # @example
62
+ # Gitlab.group_members(1)
63
+ # Gitlab.group_members(1, { per_page: 40 })
64
+ #
65
+ # @param [Integer] id The ID of a group.
66
+ # @param [Hash] options A customizable set of options.
67
+ # @option options [Integer] :page The page number.
68
+ # @option options [Integer] :per_page The number of results per page.
69
+ # @return [Array<Gitlab::ObjectifiedHash>]
70
+ def group_members(id, options = {})
71
+ get("/groups/#{url_encode id}/members", query: options)
72
+ end
73
+
74
+ # Gets a list of all group members including inherited members.
75
+ #
76
+ # @example
77
+ # Gitlab.all_group_members(1)
78
+ # Gitlab.all_group_members(1, { per_page: 40 })
79
+ #
80
+ # @param [Integer] id The ID of a group.
81
+ # @param [Hash] options A customizable set of options.
82
+ # @option options [Integer] :page The page number.
83
+ # @option options [Integer] :per_page The number of results per page.
84
+ # @return [Array<Gitlab::ObjectifiedHash>]
85
+ def all_group_members(id, options = {})
86
+ get("/groups/#{url_encode id}/members/all", query: options)
87
+ end
88
+
89
+ # Get a list of descendant groups of a group.
90
+ #
91
+ # @example
92
+ # Gitlab.group_descendants(42)
93
+ #
94
+ # @param [Integer] id the ID of a group
95
+ # @param [Hash] options A customizable set of options.
96
+ # @option options [String] :skip_groups Skip the group IDs passed.
97
+ # @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
98
+ # @option options [String] :search Return the list of authorized groups matching the search criteria.
99
+ # @option options [String] :order_by Order groups by name or path. Default is name.
100
+ # @option options [String] :sort Order groups in asc or desc order. Default is asc.
101
+ # @option options [String] :statistics Include group statistics (admins only).
102
+ # @option options [String] :owned Limit to groups owned by the current user.
103
+ # @return [Array<Gitlab::ObjectifiedHash>] List of all subgroups under a group
104
+ def group_descendants(id, options = {})
105
+ get("/groups/#{url_encode id}/descendant_groups", query: options)
106
+ end
107
+
108
+ # Get a list of group members that are billable.
109
+ #
110
+ # @example
111
+ # Gitlab.group_billable_members(1)
112
+ # Gitlab.group_billable_members(1, { per_page: 40 })
113
+ #
114
+ # @param [Integer] id The ID of a group.
115
+ # @param [Hash] options A customizable set of options.
116
+ # @option options [Integer] :page The page number.
117
+ # @option options [Integer] :per_page The number of results per page.
118
+ # @return [Array<Gitlab::ObjectifiedHash>]
119
+ def group_billable_members(id, options = {})
120
+ get("/groups/#{url_encode id}/billable_members", query: options)
121
+ end
122
+
123
+ # Get details of a single group member.
124
+ #
125
+ # @example
126
+ # Gitlab.group_member(1, 10)
127
+ #
128
+ # @param [Integer] team_id The ID of the group to find a member in.
129
+ # @param [Integer] user_id The user id of the member to find.
130
+ # @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
131
+ def group_member(team_id, user_id)
132
+ get("/groups/#{url_encode team_id}/members/#{user_id}")
133
+ end
134
+
135
+ # Gets a list of merge requests of a group.
136
+ #
137
+ # @example
138
+ # Gitlab.group_merge_requests(5)
139
+ #
140
+ # @param [Integer, String] group_id The ID or name of a group.
141
+ # @param [Hash] options A customizable set of options.
142
+ # @return [Array<Gitlab::ObjectifiedHash>]
143
+ def group_merge_requests(group, options = {})
144
+ get("/groups/#{group}/merge_requests", query: options)
145
+ end
146
+
147
+ # Adds a user to group.
148
+ #
149
+ # @example
150
+ # Gitlab.add_group_member(1, 2, 40)
151
+ # Gitlab.add_group_member(1, 2, 40, member_role_id: 5)
152
+ #
153
+ # @param [Integer] team_id The group id to add a member to.
154
+ # @param [Integer] user_id The user id of the user to add to the team.
155
+ # @param [Integer] access_level Project access level.
156
+ # @param [Hash] options A customizable set of options.
157
+ # @option options [Integer] :member_role_id The id of a custom member role.
158
+ # @return [Gitlab::ObjectifiedHash] Information about added team member.
159
+ def add_group_member(team_id, user_id, access_level, options = {})
160
+ body = { user_id: user_id, access_level: access_level }.merge(options)
161
+ post("/groups/#{url_encode team_id}/members", body: body)
162
+ end
163
+
164
+ # Set LDAP override flag for a member of a group
165
+ #
166
+ # @example
167
+ # Gitlab.override_group_member(1, 2)
168
+ #
169
+ # @param [Integer] team_id The group id into which LDAP syncs the user.
170
+ # @param [Integer] user_id The user id of the user.
171
+ def override_group_member(team_id, user_id)
172
+ post("/groups/#{url_encode team_id}/members/#{user_id}/override")
173
+ end
174
+
175
+ # Edit a user of a group.
176
+ #
177
+ # @example
178
+ # Gitlab.edit_group_member(1, 2, 40)
179
+ # Gitlab.edit_group_member(1, 2, 40, member_role_id: 5)
180
+ #
181
+ # @param [Integer] team_id The group id of member to edit.
182
+ # @param [Integer] user_id The user id of the user to edit.
183
+ # @param [Integer] access_level Project access level.
184
+ # @param [Hash] options A customizable set of options.
185
+ # @option options [Integer] :member_role_id The id of a custom member role.
186
+ # @return [Gitlab::ObjectifiedHash] Information about edited team member.
187
+ def edit_group_member(team_id, user_id, access_level, options = {})
188
+ body = { access_level: access_level }.merge(options)
189
+ put("/groups/#{url_encode team_id}/members/#{user_id}", body: body)
190
+ end
191
+
192
+ # Removes user from user group.
193
+ #
194
+ # @example
195
+ # Gitlab.remove_group_member(1, 2)
196
+ #
197
+ # @param [Integer] team_id The group ID.
198
+ # @param [Integer] user_id The ID of a user.
199
+ # @return [Gitlab::ObjectifiedHash] Information about removed team member.
200
+ def remove_group_member(team_id, user_id)
201
+ delete("/groups/#{url_encode team_id}/members/#{user_id}")
202
+ end
203
+
204
+ # Transfers a project to a group
205
+ #
206
+ # @example
207
+ # Gitlab.transfer_project_to_group(3, 50)
208
+ #
209
+ # @param [Integer] id The ID of a group.
210
+ # @param [Integer] project_id The ID of a project.
211
+ def transfer_project_to_group(id, project_id)
212
+ body = { id: id, project_id: project_id }
213
+ post("/groups/#{url_encode id}/projects/#{project_id}", body: body)
214
+ end
215
+
216
+ # Search for groups by name
217
+ #
218
+ # @example
219
+ # Gitlab.group_search('gitlab')
220
+ #
221
+ # @param [String] search A string to search for in group names and paths.
222
+ # @param [Hash] options A customizable set of options.
223
+ # @option options [String] :per_page Number of projects to return per page
224
+ # @option options [String] :page The page to retrieve
225
+ # @return [Array<Gitlab::ObjectifiedHash>]
226
+ def group_search(search, options = {})
227
+ options[:search] = search
228
+ get('/groups', query: options)
229
+ end
230
+
231
+ # Get a list of projects under a group
232
+ # @example
233
+ # Gitlab.group_projects(1)
234
+ #
235
+ # @param [Integer] id The ID of a group
236
+ # @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
237
+ def group_projects(id, options = {})
238
+ get("/groups/#{url_encode id}/projects", query: options)
239
+ end
240
+
241
+ # Get a list of subgroups under a group
242
+ # @example
243
+ # Gitlab.group_subgroups(1)
244
+ #
245
+ # @param [Integer] id the ID of a group
246
+ # @param [Hash] options A customizable set of options.
247
+ # @option options [String] :skip_groups Skip the group IDs passed.
248
+ # @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
249
+ # @option options [String] :search Return the list of authorized groups matching the search criteria.
250
+ # @option options [String] :order_by Order groups by name or path. Default is name.
251
+ # @option options [String] :sort Order groups in asc or desc order. Default is asc.
252
+ # @option options [String] :statistics Include group statistics (admins only).
253
+ # @option options [String] :owned Limit to groups owned by the current user.
254
+ # @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
255
+ def group_subgroups(id, options = {})
256
+ get("/groups/#{url_encode id}/subgroups", query: options)
257
+ end
258
+
259
+ # Updates an existing group.
260
+ #
261
+ # @example
262
+ # Gitlab.edit_group(42)
263
+ # Gitlab.edit_group(42, { name: 'Group Name' })
264
+ #
265
+ # @param [Integer] group The ID.
266
+ # @param [Hash] options A customizable set of options
267
+ # @option options [String] :name The name of the group.
268
+ # @option options [String] :path The path of the group.
269
+ # @option options [String] :description The description of the group.
270
+ # @option options [String] :visibility The visibility level of the group. Can be private, internal, or public
271
+ # @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
272
+ # @option options [String] :request_access_enabled Allow users to request member access.
273
+ # @return [Gitlab::ObjectifiedHash] Information about the edited group.
274
+ def edit_group(id, options = {})
275
+ put("/groups/#{url_encode id}", body: options)
276
+ end
277
+
278
+ # Gets a list of issues of a group.
279
+ #
280
+ # @example
281
+ # Gitlab.group_issues(5)
282
+ #
283
+ # @param [Integer, String] group_id The ID or name of a group.
284
+ # @param [Hash] options A customizable set of options.
285
+ # @return [Array<Gitlab::ObjectifiedHash>]
286
+ def group_issues(group, options = {})
287
+ get("/groups/#{group}/issues", query: options)
288
+ end
289
+
290
+ # Sync group with LDAP
291
+ #
292
+ # @example
293
+ # Gitlab.sync_ldap_group(1)
294
+ #
295
+ # @param [Integer] id The ID or name of a group.
296
+ # @return [Array<Gitlab::ObjectifiedHash>]
297
+ def sync_ldap_group(id)
298
+ post("/groups/#{url_encode id}/ldap_sync")
299
+ end
300
+
301
+ # Add LDAP group link
302
+ #
303
+ # @example
304
+ # Gitlab.add_ldap_group_links(1, 'all', 50, 'ldap')
305
+ #
306
+ # @param [Integer] id The ID of a group
307
+ # @param [String] cn The CN of a LDAP group
308
+ # @param [Integer] group_access Minimum access level for members of the LDAP group.
309
+ # @param [String] provider LDAP provider for the LDAP group
310
+ # @return [Gitlab::ObjectifiedHash] Information about added ldap group link
311
+ def add_ldap_group_links(id, commonname, group_access, provider)
312
+ post("/groups/#{url_encode id}/ldap_group_links", body: { cn: commonname, group_access: group_access, provider: provider })
313
+ end
314
+
315
+ # Delete LDAP group link
316
+ #
317
+ # @example
318
+ # Gitlab.delete_ldap_group_links(1, 'all')
319
+ #
320
+ # @param [Integer] id The ID of a group
321
+ # @param [String] cn The CN of a LDAP group
322
+ # @return [Gitlab::ObjectifiedHash] Empty hash
323
+ def delete_ldap_group_links(id, commonname, provider)
324
+ delete("/groups/#{url_encode id}/ldap_group_links/#{url_encode provider}/#{url_encode commonname}")
325
+ end
326
+
327
+ # Gets group custom_attributes.
328
+ #
329
+ # @example
330
+ # Gitlab.group_custom_attributes(2)
331
+ #
332
+ # @param [Integer] group_id The ID of a group.
333
+ # @return [Gitlab::ObjectifiedHash]
334
+ def group_custom_attributes(group_id)
335
+ get("/groups/#{group_id}/custom_attributes")
336
+ end
337
+
338
+ # Gets single group custom_attribute.
339
+ #
340
+ # @example
341
+ # Gitlab.group_custom_attribute('key', 2)
342
+ #
343
+ # @param [String] key The custom_attributes key
344
+ # @param [Integer] group_id The ID of a group.
345
+ # @return [Gitlab::ObjectifiedHash]
346
+ def group_custom_attribute(key, group_id)
347
+ get("/groups/#{group_id}/custom_attributes/#{key}")
348
+ end
349
+
350
+ # Creates a new custom_attribute
351
+ #
352
+ # @example
353
+ # Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)
354
+ #
355
+ # @param [String] key The custom_attributes key
356
+ # @param [String] value The custom_attributes value
357
+ # @param [Integer] group_id The ID of a group.
358
+ # @return [Gitlab::ObjectifiedHash]
359
+ def add_group_custom_attribute(key, value, group_id)
360
+ url = "/groups/#{group_id}/custom_attributes/#{key}"
361
+ put(url, body: { value: value })
362
+ end
363
+
364
+ # Delete custom_attribute
365
+ # Will delete a custom_attribute
366
+ #
367
+ # @example
368
+ # Gitlab.delete_group_custom_attribute('somekey', 2)
369
+ #
370
+ # @param [String] key The custom_attribute key to delete
371
+ # @param [Integer] group_id The ID of a group.
372
+ # @return [Boolean]
373
+ def delete_group_custom_attribute(key, group_id = nil)
374
+ delete("/groups/#{group_id}/custom_attributes/#{key}")
375
+ end
376
+
377
+ # List all the specified groups hooks
378
+ #
379
+ # @example
380
+ # Gitlab.list_group_hooks(3)
381
+ #
382
+ # @param [Integer] group_id The ID of a group.
383
+ # @return [Gitlab::PaginatedResponse] List of registered hooks https://docs.gitlab.com/ee/api/groups.html#hooks
384
+ def list_group_hooks(group_id)
385
+ get("/groups/#{group_id}/hooks")
386
+ end
387
+
388
+ # get specified group hook
389
+ #
390
+ # @example
391
+ # Gitlab.group_hook(3, 1)
392
+ #
393
+ # @param [Integer] group_id The ID of a group.
394
+ # @param [Integer] hook_id The ID of the hook.
395
+ # @return [Gitlab::ObjectifiedHash] The hook https://docs.gitlab.com/ee/api/groups.html#get-group-hook
396
+ def group_hook(group_id, hook_id)
397
+ get("/groups/#{group_id}/hooks/#{hook_id}")
398
+ end
399
+
400
+ # Add a new group hook
401
+ #
402
+ # @example
403
+ # Gitlab.add_group_hook(3, "https://example.com/my-hook-receiver", {token: "verify me"})
404
+ #
405
+ # @param [Integer] group_id The ID of a group.
406
+ # @param [String] the hook url which will receive the selected events
407
+ # @option options [Boolean] :name The name of the group.
408
+ # @option options [Boolean] :push_events Trigger hook on push events
409
+ # @potion options [String] :push_events_branch_filter Trigger hook on push events for matching branches only.
410
+ # @option options [Boolean] :issues_events Trigger hook on issues events
411
+ # @option options [Boolean] :confidential_issues_events Trigger hook on confidential issues events
412
+ # @option options [Boolean] :merge_requests_events Trigger hook on merge requests events
413
+ # @option options [Boolean] :tag_push_events Trigger hook on tag push events
414
+ # @option options [Boolean] :note_events Trigger hook on note events
415
+ # @option options [Boolean] :confidential_note_events Trigger hook on confidential note events
416
+ # @option options [Boolean] :job_events Trigger hook on job events
417
+ # @option options [Boolean] :pipeline_events Trigger hook on pipeline events
418
+ # @option options [Boolean] :wiki_page_events Trigger hook on wiki page events
419
+ # @option options [Boolean] :deployment_events Trigger hook on deployment events
420
+ # @option options [Boolean] :releases_events Trigger hook on release events
421
+ # @option options [Boolean] :subgroup_events Trigger hook on subgroup events
422
+ # @option options [Boolean] :enable_ssl_verification Do SSL verification when triggering the hook
423
+ # @option options [String] :token Secret token to validate received payloads; not returned in the response
424
+ # @return [Gitlab::ObjectifiedHash] Response body matches https://docs.gitlab.com/ee/api/groups.html#get-group-hook
425
+ def add_group_hook(group_id, url, options = {})
426
+ post("/groups/#{group_id}/hooks", body: options.merge(url: url))
427
+ end
428
+
429
+ # Edit a group hook
430
+ #
431
+ # @example
432
+ # Gitlab.edit_group_hook(3, 1, "https://example.com/my-hook-receiver", {token: "verify me"})
433
+ #
434
+ # @param [Integer] group_id The ID of a group.
435
+ # @param [Integer] hook_id The ID of a group.
436
+ # @param [String] the hook url which will receive the selected events
437
+ # @option options [Boolean] :name The name of the group.
438
+ # @option options [Boolean] :push_events Trigger hook on push events
439
+ # @potion options [String] :push_events_branch_filter Trigger hook on push events for matching branches only.
440
+ # @option options [Boolean] :issues_events Trigger hook on issues events
441
+ # @option options [Boolean] :confidential_issues_events Trigger hook on confidential issues events
442
+ # @option options [Boolean] :merge_requests_events Trigger hook on merge requests events
443
+ # @option options [Boolean] :tag_push_events Trigger hook on tag push events
444
+ # @option options [Boolean] :note_events Trigger hook on note events
445
+ # @option options [Boolean] :confidential_note_events Trigger hook on confidential note events
446
+ # @option options [Boolean] :job_events Trigger hook on job events
447
+ # @option options [Boolean] :pipeline_events Trigger hook on pipeline events
448
+ # @option options [Boolean] :wiki_page_events Trigger hook on wiki page events
449
+ # @option options [Boolean] :deployment_events Trigger hook on deployment events
450
+ # @option options [Boolean] :releases_events Trigger hook on release events
451
+ # @option options [Boolean] :subgroup_events Trigger hook on subgroup events
452
+ # @option options [Boolean] :enable_ssl_verification Do SSL verification when triggering the hook
453
+ # @option options [String] :token Secret token to validate received payloads; not returned in the response
454
+ # @return [Gitlab::ObjectifiedHash] Response body matches https://docs.gitlab.com/ee/api/groups.html#edit-group-hook
455
+ def edit_group_hook(group_id, hook_id, url, options = {})
456
+ post("/groups/#{group_id}/hooks/#{hook_id}", body: options.merge(url: url))
457
+ end
458
+
459
+ # Delete a group hook
460
+ #
461
+ # @example
462
+ # Gitlab.delete_group_hook(3, 1)
463
+ #
464
+ # @param [Integer] group_id The ID of a group.
465
+ # @param [Integer] hook_id The ID of a group.
466
+ # @return [Gitlab::ObjectifiedHash] no body, will evaluate to an empty hash. https://docs.gitlab.com/ee/api/groups.html#delete-group-hook
467
+ def delete_group_hook(group_id, hook_id)
468
+ delete("/groups/#{group_id}/hooks/#{hook_id}")
469
+ end
470
+ end
471
+
472
+ # Get all access tokens for a group
473
+ #
474
+ # @example
475
+ # Gitlab.group_access_tokens(1)
476
+ #
477
+ # @param [Integer] group_id The ID of the group.
478
+ # @return [Array<Gitlab::ObjectifiedHash>]
479
+ def group_access_tokens(group_id)
480
+ get("/groups/#{group_id}/access_tokens")
481
+ end
482
+
483
+ # Get group access token information
484
+ #
485
+ # @example
486
+ # Gitlab.group_access_token(1, 1)
487
+ #
488
+ # @param [Integer] group_id The ID of the group.
489
+ # @param [Integer] group_access_token_id ID of the group access token.
490
+ # @return [Gitlab::ObjectifiedHash]
491
+ def group_access_token(group_id, group_access_token_id)
492
+ get("/groups/#{group_id}/access_tokens/#{group_access_token_id}")
493
+ end
494
+
495
+ # Create group access token
496
+ #
497
+ # @example
498
+ # Gitlab.create_group_access_token(2, "token", ["api", "read_user"])
499
+ # Gitlab.create_group_access_token(2, "token", ["api", "read_user"], 20)
500
+ # Gitlab.create_group_access_token(2, "token", ["api", "read_user"], 20, "1970-01-01")
501
+ #
502
+ # @param [Integer] group_id The ID of the group.
503
+ # @param [String] name Name for group access token.
504
+ # @param [Array<String>] scopes Array of scopes for the group access token
505
+ # @param [Integer] access_level Project access level (10: Guest, 20: Reporter, 30: Developer, 40: Maintainer, 50: Owner).
506
+ # @param [String] expires_at Date for group access token expiration in ISO format.
507
+ # @return [Gitlab::ObjectifiedHash]
508
+ def create_group_access_token(group_id, name, scopes, access_level = nil, expires_at = nil)
509
+ body = { name: name, scopes: scopes }
510
+ body[:access_level] = access_level if access_level
511
+ body[:expires_at] = expires_at if expires_at
512
+ post("/groups/#{group_id}/access_tokens", body: body)
513
+ end
514
+
515
+ # Revoke a group access token
516
+ #
517
+ # @example
518
+ # Gitlab.revoke_group_access_token(1, 1)
519
+ #
520
+ # @param [Integer] user_id The ID of the group.
521
+ # @param [Integer] group_access_token_id ID of the group access token.
522
+ # @return [Gitlab::ObjectifiedHash]
523
+ def revoke_group_access_token(group_id, group_access_token_id)
524
+ delete("/groups/#{group_id}/access_tokens/#{group_access_token_id}")
525
+ end
526
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to issue links.
5
+ # @see https://docs.gitlab.com/ee/api/issue_links.html
6
+ module IssueLinks
7
+ # Gets a list of links for a issue.
8
+ #
9
+ # @example
10
+ # Gitlab.issue_links(5, 10)
11
+ #
12
+ # @param [Integer] project The ID of a project.
13
+ # @param [Integer] issue The ID of an issue.
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 issue_links(project, issue, options = {})
18
+ get("/projects/#{url_encode project}/issues/#{issue}/links", query: options)
19
+ end
20
+
21
+ # Creates a new issue link.
22
+ #
23
+ # @example
24
+ # Gitlab.create_issue_link(6, 1, 6, 2)
25
+ #
26
+ # @param [Integer, String] project The ID or name of a project.
27
+ # @param [Integer] issue The ID of an issue.
28
+ # @param [Integer] target_project_id Project ID the target issue is located in.
29
+ # @param [Integer] target_issue_iid The ID of the target issue.
30
+ # @return [Gitlab::ObjectifiedHash] Information about created link.
31
+ def create_issue_link(project, issue, target_project_id, target_issue_iid)
32
+ post("/projects/#{url_encode project}/issues/#{issue}/links", body: { target_project_id: target_project_id, target_issue_iid: target_issue_iid })
33
+ end
34
+
35
+ # Deletes an issue link.
36
+ #
37
+ # @example
38
+ # Gitlab.delete_issue_link(5, 10, 123)
39
+ #
40
+ # @param [Integer] project The ID of a project.
41
+ # @param [Integer] issue The ID of an issue.
42
+ # @param [Integer] id The ID of a link.
43
+ # @return [Gitlab::ObjectifiedHash]
44
+ def delete_issue_link(project, issue, id)
45
+ delete("/projects/#{url_encode project}/issues/#{issue}/links/#{id}")
46
+ end
47
+ end
48
+ end