gitlab 4.10.0 → 4.19.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +26 -18
  4. data/lib/gitlab/api.rb +2 -0
  5. data/lib/gitlab/cli.rb +6 -8
  6. data/lib/gitlab/cli_helpers.rb +20 -25
  7. data/lib/gitlab/client/application_settings.rb +172 -0
  8. data/lib/gitlab/client/build_variables.rb +17 -12
  9. data/lib/gitlab/client/commits.rb +42 -5
  10. data/lib/gitlab/client/container_registry.rb +85 -0
  11. data/lib/gitlab/client/epic_issues.rb +23 -0
  12. data/lib/gitlab/client/epics.rb +73 -0
  13. data/lib/gitlab/client/group_badges.rb +88 -0
  14. data/lib/gitlab/client/group_labels.rb +1 -1
  15. data/lib/gitlab/client/groups.rb +153 -2
  16. data/lib/gitlab/client/issue_links.rb +48 -0
  17. data/lib/gitlab/client/issues.rb +1 -1
  18. data/lib/gitlab/client/jobs.rb +91 -8
  19. data/lib/gitlab/client/keys.rb +11 -0
  20. data/lib/gitlab/client/labels.rb +1 -1
  21. data/lib/gitlab/client/lint.rb +19 -0
  22. data/lib/gitlab/client/markdown.rb +23 -0
  23. data/lib/gitlab/client/merge_request_approvals.rb +160 -7
  24. data/lib/gitlab/client/merge_requests.rb +64 -4
  25. data/lib/gitlab/client/notes.rb +28 -1
  26. data/lib/gitlab/client/packages.rb +95 -0
  27. data/lib/gitlab/client/pipeline_schedules.rb +16 -4
  28. data/lib/gitlab/client/pipelines.rb +12 -0
  29. data/lib/gitlab/client/projects.rb +142 -8
  30. data/lib/gitlab/client/remote_mirrors.rb +51 -0
  31. data/lib/gitlab/client/repositories.rb +59 -3
  32. data/lib/gitlab/client/repository_files.rb +16 -0
  33. data/lib/gitlab/client/resource_state_events.rb +57 -0
  34. data/lib/gitlab/client/runners.rb +99 -14
  35. data/lib/gitlab/client/search.rb +5 -1
  36. data/lib/gitlab/client/user_snippets.rb +114 -0
  37. data/lib/gitlab/client/users.rb +142 -11
  38. data/lib/gitlab/client.rb +18 -2
  39. data/lib/gitlab/configuration.rb +1 -1
  40. data/lib/gitlab/error.rb +54 -0
  41. data/lib/gitlab/help.rb +8 -8
  42. data/lib/gitlab/objectified_hash.rb +23 -7
  43. data/lib/gitlab/page_links.rb +1 -1
  44. data/lib/gitlab/paginated_response.rb +23 -20
  45. data/lib/gitlab/request.rb +34 -33
  46. data/lib/gitlab/shell_history.rb +6 -10
  47. data/lib/gitlab/version.rb +1 -1
  48. data/lib/gitlab.rb +14 -6
  49. metadata +24 -47
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to GitLab Container Registry.
5
+ # @see https://docs.gitlab.com/ce/api/container_registry.html
6
+ module ContainerRegistry
7
+ # Get a list of registry repositories in a project.
8
+ #
9
+ # @example
10
+ # Gitlab.registry_repositories(5)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns list of registry repositories in a project.
14
+ def registry_repositories(project)
15
+ get("/projects/#{url_encode project}/registry/repositories")
16
+ end
17
+
18
+ # Delete a repository in registry.
19
+ #
20
+ # @example
21
+ # Gitlab.delete_registry_repository(5, 2)
22
+ #
23
+ # @param [Integer, String] project The ID or name of a project.
24
+ # @param [Integer] id The ID of registry repository.
25
+ # @return [void] This API call returns an empty response body.
26
+ def delete_registry_repository(project, id)
27
+ delete("/projects/#{url_encode project}/registry/repositories/#{id}")
28
+ end
29
+
30
+ # Get a list of tags for given registry repository.
31
+ #
32
+ # @example
33
+ # Gitlab.registry_repository_tags(5, 2)
34
+ #
35
+ # @param [Integer, String] project The ID or name of a project.
36
+ # @param [Integer] repository_id The ID of registry repository.
37
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns list of tags of a registry repository.
38
+ def registry_repository_tags(project, repository_id)
39
+ get("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags")
40
+ end
41
+
42
+ # Get details of a registry repository tag.
43
+ #
44
+ # @example
45
+ # Gitlab.registry_repository_tag(5, 2, 'v10.0.0')
46
+ #
47
+ # @param [Integer, String] project The ID or name of a project.
48
+ # @param [Integer] repository_id The ID of registry repository.
49
+ # @param [String] tag_name The name of tag.
50
+ # @return <Gitlab::ObjectifiedHash> Returns details about the registry repository tag
51
+ def registry_repository_tag(project, repository_id, tag_name)
52
+ get("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags/#{tag_name}")
53
+ end
54
+
55
+ # Delete a registry repository tag.
56
+ #
57
+ # @example
58
+ # Gitlab.delete_registry_repository_tag(5, 2, 'v10.0.0')
59
+ #
60
+ # @param [Integer, String] project The ID or name of a project.
61
+ # @param [Integer] repository_id The ID of registry repository.
62
+ # @param [String] tag_name The name of tag.
63
+ # @return [void] This API call returns an empty response body.
64
+ def delete_registry_repository_tag(project, repository_id, tag_name)
65
+ delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags/#{tag_name}")
66
+ end
67
+
68
+ # Delete repository tags in bulk based on given criteria.
69
+ #
70
+ # @example
71
+ # Gitlab.bulk_delete_registry_repository_tags(5, 2, name_regex: '.*')
72
+ # Gitlab.bulk_delete_registry_repository_tags(5, 2, name_regex: '[0-9a-z]{40}', keep_n: 5, older_than: '1d')
73
+ #
74
+ # @param [Integer, String] project The ID or name of a project.
75
+ # @param [Integer] repository_id The ID of registry repository.
76
+ # @param [Hash] options A customizable set of options.
77
+ # @option options [String] :name_regex(required) The regex of the name to delete. To delete all tags specify .*.
78
+ # @option options [Integer] :keep_n(optional) The amount of latest tags of given name to keep.
79
+ # @option options [String] :older_than(required) Tags to delete that are older than the given time, written in human readable form 1h, 1d, 1month.
80
+ # @return [void] This API call returns an empty response body.
81
+ def bulk_delete_registry_repository_tags(project, repository_id, options = {})
82
+ delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags", body: options)
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to issues.
5
+ # @see https://docs.gitlab.com/ee/api/epic_issues.html
6
+ module EpicIssues
7
+ # List issues for an epic.
8
+ # Gets all issues that are assigned to an epic and the authenticated user has access to..
9
+ # @example
10
+ # Gitlab.epic_issues(5, 7)
11
+ # Gitlab.epic_issues(5, 7, { per_page: 40 })
12
+ #
13
+ # @param [Integer, String] group The ID or name of a group.
14
+ # @param [Integer] epic The iid of an epic.
15
+ # @param [Hash] options A customizable set of options.
16
+ # @option options [Integer] :page The page number.
17
+ # @option options [Integer] :per_page The number of results per page.
18
+ # @return [Array<Gitlab::ObjectifiedHash>]
19
+ def epic_issues(group, epic, options = {})
20
+ get("/groups/#{url_encode group}/epics/#{epic}/issues", query: options)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to Epics.
5
+ # @see https://docs.gitlab.com/ee/api/epics.html
6
+ module Epics
7
+ # Gets a list of epics.
8
+ #
9
+ # @example
10
+ # Gitlab.epics(123)
11
+ # Gitlab.epics(123, { per_page: 40, page: 2 })
12
+ #
13
+ # @param [Integer] group_id The ID of a group.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @option options [Integer] :page The page number.
16
+ # @option options [Integer] :per_page The number of results per page.
17
+ # @return [Array<Gitlab::ObjectifiedHash>]
18
+ def epics(group_id, options = {})
19
+ get("/groups/#{group_id}/epics", query: options)
20
+ end
21
+
22
+ # Gets a single epic.
23
+ #
24
+ # @example
25
+ # Gitlab.epic(123, 1)
26
+ #
27
+ # @param [Integer] group_id The ID of a group.
28
+ # @param [Integer] epic_iid The ID of a epic.
29
+ # @param [Hash] options A customizable set of options.
30
+ # @return [Gitlab::ObjectifiedHash]
31
+ def epic(group_id, epic_iid, options = {})
32
+ get("/groups/#{group_id}/epics/#{epic_iid}", query: options)
33
+ end
34
+
35
+ # Creates a new epic.
36
+ #
37
+ # @example
38
+ # Gitlab.create_epic(123, "My new epic title")
39
+ #
40
+ # @param [Integer] group_id The ID of a group.
41
+ # @param [String] title
42
+ # @param [Hash] options A customizable set of options.
43
+ # @return [Gitlab::ObjectifiedHash] Information about created epic.
44
+ def create_epic(group_id, title, options = {})
45
+ body = options.merge(title: title)
46
+ post("/groups/#{group_id}/epics", body: body)
47
+ end
48
+
49
+ # Deletes an epic.
50
+ #
51
+ # @example
52
+ # Gitlab.delete_epic(42, 123)
53
+ # @param [Integer] group_id The ID of a group.
54
+ # @param [Integer] epic_iid The IID of an epic.
55
+ def delete_epic(group_id, epic_iid)
56
+ delete("/groups/#{group_id}/epics/#{epic_iid}")
57
+ end
58
+
59
+ # Updates an existing epic.
60
+ #
61
+ # @example
62
+ # Gitlab.edit_epic(42)
63
+ # Gitlab.edit_epic(42, 123, { title: 'New epic title' })
64
+ #
65
+ # @param [Integer] group_id The ID.
66
+ # @param [Integer] epic_iid The IID of an epic.
67
+ # @param [Hash] options A customizable set of options
68
+ # @return [Gitlab::ObjectifiedHash] Information about the edited epic.
69
+ def edit_epic(group_id, epic_iid, options = {})
70
+ put("/groups/#{group_id}/epics/#{epic_iid}", body: options)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to group badges.
5
+ # @see https://docs.gitlab.com/ee/api/group_badges.html
6
+ module GroupBadges
7
+ # Gets a list of a groups badges.
8
+ #
9
+ # @example
10
+ # Gitlab.group_badges(5)
11
+ # Gitlab.group_badges(5, 'Coverage')
12
+ #
13
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
14
+ # @param [String] name(optional) Name of the badges to return (case-sensitive).
15
+ # @return [Array<Gitlab::ObjectifiedHash>] List of all badges of a group
16
+ def group_badges(group, name = nil)
17
+ query = { name: name } if name
18
+ get("/groups/#{url_encode group}/badges", query: query)
19
+ end
20
+
21
+ # Gets a badge of a group.
22
+ #
23
+ # @example
24
+ # Gitlab.group_badge(5, 42)
25
+ #
26
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
27
+ # @param [Integer] badge_id(required) The badge ID.
28
+ # @return [Gitlab::ObjectifiedHash] Information about the requested badge
29
+ def group_badge(group, badge_id)
30
+ get("/groups/#{url_encode group}/badges/#{badge_id}")
31
+ end
32
+
33
+ # Adds a badge to a group.
34
+ #
35
+ # @example
36
+ # Gitlab.add_group_badge(5, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
37
+ #
38
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
39
+ # @param [Hash] options A customizable set of options.
40
+ # @option options [String] :link_url(required) URL of the badge link
41
+ # @option options [String] :image_url(required) URL of the badge image
42
+ # @return [Gitlab::ObjectifiedHash] Information about the added group badge.
43
+ def add_group_badge(group, options = {})
44
+ post("/groups/#{url_encode group}/badges", body: options)
45
+ end
46
+
47
+ # Updates a badge of a group.
48
+ #
49
+ # @example
50
+ # Gitlab.edit_group_badge(5, 1, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
51
+ #
52
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
53
+ # @param [Integer] badge_id(required) The badge ID.
54
+ # @param [Hash] options A customizable set of options.
55
+ # @option options [String] :link_url(optional) URL of the badge link
56
+ # @option options [String] :image_url(optional) URL of the badge image
57
+ # @return [Gitlab::ObjectifiedHash] Information about the updated group badge.
58
+ def edit_group_badge(group, badge_id, options = {})
59
+ put("/groups/#{url_encode group}/badges/#{badge_id}", body: options)
60
+ end
61
+
62
+ # Removes a badge from a group.
63
+ #
64
+ # @example
65
+ # Gitlab.remove_group_badge(5, 42)
66
+ #
67
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
68
+ # @param [Integer] badge_id(required) The badge ID.
69
+ # @return [nil] This API call returns an empty response body.
70
+ def remove_group_badge(group, badge_id)
71
+ delete("/groups/#{url_encode group}/badges/#{badge_id}")
72
+ end
73
+
74
+ # Preview a badge from a group.
75
+ #
76
+ # @example
77
+ # Gitlab.preview_group_badge(3, 'https://abc.com/gitlab/gitlab-ce/commits/master', 'https://shields.io/my/badge1')
78
+ #
79
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
80
+ # @param [String] :link_url(required) URL of the badge link
81
+ # @param [String] :image_url(required) URL of the badge image
82
+ # @return [Gitlab::ObjectifiedHash] Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation.
83
+ def preview_group_badge(group, link_url, image_url)
84
+ query = { link_url: link_url, image_url: image_url }
85
+ get("/groups/#{url_encode group}/badges/render", query: query)
86
+ end
87
+ end
88
+ end
@@ -58,7 +58,7 @@ class Gitlab::Client
58
58
  # @param [String] name The name of a label.
