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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -267
- data/LICENSE.txt +1 -1
- data/README.md +40 -30
- data/exe/gitlab +5 -1
- data/lib/gitlab/api.rb +7 -3
- data/lib/gitlab/cli.rb +13 -9
- data/lib/gitlab/cli_helpers.rb +49 -45
- data/lib/gitlab/client/access_requests.rb +10 -1
- data/lib/gitlab/client/application_settings.rb +172 -0
- data/lib/gitlab/client/avatar.rb +21 -0
- data/lib/gitlab/client/award_emojis.rb +5 -3
- data/lib/gitlab/client/boards.rb +62 -4
- data/lib/gitlab/client/branches.rb +47 -8
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +19 -12
- data/lib/gitlab/client/builds.rb +13 -11
- data/lib/gitlab/client/commits.rb +73 -21
- data/lib/gitlab/client/container_registry.rb +85 -0
- data/lib/gitlab/client/deployments.rb +3 -1
- data/lib/gitlab/client/environments.rb +5 -3
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/events.rb +6 -4
- data/lib/gitlab/client/features.rb +48 -0
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_boards.rb +141 -0
- data/lib/gitlab/client/group_labels.rb +88 -0
- data/lib/gitlab/client/group_milestones.rb +7 -6
- data/lib/gitlab/client/groups.rb +326 -12
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +47 -13
- data/lib/gitlab/client/jobs.rb +96 -8
- data/lib/gitlab/client/keys.rb +13 -0
- data/lib/gitlab/client/labels.rb +6 -4
- data/lib/gitlab/client/lint.rb +19 -0
- data/lib/gitlab/client/markdown.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +164 -9
- data/lib/gitlab/client/merge_requests.rb +148 -11
- data/lib/gitlab/client/merge_trains.rb +55 -0
- data/lib/gitlab/client/milestones.rb +19 -5
- data/lib/gitlab/client/namespaces.rb +4 -2
- data/lib/gitlab/client/notes.rb +38 -9
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +36 -10
- data/lib/gitlab/client/pipeline_triggers.rb +10 -8
- data/lib/gitlab/client/pipelines.rb +65 -3
- data/lib/gitlab/client/project_badges.rb +85 -0
- data/lib/gitlab/client/project_clusters.rb +83 -0
- data/lib/gitlab/client/project_exports.rb +54 -0
- data/lib/gitlab/client/project_release_links.rb +76 -0
- data/lib/gitlab/client/project_releases.rb +90 -0
- data/lib/gitlab/client/projects.rb +307 -26
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +77 -6
- data/lib/gitlab/client/repository_files.rb +21 -3
- data/lib/gitlab/client/repository_submodules.rb +27 -0
- data/lib/gitlab/client/resource_label_events.rb +82 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +170 -18
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +4 -1
- data/lib/gitlab/client/sidekiq.rb +2 -0
- data/lib/gitlab/client/snippets.rb +5 -3
- data/lib/gitlab/client/system_hooks.rb +9 -7
- data/lib/gitlab/client/tags.rb +10 -9
- data/lib/gitlab/client/templates.rb +100 -0
- data/lib/gitlab/client/todos.rb +7 -5
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +302 -31
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +48 -9
- data/lib/gitlab/configuration.rb +9 -6
- data/lib/gitlab/error.rb +73 -3
- data/lib/gitlab/file_response.rb +4 -2
- data/lib/gitlab/headers/page_links.rb +37 -0
- data/lib/gitlab/headers/total.rb +29 -0
- data/lib/gitlab/help.rb +16 -16
- data/lib/gitlab/objectified_hash.rb +27 -10
- data/lib/gitlab/paginated_response.rb +43 -25
- data/lib/gitlab/request.rb +51 -37
- data/lib/gitlab/shell.rb +6 -4
- data/lib/gitlab/shell_history.rb +11 -13
- data/lib/gitlab/version.rb +3 -1
- data/lib/gitlab.rb +23 -9
- metadata +59 -45
- data/.gitignore +0 -22
- data/CONTRIBUTING.md +0 -195
- data/Gemfile +0 -4
- data/Rakefile +0 -17
- data/bin/console +0 -10
- data/bin/setup +0 -6
- data/gitlab.gemspec +0 -33
- data/lib/gitlab/page_links.rb +0 -33
data/lib/gitlab/client/groups.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to groups.
|
3
5
|
# @see https://docs.gitlab.com/ce/api/groups.html
|
@@ -12,8 +14,8 @@ 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 groups(options={})
|
16
|
-
get(
|
17
|
+
def groups(options = {})
|
18
|
+
get('/groups', query: options)
|
17
19
|
end
|
18
20
|
|
19
21
|
# Gets a single group.
|
@@ -22,9 +24,12 @@ class Gitlab::Client
|
|
22
24
|
# Gitlab.group(42)
|
23
25
|
#
|
24
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)
|
25
30
|
# @return [Gitlab::ObjectifiedHash]
|
26
|
-
def group(id)
|
27
|
-
get("/groups/#{url_encode id}")
|
31
|
+
def group(id, options = {})
|
32
|
+
get("/groups/#{url_encode id}", query: options)
|
28
33
|
end
|
29
34
|
|
30
35
|
# Creates a new group.
|
@@ -36,9 +41,9 @@ class Gitlab::Client
|
|
36
41
|
# @param [String] name The name of a group.
|
37
42
|
# @param [String] path The path of a group.
|
38
43
|
# @return [Gitlab::ObjectifiedHash] Information about created group.
|
39
|
-
def create_group(name, path, options={})
|
44
|
+
def create_group(name, path, options = {})
|
40
45
|
body = { name: name, path: path }.merge(options)
|
41
|
-
post(
|
46
|
+
post('/groups', body: body)
|
42
47
|
end
|
43
48
|
|
44
49
|
# Delete's a group.
|
@@ -62,10 +67,59 @@ class Gitlab::Client
|
|
62
67
|
# @option options [Integer] :page The page number.
|
63
68
|
# @option options [Integer] :per_page The number of results per page.
|
64
69
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
65
|
-
def group_members(id, options={})
|
70
|
+
def group_members(id, options = {})
|
66
71
|
get("/groups/#{url_encode id}/members", query: options)
|
67
72
|
end
|
68
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
|
+
|
69
123
|
# Get details of a single group member.
|
70
124
|
#
|
71
125
|
# @example
|
@@ -78,6 +132,18 @@ class Gitlab::Client
|
|
78
132
|
get("/groups/#{url_encode team_id}/members/#{user_id}")
|
79
133
|
end
|
80
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
|
+
|
81
147
|
# Adds a user to group.
|
82
148
|
#
|
83
149
|
# @example
|
@@ -138,9 +204,9 @@ class Gitlab::Client
|
|
138
204
|
# @option options [String] :per_page Number of projects to return per page
|
139
205
|
# @option options [String] :page The page to retrieve
|
140
206
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
141
|
-
def group_search(search, options={})
|
207
|
+
def group_search(search, options = {})
|
142
208
|
options[:search] = search
|
143
|
-
get(
|
209
|
+
get('/groups', query: options)
|
144
210
|
end
|
145
211
|
|
146
212
|
# Get a list of projects under a group
|
@@ -149,7 +215,7 @@ class Gitlab::Client
|
|
149
215
|
#
|
150
216
|
# @param [Integer] id The ID of a group
|
151
217
|
# @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
|
152
|
-
def group_projects(id, options={})
|
218
|
+
def group_projects(id, options = {})
|
153
219
|
get("/groups/#{url_encode id}/projects", query: options)
|
154
220
|
end
|
155
221
|
|
@@ -167,7 +233,7 @@ class Gitlab::Client
|
|
167
233
|
# @option options [String] :statistics Include group statistics (admins only).
|
168
234
|
# @option options [String] :owned Limit to groups owned by the current user.
|
169
235
|
# @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
|
170
|
-
def group_subgroups(id, options={})
|
236
|
+
def group_subgroups(id, options = {})
|
171
237
|
get("/groups/#{url_encode id}/subgroups", query: options)
|
172
238
|
end
|
173
239
|
|
@@ -186,8 +252,256 @@ class Gitlab::Client
|
|
186
252
|
# @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
|
187
253
|
# @option options [String] :request_access_enabled Allow users to request member access.
|
188
254
|
# @return [Gitlab::ObjectifiedHash] Information about the edited group.
|
189
|
-
def edit_group(id, options={})
|
255
|
+
def edit_group(id, options = {})
|
190
256
|
put("/groups/#{url_encode id}", body: options)
|
191
257
|
end
|
258
|
+
|
259
|
+
# Gets a list of issues of a group.
|
260
|
+
#
|
261
|
+
# @example
|
262
|
+
# Gitlab.group_issues(5)
|
263
|
+
#
|
264
|
+
# @param [Integer, String] group_id The ID or name of a group.
|
265
|
+
# @param [Hash] options A customizable set of options.
|
266
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
267
|
+
def group_issues(group, options = {})
|
268
|
+
get("/groups/#{group}/issues", query: options)
|
269
|
+
end
|
270
|
+
|
271
|
+
# Sync group with LDAP
|
272
|
+
#
|
273
|
+
# @example
|
274
|
+
# Gitlab.sync_ldap_group(1)
|
275
|
+
#
|
276
|
+
# @param [Integer] id The ID or name of a group.
|
277
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
278
|
+
def sync_ldap_group(id)
|
279
|
+
post("/groups/#{url_encode id}/ldap_sync")
|
280
|
+
end
|
281
|
+
|
282
|
+
# Add LDAP group link
|
283
|
+
#
|
284
|
+
# @example
|
285
|
+
# Gitlab.add_ldap_group_links(1, 'all', 50, 'ldap')
|
286
|
+
#
|
287
|
+
# @param [Integer] id The ID of a group
|
288
|
+
# @param [String] cn The CN of a LDAP group
|
289
|
+
# @param [Integer] group_access Minimum access level for members of the LDAP group.
|
290
|
+
# @param [String] provider LDAP provider for the LDAP group
|
291
|
+
# @return [Gitlab::ObjectifiedHash] Information about added ldap group link
|
292
|
+
def add_ldap_group_links(id, commonname, group_access, provider)
|
293
|
+
post("/groups/#{url_encode id}/ldap_group_links", body: { cn: commonname, group_access: group_access, provider: provider })
|
294
|
+
end
|
295
|
+
|
296
|
+
# Delete LDAP group link
|
297
|
+
#
|
298
|
+
# @example
|
299
|
+
# Gitlab.delete_ldap_group_links(1, 'all')
|
300
|
+
#
|
301
|
+
# @param [Integer] id The ID of a group
|
302
|
+
# @param [String] cn The CN of a LDAP group
|
303
|
+
# @return [Gitlab::ObjectifiedHash] Empty hash
|
304
|
+
def delete_ldap_group_links(id, commonname, provider)
|
305
|
+
delete("/groups/#{url_encode id}/ldap_group_links/#{url_encode provider}/#{url_encode commonname}")
|
306
|
+
end
|
307
|
+
|
308
|
+
# Gets group custom_attributes.
|
309
|
+
#
|
310
|
+
# @example
|
311
|
+
# Gitlab.group_custom_attributes(2)
|
312
|
+
#
|
313
|
+
# @param [Integer] group_id The ID of a group.
|
314
|
+
# @return [Gitlab::ObjectifiedHash]
|
315
|
+
def group_custom_attributes(group_id)
|
316
|
+
get("/groups/#{group_id}/custom_attributes")
|
317
|
+
end
|
318
|
+
|
319
|
+
# Gets single group custom_attribute.
|
320
|
+
#
|
321
|
+
# @example
|
322
|
+
# Gitlab.group_custom_attribute('key', 2)
|
323
|
+
#
|
324
|
+
# @param [String] key The custom_attributes key
|
325
|
+
# @param [Integer] group_id The ID of a group.
|
326
|
+
# @return [Gitlab::ObjectifiedHash]
|
327
|
+
def group_custom_attribute(key, group_id)
|
328
|
+
get("/groups/#{group_id}/custom_attributes/#{key}")
|
329
|
+
end
|
330
|
+
|
331
|
+
# Creates a new custom_attribute
|
332
|
+
#
|
333
|
+
# @example
|
334
|
+
# Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)
|
335
|
+
#
|
336
|
+
# @param [String] key The custom_attributes key
|
337
|
+
# @param [String] value The custom_attributes value
|
338
|
+
# @param [Integer] group_id The ID of a group.
|
339
|
+
# @return [Gitlab::ObjectifiedHash]
|
340
|
+
def add_group_custom_attribute(key, value, group_id)
|
341
|
+
url = "/groups/#{group_id}/custom_attributes/#{key}"
|
342
|
+
put(url, body: { value: value })
|
343
|
+
end
|
344
|
+
|
345
|
+
# Delete custom_attribute
|
346
|
+
# Will delete a custom_attribute
|
347
|
+
#
|
348
|
+
# @example
|
349
|
+
# Gitlab.delete_group_custom_attribute('somekey', 2)
|
350
|
+
#
|
351
|
+
# @param [String] key The custom_attribute key to delete
|
352
|
+
# @param [Integer] group_id The ID of a group.
|
353
|
+
# @return [Boolean]
|
354
|
+
def delete_group_custom_attribute(key, group_id = nil)
|
355
|
+
delete("/groups/#{group_id}/custom_attributes/#{key}")
|
356
|
+
end
|
357
|
+
|
358
|
+
# List all the specified groups hooks
|
359
|
+
#
|
360
|
+
# @example
|
361
|
+
# Gitlab.list_group_hooks(3)
|
362
|
+
#
|
363
|
+
# @param [Integer] group_id The ID of a group.
|
364
|
+
# @return [Gitlab::PaginatedResponse] List of registered hooks https://docs.gitlab.com/ee/api/groups.html#hooks
|
365
|
+
def list_group_hooks(group_id)
|
366
|
+
get("/groups/#{group_id}/hooks")
|
367
|
+
end
|
368
|
+
|
369
|
+
# get specified group hook
|
370
|
+
#
|
371
|
+
# @example
|
372
|
+
# Gitlab.group_hook(3, 1)
|
373
|
+
#
|
374
|
+
# @param [Integer] group_id The ID of a group.
|
375
|
+
# @param [Integer] hook_id The ID of the hook.
|
376
|
+
# @return [Gitlab::ObjectifiedHash] The hook https://docs.gitlab.com/ee/api/groups.html#get-group-hook
|
377
|
+
def group_hook(group_id, hook_id)
|
378
|
+
get("/groups/#{group_id}/hooks/#{hook_id}")
|
379
|
+
end
|
380
|
+
|
381
|
+
# Add a new group hook
|
382
|
+
#
|
383
|
+
# @example
|
384
|
+
# Gitlab.add_group_hook(3, "https://example.com/my-hook-receiver", {token: "verify me"})
|
385
|
+
#
|
386
|
+
# @param [Integer] group_id The ID of a group.
|
387
|
+
# @param [String] the hook url which will receive the selected events
|
388
|
+
# @option options [Boolean] :name The name of the group.
|
389
|
+
# @option options [Boolean] :push_events Trigger hook on push events
|
390
|
+
# @potion options [String] :push_events_branch_filter Trigger hook on push events for matching branches only.
|
391
|
+
# @option options [Boolean] :issues_events Trigger hook on issues events
|
392
|
+
# @option options [Boolean] :confidential_issues_events Trigger hook on confidential issues events
|
393
|
+
# @option options [Boolean] :merge_requests_events Trigger hook on merge requests events
|
394
|
+
# @option options [Boolean] :tag_push_events Trigger hook on tag push events
|
395
|
+
# @option options [Boolean] :note_events Trigger hook on note events
|
396
|
+
# @option options [Boolean] :confidential_note_events Trigger hook on confidential note events
|
397
|
+
# @option options [Boolean] :job_events Trigger hook on job events
|
398
|
+
# @option options [Boolean] :pipeline_events Trigger hook on pipeline events
|
399
|
+
# @option options [Boolean] :wiki_page_events Trigger hook on wiki page events
|
400
|
+
# @option options [Boolean] :deployment_events Trigger hook on deployment events
|
401
|
+
# @option options [Boolean] :releases_events Trigger hook on release events
|
402
|
+
# @option options [Boolean] :subgroup_events Trigger hook on subgroup events
|
403
|
+
# @option options [Boolean] :enable_ssl_verification Do SSL verification when triggering the hook
|
404
|
+
# @option options [String] :token Secret token to validate received payloads; not returned in the response
|
405
|
+
# @return [Gitlab::ObjectifiedHash] Response body matches https://docs.gitlab.com/ee/api/groups.html#get-group-hook
|
406
|
+
def add_group_hook(group_id, url, options = {})
|
407
|
+
post("/groups/#{group_id}/hooks", body: options.merge(url: url))
|
408
|
+
end
|
409
|
+
|
410
|
+
# Edit a group hook
|
411
|
+
#
|
412
|
+
# @example
|
413
|
+
# Gitlab.edit_group_hook(3, 1, "https://example.com/my-hook-receiver", {token: "verify me"})
|
414
|
+
#
|
415
|
+
# @param [Integer] group_id The ID of a group.
|
416
|
+
# @param [Integer] hook_id The ID of a group.
|
417
|
+
# @param [String] the hook url which will receive the selected events
|
418
|
+
# @option options [Boolean] :name The name of the group.
|
419
|
+
# @option options [Boolean] :push_events Trigger hook on push events
|
420
|
+
# @potion options [String] :push_events_branch_filter Trigger hook on push events for matching branches only.
|
421
|
+
# @option options [Boolean] :issues_events Trigger hook on issues events
|
422
|
+
# @option options [Boolean] :confidential_issues_events Trigger hook on confidential issues events
|
423
|
+
# @option options [Boolean] :merge_requests_events Trigger hook on merge requests events
|
424
|
+
# @option options [Boolean] :tag_push_events Trigger hook on tag push events
|
425
|
+
# @option options [Boolean] :note_events Trigger hook on note events
|
426
|
+
# @option options [Boolean] :confidential_note_events Trigger hook on confidential note events
|
427
|
+
# @option options [Boolean] :job_events Trigger hook on job events
|
428
|
+
# @option options [Boolean] :pipeline_events Trigger hook on pipeline events
|
429
|
+
# @option options [Boolean] :wiki_page_events Trigger hook on wiki page events
|
430
|
+
# @option options [Boolean] :deployment_events Trigger hook on deployment events
|
431
|
+
# @option options [Boolean] :releases_events Trigger hook on release events
|
432
|
+
# @option options [Boolean] :subgroup_events Trigger hook on subgroup events
|
433
|
+
# @option options [Boolean] :enable_ssl_verification Do SSL verification when triggering the hook
|
434
|
+
# @option options [String] :token Secret token to validate received payloads; not returned in the response
|
435
|
+
# @return [Gitlab::ObjectifiedHash] Response body matches https://docs.gitlab.com/ee/api/groups.html#edit-group-hook
|
436
|
+
def edit_group_hook(group_id, hook_id, url, options = {})
|
437
|
+
post("/groups/#{group_id}/hooks/#{hook_id}", body: options.merge(url: url))
|
438
|
+
end
|
439
|
+
|
440
|
+
# Delete a group hook
|
441
|
+
#
|
442
|
+
# @example
|
443
|
+
# Gitlab.delete_group_hook(3, 1)
|
444
|
+
#
|
445
|
+
# @param [Integer] group_id The ID of a group.
|
446
|
+
# @param [Integer] hook_id The ID of a group.
|
447
|
+
# @return [Gitlab::ObjectifiedHash] no body, will evaluate to an empty hash. https://docs.gitlab.com/ee/api/groups.html#delete-group-hook
|
448
|
+
def delete_group_hook(group_id, hook_id)
|
449
|
+
delete("/groups/#{group_id}/hooks/#{hook_id}")
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
# Get all access tokens for a group
|
454
|
+
#
|
455
|
+
# @example
|
456
|
+
# Gitlab.group_access_tokens(1)
|
457
|
+
#
|
458
|
+
# @param [Integer] group_id The ID of the group.
|
459
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
460
|
+
def group_access_tokens(group_id)
|
461
|
+
get("/groups/#{group_id}/access_tokens")
|
462
|
+
end
|
463
|
+
|
464
|
+
# Get group access token information
|
465
|
+
#
|
466
|
+
# @example
|
467
|
+
# Gitlab.group_access_token(1, 1)
|
468
|
+
#
|
469
|
+
# @param [Integer] group_id The ID of the group.
|
470
|
+
# @param [Integer] group_access_token_id ID of the group access token.
|
471
|
+
# @return [Gitlab::ObjectifiedHash]
|
472
|
+
def group_access_token(group_id, group_access_token_id)
|
473
|
+
get("/groups/#{group_id}/access_tokens/#{group_access_token_id}")
|
474
|
+
end
|
475
|
+
|
476
|
+
# Create group access token
|
477
|
+
#
|
478
|
+
# @example
|
479
|
+
# Gitlab.create_group_access_token(2, "token", ["api", "read_user"])
|
480
|
+
# Gitlab.create_group_access_token(2, "token", ["api", "read_user"], 20)
|
481
|
+
# Gitlab.create_group_access_token(2, "token", ["api", "read_user"], 20, "1970-01-01")
|
482
|
+
#
|
483
|
+
# @param [Integer] group_id The ID of the group.
|
484
|
+
# @param [String] name Name for group access token.
|
485
|
+
# @param [Array<String>] scopes Array of scopes for the group access token
|
486
|
+
# @param [Integer] access_level Project access level (10: Guest, 20: Reporter, 30: Developer, 40: Maintainer, 50: Owner).
|
487
|
+
# @param [String] expires_at Date for group access token expiration in ISO format.
|
488
|
+
# @return [Gitlab::ObjectifiedHash]
|
489
|
+
def create_group_access_token(group_id, name, scopes, access_level = nil, expires_at = nil)
|
490
|
+
body = { name: name, scopes: scopes }
|
491
|
+
body[:access_level] = access_level if access_level
|
492
|
+
body[:expires_at] = expires_at if expires_at
|
493
|
+
post("/groups/#{group_id}/access_tokens", body: body)
|
494
|
+
end
|
495
|
+
|
496
|
+
# Revoke a group access token
|
497
|
+
#
|
498
|
+
# @example
|
499
|
+
# Gitlab.revoke_group_access_token(1, 1)
|
500
|
+
#
|
501
|
+
# @param [Integer] user_id The ID of the group.
|
502
|
+
# @param [Integer] group_access_token_id ID of the group access token.
|
503
|
+
# @return [Gitlab::ObjectifiedHash]
|
504
|
+
def revoke_group_access_token(group_id, group_access_token_id)
|
505
|
+
delete("/groups/#{group_id}/access_tokens/#{group_access_token_id}")
|
192
506
|
end
|
193
507
|
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
|
data/lib/gitlab/client/issues.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to issues.
|
3
5
|
# @see https://docs.gitlab.com/ce/api/issues.html
|
@@ -15,9 +17,9 @@ class Gitlab::Client
|
|
15
17
|
# @option options [Integer] :page The page number.
|
16
18
|
# @option options [Integer] :per_page The number of results per page.
|
17
19
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
18
|
-
def issues(project=nil, options={})
|
20
|
+
def issues(project = nil, options = {})
|
19
21
|
if project.to_s.empty? && project.to_i.zero?
|
20
|
-
get(
|
22
|
+
get('/issues', query: options)
|
21
23
|
else
|
22
24
|
get("/projects/#{url_encode project}/issues", query: options)
|
23
25
|
end
|
@@ -49,7 +51,7 @@ class Gitlab::Client
|
|
49
51
|
# @option options [Integer] :milestone_id The ID of a milestone to assign issue.
|
50
52
|
# @option options [String] :labels Comma-separated label names for an issue.
|
51
53
|
# @return [Gitlab::ObjectifiedHash] Information about created issue.
|
52
|
-
def create_issue(project, title, options={})
|
54
|
+
def create_issue(project, title, options = {})
|
53
55
|
body = { title: title }.merge(options)
|
54
56
|
post("/projects/#{url_encode project}/issues", body: body)
|
55
57
|
end
|
@@ -69,7 +71,7 @@ class Gitlab::Client
|
|
69
71
|
# @option options [String] :labels Comma-separated label names for an issue.
|
70
72
|
# @option options [String] :state_event The state event of an issue ('close' or 'reopen').
|
71
73
|
# @return [Gitlab::ObjectifiedHash] Information about updated issue.
|
72
|
-
def edit_issue(project, id, options={})
|
74
|
+
def edit_issue(project, id, options = {})
|
73
75
|
put("/projects/#{url_encode project}/issues/#{id}", body: options)
|
74
76
|
end
|
75
77
|
|
@@ -143,10 +145,10 @@ class Gitlab::Client
|
|
143
145
|
# @param [Integer] id The ID of an issue.
|
144
146
|
# @option options [String] :to_project_id The ID of the new project.
|
145
147
|
# @return [Gitlab::ObjectifiedHash] Information about moved issue.
|
146
|
-
def move_issue(project, id, options={})
|
148
|
+
def move_issue(project, id, options = {})
|
147
149
|
post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
|
148
150
|
end
|
149
|
-
|
151
|
+
|
150
152
|
# Sets an estimated time of work for an issue.
|
151
153
|
#
|
152
154
|
# @example
|
@@ -158,8 +160,8 @@ class Gitlab::Client
|
|
158
160
|
def estimate_time_of_issue(project, id, duration)
|
159
161
|
post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
|
160
162
|
end
|
161
|
-
|
162
|
-
# Resets the estimated time for an issue to 0 seconds.
|
163
|
+
|
164
|
+
# Resets the estimated time for an issue to 0 seconds.
|
163
165
|
#
|
164
166
|
# @example
|
165
167
|
# Gitlab.reset_time_estimate_of_issue(3, 42)
|
@@ -169,7 +171,7 @@ class Gitlab::Client
|
|
169
171
|
def reset_time_estimate_of_issue(project, id)
|
170
172
|
post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate")
|
171
173
|
end
|
172
|
-
|
174
|
+
|
173
175
|
# Adds spent time for an issue
|
174
176
|
#
|
175
177
|
# @example
|
@@ -179,9 +181,9 @@ class Gitlab::Client
|
|
179
181
|
# @param [Integer] id The ID of an issue.
|
180
182
|
# @param [String] duration The time spent in human format. e.g: 3h30m
|
181
183
|
def add_time_spent_on_issue(project, id, duration)
|
182
|
-
post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration:
|
184
|
+
post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: duration })
|
183
185
|
end
|
184
|
-
|
186
|
+
|
185
187
|
# Resets the total spent time for this issue to 0 seconds.
|
186
188
|
#
|
187
189
|
# @example
|
@@ -192,7 +194,7 @@ class Gitlab::Client
|
|
192
194
|
def reset_time_spent_on_issue(project, id)
|
193
195
|
post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
|
194
196
|
end
|
195
|
-
|
197
|
+
|
196
198
|
# Get time tracking stats for an issue
|
197
199
|
#
|
198
200
|
# @example
|
@@ -203,6 +205,38 @@ class Gitlab::Client
|
|
203
205
|
def time_stats_for_issue(project, id)
|
204
206
|
get("/projects/#{url_encode project}/issues/#{id}/time_stats")
|
205
207
|
end
|
206
|
-
|
208
|
+
|
209
|
+
# Get participants on issue
|
210
|
+
#
|
211
|
+
# @example
|
212
|
+
# @gitlab.participants_on_issue(3, 42)
|
213
|
+
#
|
214
|
+
# @param [Integer, String] project The ID or name of a project.
|
215
|
+
# @param [Integer] id The ID of an issue.
|
216
|
+
def participants_on_issue(project, id)
|
217
|
+
get("/projects/#{url_encode project}/issues/#{id}/participants")
|
218
|
+
end
|
219
|
+
|
220
|
+
# List merge requests that will close issue on merge
|
221
|
+
#
|
222
|
+
# @example
|
223
|
+
# Gitlab.merge_requests_closing_issue_on_merge(3, 42)
|
224
|
+
#
|
225
|
+
# @param [Integer, String] project The ID or name of a project.
|
226
|
+
# @param [Integer] id The ID of an issue.
|
227
|
+
def merge_requests_closing_issue_on_merge(project, id)
|
228
|
+
get("/projects/#{url_encode project}/issues/#{id}/closed_by")
|
229
|
+
end
|
230
|
+
|
231
|
+
# List related merge requests
|
232
|
+
#
|
233
|
+
# @example
|
234
|
+
# Gitlab.related_merge_requests(3, 42)
|
235
|
+
#
|
236
|
+
# @param [Integer, String] project The ID or name of a project.
|
237
|
+
# @param [Integer] id The ID of an issue.
|
238
|
+
def related_merge_requests(project, id)
|
239
|
+
get("/projects/#{url_encode project}/issues/#{id}/related_merge_requests")
|
240
|
+
end
|
207
241
|
end
|
208
242
|
end
|