59
59
  # @return [Gitlab::ObjectifiedHash] Information about deleted label.
60
60
  def delete_group_label(group, name)
61
- delete("/groups/#{url_encode group}/labels", body: { name: name })
61
+ delete("/groups/#{url_encode group}/labels/#{name}")
62
62
  end
63
63
 
64
64
  # Subscribes the user to a group label to receive notifications
@@ -24,9 +24,12 @@ class Gitlab::Client
24
24
  # Gitlab.group(42)
25
25
  #
26
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)
27
30
  # @return [Gitlab::ObjectifiedHash]
28
- def group(id)
29
- get("/groups/#{url_encode id}")
31
+ def group(id, options = {})
32
+ get("/groups/#{url_encode id}", query: options)
30
33
  end
31
34
 
32
35
  # Creates a new group.
@@ -68,6 +71,55 @@ class Gitlab::Client
68
71
  get("/groups/#{url_encode id}/members", query: options)
69
72
  end
70
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
+
71
123
  # Get details of a single group member.
72
124
  #
73
125
  # @example
@@ -80,6 +132,18 @@ class Gitlab::Client
80
132
  get("/groups/#{url_encode team_id}/members/#{user_id}")
81
133
  end
82
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
+
83
147
  # Adds a user to group.
84
148
  #
85
149
  # @example
@@ -203,5 +267,92 @@ class Gitlab::Client
203
267
  def group_issues(group, options = {})
204
268
  get("/groups/#{group}/issues", query: options)
205
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
206
357
  end
207
358
  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
@@ -181,7 +181,7 @@ class Gitlab::Client
181
181
  # @param [Integer] id The ID of an issue.
182
182
  # @param [String] duration The time spent in human format. e.g: 3h30m
183
183
  def add_time_spent_on_issue(project, id, duration)
184
- post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: url_encode(duration) })
184
+ post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: duration })
185
185
  end
186
186
 
187
187
  # Resets the total spent time for this issue to 0 seconds.
@@ -36,6 +36,21 @@ class Gitlab::Client
36
36
  get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
37
37
  end
38
38
 
39
+ # Gets a list of Bridge Jobs from a pipeline
40
+ #
41
+ # @example
42
+ # Gitlab.pipeline_bridges(1, 2)
43
+ # Gitlab.pipeline_bridges("project", 2)
44
+ #
45
+ # @param [Integer, String] The ID or name of a project.
46
+ # @param [Integer] the id of the pipeline
47
+ # @param [Hash] options A customizable set of options.
48
+ # @option options [Array] :scope The scope of bridge jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all bridge jobs if none provided.
49
+ # @return [Array<Gitlab::ObjectifiedHash>]
50
+ def pipeline_bridges(project_id, pipeline_id, options = {})
51
+ get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/bridges", query: options)
52
+ end
53
+
39
54
  # Gets a single job
40
55
  #
41
56
  # @example
@@ -70,17 +85,71 @@ class Gitlab::Client
70
85
  # Gitlab.job_artifacts_download(1, "master", "release")
71
86
  # Gitlab.job_artifacts_download("project", "master", "release")
72
87
  #
73
- # @param [Integer, String] id, The ID or name of a project.
74
- # @param [String] ref, Ref Name
75
- # @param [String] job, jobname
76
- # @return [Array<Gitlab::ObjectifiedHash>]
88
+ # @param [Integer, String] project_id The ID or name of a project.
89
+ # @param [String] ref Ref Name
90
+ # @param [String] job jobname
91
+ # @return [Gitlab::FileResponse]
77
92
  def job_artifacts_download(project_id, ref_name, job_name)
78
- get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download", query: { job: job_name },
79
- format: nil,
80
- headers: { Accept: 'text/plain' },
81
- parser: ::Gitlab::Request::Parser)
93
+ get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
94
+ query: { job: job_name },
95
+ format: nil,
96
+ headers: { Accept: 'application/octet-stream' },
97
+ parser: proc { |body, _|
98
+ if body.encoding == Encoding::ASCII_8BIT # binary response
99
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
100
+ else # error with json response
101
+ ::Gitlab::Request.parse(body)
102
+ end
103
+ })
82
104
  end
83
105
 
106
+ # Download a single artifact file by job ID
107
+ #
108
+ # @example
109
+ # Gitlab.download_job_artifact_file(1, 5, "some/release/file.pdf")
110
+ #
111
+ # @param [Integer, String] project_id(required) The ID or name of a project.
112
+ # @param [String] job_id(required) The unique job identifier.
113
+ # @param [String] artifact_path(required) Path to a file inside the artifacts archive.
114
+ # @return [Gitlab::FileResponse]
115
+ def download_job_artifact_file(project_id, job_id, artifact_path)
116
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/#{artifact_path}",
117
+ format: nil,
118
+ headers: { Accept: 'application/octet-stream' },
119
+ parser: proc { |body, _|
120
+ if body.encoding == Encoding::ASCII_8BIT # binary response
121
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
122
+ else # error with json response
123
+ ::Gitlab::Request.parse(body)
124
+ end
125
+ })
126
+ end
127
+
128
+ # Download a single artifact file from specific tag or branch
129
+ #
130
+ # @example
131
+ # Gitlab.download_branch_artifact_file(1, "master", "some/release/file.pdf", 'pdf')
132
+ #
133
+ # @param [Integer, String] project_id(required) The ID or name of a project.
134
+ # @param [String] ref_name(required) Branch or tag name in repository. HEAD or SHA references are not supported.
135
+ # @param [String] artifact_path(required) Path to a file inside the artifacts archive.
136
+ # @param [String] job(required) The name of the job.
137
+ # @return [Gitlab::FileResponse]
138
+ def download_branch_artifact_file(project_id, ref_name, artifact_path, job)
139
+ get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/raw/#{artifact_path}",
140
+ query: { job: job },
141
+ format: nil,
142
+ headers: { Accept: 'application/octet-stream' },
143
+ parser: proc { |body, _|
144
+ if body.encoding == Encoding::ASCII_8BIT # binary response
145
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
146
+ else # error with json response
147
+ ::Gitlab::Request.parse(body)
148
+ end
149
+ })
150
+ end
151
+ alias download_tag_artifact_file download_branch_artifact_file
152
+
84
153
  # Get Job Trace
85
154
  #
86
155
  # @example
@@ -163,5 +232,19 @@ class Gitlab::Client
163
232
  def job_artifacts_keep(project_id, job_id)
164
233
  post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep")
165
234
  end
235
+
236
+ # Delete Artifacts
237
+ # Deletes the artifacts associated with a job.
238
+ #
239
+ # @example
240
+ # Gitlab.job_artifacts_delete(1,1)
241
+ # Gitlab.job_artifacts_delete("project", 1)
242
+ #
243
+ # @param [Integer, String] The ID or name of a project.
244
+ # @param [Integer] the id of the job
245
+ # @return [Array<Gitlab::ObjectifiedHash>]
246
+ def job_artifacts_delete(project_id, job_id)
247
+ delete("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts")
248
+ end
166
249
  end
167
250
  end
@@ -14,5 +14,16 @@ class Gitlab::Client
14
14
  def key(id)
15
15
  get("/keys/#{id}")
16
16
  end
17
+
18
+ # Gets information about a key by key fingerprint.
19
+ #
20
+ # @example
21
+ # Gitlab.key_by_fingerprint("9f:70:33:b3:50:4d:9a:a3:ef:ea:13:9b:87:0f:7f:7e")
22
+ #
23
+ # @param [String] fingerprint The Fingerprint of a key.
24
+ # @return [Gitlab::ObjectifiedHash]
25
+ def key_by_fingerprint(fingerprint)
26
+ get('/keys', query: { fingerprint: fingerprint })
27
+ end
17
28
  end
18
29
  end
@@ -58,7 +58,7 @@ class Gitlab::Client
58
58
  # @param [String] name The name of a label.
59
59
  # @return [Gitlab::ObjectifiedHash] Information about deleted label.
60
60
  def delete_label(project, name)
61
- delete("/projects/#{url_encode project}/labels", body: { name: name })
61
+ delete("/projects/#{url_encode project}/labels/#{name}")
62
62
  end
63
63
 
64
64
  # Subscribes the user to a label to receive notifications