gitlab 4.2.0 → 4.18.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 (271) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +4 -2
  3. data/LICENSE.txt +1 -1
  4. data/README.md +96 -25
  5. data/exe/gitlab +5 -1
  6. data/lib/gitlab/api.rb +8 -3
  7. data/lib/gitlab/cli.rb +15 -15
  8. data/lib/gitlab/cli_helpers.rb +63 -61
  9. data/lib/gitlab/client/access_requests.rb +103 -0
  10. data/lib/gitlab/client/application_settings.rb +172 -0
  11. data/lib/gitlab/client/avatar.rb +21 -0
  12. data/lib/gitlab/client/award_emojis.rb +5 -3
  13. data/lib/gitlab/client/boards.rb +62 -4
  14. data/lib/gitlab/client/branches.rb +53 -14
  15. data/lib/gitlab/client/broadcast_messages.rb +75 -0
  16. data/lib/gitlab/client/build_variables.rb +78 -9
  17. data/lib/gitlab/client/builds.rb +13 -11
  18. data/lib/gitlab/client/commits.rb +89 -19
  19. data/lib/gitlab/client/container_registry.rb +85 -0
  20. data/lib/gitlab/client/deployments.rb +34 -0
  21. data/lib/gitlab/client/environments.rb +5 -3
  22. data/lib/gitlab/client/epic_issues.rb +23 -0
  23. data/lib/gitlab/client/epics.rb +73 -0
  24. data/lib/gitlab/client/events.rb +60 -0
  25. data/lib/gitlab/client/features.rb +48 -0
  26. data/lib/gitlab/client/group_badges.rb +88 -0
  27. data/lib/gitlab/client/group_boards.rb +141 -0
  28. data/lib/gitlab/client/group_labels.rb +88 -0
  29. data/lib/gitlab/client/group_milestones.rb +94 -0
  30. data/lib/gitlab/client/groups.rb +197 -17
  31. data/lib/gitlab/client/issue_links.rb +48 -0
  32. data/lib/gitlab/client/issues.rb +98 -4
  33. data/lib/gitlab/client/jobs.rb +96 -8
  34. data/lib/gitlab/client/keys.rb +13 -0
  35. data/lib/gitlab/client/labels.rb +7 -5
  36. data/lib/gitlab/client/lint.rb +19 -0
  37. data/lib/gitlab/client/markdown.rb +23 -0
  38. data/lib/gitlab/client/merge_request_approvals.rb +265 -0
  39. data/lib/gitlab/client/merge_requests.rb +237 -9
  40. data/lib/gitlab/client/milestones.rb +19 -5
  41. data/lib/gitlab/client/namespaces.rb +4 -2
  42. data/lib/gitlab/client/notes.rb +58 -12
  43. data/lib/gitlab/client/pipeline_schedules.rb +147 -0
  44. data/lib/gitlab/client/pipeline_triggers.rb +12 -10
  45. data/lib/gitlab/client/pipelines.rb +40 -3
  46. data/lib/gitlab/client/project_badges.rb +85 -0
  47. data/lib/gitlab/client/project_clusters.rb +83 -0
  48. data/lib/gitlab/client/project_release_links.rb +76 -0
  49. data/lib/gitlab/client/project_releases.rb +79 -0
  50. data/lib/gitlab/client/projects.rb +280 -47
  51. data/lib/gitlab/client/protected_tags.rb +59 -0
  52. data/lib/gitlab/client/remote_mirrors.rb +51 -0
  53. data/lib/gitlab/client/repositories.rb +60 -6
  54. data/lib/gitlab/client/repository_files.rb +23 -5
  55. data/lib/gitlab/client/repository_submodules.rb +27 -0
  56. data/lib/gitlab/client/resource_label_events.rb +82 -0
  57. data/lib/gitlab/client/resource_state_events.rb +57 -0
  58. data/lib/gitlab/client/runners.rb +111 -15
  59. data/lib/gitlab/client/search.rb +66 -0
  60. data/lib/gitlab/client/services.rb +4 -1
  61. data/lib/gitlab/client/sidekiq.rb +39 -0
  62. data/lib/gitlab/client/snippets.rb +8 -4
  63. data/lib/gitlab/client/system_hooks.rb +9 -7
  64. data/lib/gitlab/client/tags.rb +15 -14
  65. data/lib/gitlab/client/templates.rb +100 -0
  66. data/lib/gitlab/client/todos.rb +7 -5
  67. data/lib/gitlab/client/user_snippets.rb +114 -0
  68. data/lib/gitlab/client/users.rb +166 -30
  69. data/lib/gitlab/client/versions.rb +18 -0
  70. data/lib/gitlab/client/wikis.rb +79 -0
  71. data/lib/gitlab/client.rb +49 -12
  72. data/lib/gitlab/configuration.rb +8 -6
  73. data/lib/gitlab/error.rb +74 -5
  74. data/lib/gitlab/file_response.rb +5 -3
  75. data/lib/gitlab/help.rb +19 -20
  76. data/lib/gitlab/objectified_hash.rb +27 -10
  77. data/lib/gitlab/page_links.rb +11 -9
  78. data/lib/gitlab/paginated_response.rb +37 -24
  79. data/lib/gitlab/request.rb +42 -53
  80. data/lib/gitlab/shell.rb +11 -12
  81. data/lib/gitlab/shell_history.rb +11 -13
  82. data/lib/gitlab/version.rb +3 -1
  83. data/lib/gitlab.rb +19 -8
  84. metadata +50 -395
  85. data/.gitignore +0 -22
  86. data/.travis.yml +0 -8
  87. data/CONTRIBUTING.md +0 -195
  88. data/Gemfile +0 -4
  89. data/Rakefile +0 -9
  90. data/bin/console +0 -10
  91. data/bin/setup +0 -6
  92. data/gitlab.gemspec +0 -31
  93. data/spec/fixtures/board_list.json +0 -1
  94. data/spec/fixtures/board_lists.json +0 -1
  95. data/spec/fixtures/boards.json +0 -1
  96. data/spec/fixtures/branch.json +0 -1
  97. data/spec/fixtures/branch_delete.json +0 -3
  98. data/spec/fixtures/branches.json +0 -1
  99. data/spec/fixtures/build.json +0 -38
  100. data/spec/fixtures/build_artifacts.json +0 -0
  101. data/spec/fixtures/build_cancel.json +0 -24
  102. data/spec/fixtures/build_erase.json +0 -24
  103. data/spec/fixtures/build_retry.json +0 -24
  104. data/spec/fixtures/builds.json +0 -78
  105. data/spec/fixtures/builds_commits.json +0 -64
  106. data/spec/fixtures/compare_merge_request_diff.json +0 -31
  107. data/spec/fixtures/empty.json +0 -0
  108. data/spec/fixtures/environment.json +0 -6
  109. data/spec/fixtures/environments.json +0 -14
  110. data/spec/fixtures/error_already_exists.json +0 -1
  111. data/spec/fixtures/error_project_not_found.json +0 -1
  112. data/spec/fixtures/get_repository_file.json +0 -1
  113. data/spec/fixtures/group.json +0 -60
  114. data/spec/fixtures/group_create.json +0 -1
  115. data/spec/fixtures/group_create_with_description.json +0 -1
  116. data/spec/fixtures/group_delete.json +0 -1
  117. data/spec/fixtures/group_member.json +0 -1
  118. data/spec/fixtures/group_member_delete.json +0 -1
  119. data/spec/fixtures/group_member_edit.json +0 -1
  120. data/spec/fixtures/group_members.json +0 -1
  121. data/spec/fixtures/group_projects.json +0 -44
  122. data/spec/fixtures/group_search.json +0 -2
  123. data/spec/fixtures/groups.json +0 -2
  124. data/spec/fixtures/issue.json +0 -1
  125. data/spec/fixtures/issue_award_emoji.json +0 -16
  126. data/spec/fixtures/issue_award_emojis.json +0 -34
  127. data/spec/fixtures/issues.json +0 -1
  128. data/spec/fixtures/job.json +0 -43
  129. data/spec/fixtures/job_trace.json +0 -1
  130. data/spec/fixtures/jobs.json +0 -91
  131. data/spec/fixtures/key.json +0 -1
  132. data/spec/fixtures/keys.json +0 -1
  133. data/spec/fixtures/label.json +0 -1
  134. data/spec/fixtures/label_unsubscribe.json +0 -1
  135. data/spec/fixtures/labels.json +0 -1
  136. data/spec/fixtures/merge_request.json +0 -1
  137. data/spec/fixtures/merge_request_award_emoji.json +0 -16
  138. data/spec/fixtures/merge_request_award_emojis.json +0 -34
  139. data/spec/fixtures/merge_request_changes.json +0 -1
  140. data/spec/fixtures/merge_request_closes_issues.json +0 -1
  141. data/spec/fixtures/merge_request_comment.json +0 -1
  142. data/spec/fixtures/merge_request_comments.json +0 -1
  143. data/spec/fixtures/merge_request_commits.json +0 -1
  144. data/spec/fixtures/merge_requests.json +0 -1
  145. data/spec/fixtures/milestone.json +0 -1
  146. data/spec/fixtures/milestone_issues.json +0 -1
  147. data/spec/fixtures/milestone_merge_requests.json +0 -1
  148. data/spec/fixtures/milestones.json +0 -1
  149. data/spec/fixtures/namespaces.json +0 -1
  150. data/spec/fixtures/note.json +0 -1
  151. data/spec/fixtures/note_award_emoji.json +0 -16
  152. data/spec/fixtures/note_award_emojis.json +0 -18
  153. data/spec/fixtures/notes.json +0 -1
  154. data/spec/fixtures/pipeline.json +0 -23
  155. data/spec/fixtures/pipeline_cancel.json +0 -23
  156. data/spec/fixtures/pipeline_create.json +0 -23
  157. data/spec/fixtures/pipeline_jobs.json +0 -91
  158. data/spec/fixtures/pipeline_retry.json +0 -23
  159. data/spec/fixtures/pipelines.json +0 -48
  160. data/spec/fixtures/project.json +0 -1
  161. data/spec/fixtures/project_commit.json +0 -13
  162. data/spec/fixtures/project_commit_comment.json +0 -1
  163. data/spec/fixtures/project_commit_comments.json +0 -1
  164. data/spec/fixtures/project_commit_create.json +0 -22
  165. data/spec/fixtures/project_commit_diff.json +0 -10
  166. data/spec/fixtures/project_commit_status.json +0 -42
  167. data/spec/fixtures/project_commits.json +0 -1
  168. data/spec/fixtures/project_edit.json +0 -21
  169. data/spec/fixtures/project_events.json +0 -1
  170. data/spec/fixtures/project_for_user.json +0 -1
  171. data/spec/fixtures/project_fork.json +0 -50
  172. data/spec/fixtures/project_fork_link.json +0 -1
  173. data/spec/fixtures/project_forked_for_user.json +0 -50
  174. data/spec/fixtures/project_hook.json +0 -1
  175. data/spec/fixtures/project_hooks.json +0 -1
  176. data/spec/fixtures/project_issues.json +0 -1
  177. data/spec/fixtures/project_key.json +0 -6
  178. data/spec/fixtures/project_keys.json +0 -6
  179. data/spec/fixtures/project_runner_enable.json +0 -7
  180. data/spec/fixtures/project_runners.json +0 -16
  181. data/spec/fixtures/project_search.json +0 -1
  182. data/spec/fixtures/project_star.json +0 -44
  183. data/spec/fixtures/project_tag_annotated.json +0 -1
  184. data/spec/fixtures/project_tag_lightweight.json +0 -1
  185. data/spec/fixtures/project_tags.json +0 -1
  186. data/spec/fixtures/project_unstar.json +0 -44
  187. data/spec/fixtures/project_update_commit_status.json +0 -20
  188. data/spec/fixtures/projects.json +0 -1
  189. data/spec/fixtures/push_rule.json +0 -1
  190. data/spec/fixtures/raw_file.json +0 -2
  191. data/spec/fixtures/release_create.json +0 -1
  192. data/spec/fixtures/release_update.json +0 -1
  193. data/spec/fixtures/repository_file.json +0 -1
  194. data/spec/fixtures/run_trigger.json +0 -1
  195. data/spec/fixtures/runner.json +0 -26
  196. data/spec/fixtures/runner_delete.json +0 -7
  197. data/spec/fixtures/runner_edit.json +0 -26
  198. data/spec/fixtures/runners.json +0 -16
  199. data/spec/fixtures/runners_all.json +0 -30
  200. data/spec/fixtures/service.json +0 -1
  201. data/spec/fixtures/session.json +0 -1
  202. data/spec/fixtures/shell_history.json +0 -2
  203. data/spec/fixtures/snippet.json +0 -1
  204. data/spec/fixtures/snippet_award_emoji.json +0 -16
  205. data/spec/fixtures/snippet_award_emojis.json +0 -34
  206. data/spec/fixtures/snippet_content.json +0 -3
  207. data/spec/fixtures/snippets.json +0 -1
  208. data/spec/fixtures/system_hook.json +0 -1
  209. data/spec/fixtures/system_hooks.json +0 -1
  210. data/spec/fixtures/tag.json +0 -1
  211. data/spec/fixtures/tag_create.json +0 -1
  212. data/spec/fixtures/tag_create_with_description.json +0 -1
  213. data/spec/fixtures/tag_delete.json +0 -1
  214. data/spec/fixtures/tags.json +0 -1
  215. data/spec/fixtures/team_member.json +0 -1
  216. data/spec/fixtures/team_members.json +0 -1
  217. data/spec/fixtures/todo.json +0 -73
  218. data/spec/fixtures/todos.json +0 -148
  219. data/spec/fixtures/tree.json +0 -1
  220. data/spec/fixtures/trigger.json +0 -10
  221. data/spec/fixtures/triggers.json +0 -12
  222. data/spec/fixtures/user.json +0 -1
  223. data/spec/fixtures/user_block_unblock.json +0 -1
  224. data/spec/fixtures/user_email.json +0 -1
  225. data/spec/fixtures/user_emails.json +0 -1
  226. data/spec/fixtures/user_search.json +0 -1
  227. data/spec/fixtures/users.json +0 -1
  228. data/spec/fixtures/variable.json +0 -4
  229. data/spec/fixtures/variables.json +0 -10
  230. data/spec/gitlab/cli_helpers_spec.rb +0 -57
  231. data/spec/gitlab/cli_spec.rb +0 -119
  232. data/spec/gitlab/client/award_emojis_spec.rb +0 -391
  233. data/spec/gitlab/client/boards_spec.rb +0 -94
  234. data/spec/gitlab/client/branches_spec.rb +0 -116
  235. data/spec/gitlab/client/build_variables_spec.rb +0 -86
  236. data/spec/gitlab/client/builds_spec.rb +0 -148
  237. data/spec/gitlab/client/client_spec.rb +0 -11
  238. data/spec/gitlab/client/commits_spec.rb +0 -168
  239. data/spec/gitlab/client/environments_spec.rb +0 -132
  240. data/spec/gitlab/client/groups_spec.rb +0 -195
  241. data/spec/gitlab/client/issues_spec.rb +0 -186
  242. data/spec/gitlab/client/jobs_spec.rb +0 -135
  243. data/spec/gitlab/client/keys_spec.rb +0 -19
  244. data/spec/gitlab/client/labels_spec.rb +0 -100
  245. data/spec/gitlab/client/merge_requests_spec.rb +0 -224
  246. data/spec/gitlab/client/milestones_spec.rb +0 -98
  247. data/spec/gitlab/client/namespaces_spec.rb +0 -22
  248. data/spec/gitlab/client/notes_spec.rb +0 -333
  249. data/spec/gitlab/client/pipeline_triggers_spec.rb +0 -157
  250. data/spec/gitlab/client/pipelines_spec.rb +0 -95
  251. data/spec/gitlab/client/projects_spec.rb +0 -613
  252. data/spec/gitlab/client/repositories_spec.rb +0 -94
  253. data/spec/gitlab/client/repository_files_spec.rb +0 -95
  254. data/spec/gitlab/client/runners_spec.rb +0 -185
  255. data/spec/gitlab/client/services_spec.rb +0 -55
  256. data/spec/gitlab/client/snippets_spec.rb +0 -100
  257. data/spec/gitlab/client/system_hooks_spec.rb +0 -69
  258. data/spec/gitlab/client/tags_spec.rb +0 -109
  259. data/spec/gitlab/client/todos_spec.rb +0 -45
  260. data/spec/gitlab/client/users_spec.rb +0 -418
  261. data/spec/gitlab/error_spec.rb +0 -45
  262. data/spec/gitlab/file_response_spec.rb +0 -33
  263. data/spec/gitlab/help_spec.rb +0 -46
  264. data/spec/gitlab/objectified_hash_spec.rb +0 -48
  265. data/spec/gitlab/page_links_spec.rb +0 -16
  266. data/spec/gitlab/paginated_response_spec.rb +0 -60
  267. data/spec/gitlab/request_spec.rb +0 -73
  268. data/spec/gitlab/shell_history_spec.rb +0 -53
  269. data/spec/gitlab/shell_spec.rb +0 -80
  270. data/spec/gitlab_spec.rb +0 -97
  271. data/spec/spec_helper.rb +0 -74
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to milestones.
3
5
  # @see https://docs.gitlab.com/ce/api/milestones.html
@@ -12,7 +14,7 @@ class Gitlab::Client
12
14
  # @option options [Integer] :page The page number.
13
15
  # @option options [Integer] :per_page The number of results per page.
14
16
  # @return [Array<Gitlab::ObjectifiedHash>]
15
- def milestones(project, options={})
17
+ def milestones(project, options = {})
16
18
  get("/projects/#{url_encode project}/milestones", query: options)
17
19
  end
18
20
 
@@ -38,7 +40,7 @@ class Gitlab::Client
38
40
  # @option options [Integer] :page The page number.
39
41
  # @option options [Integer] :per_page The number of results per page.
40
42
  # @return [Array<Gitlab::ObjectifiedHash>]
41
- def milestone_issues(project, milestone, options={})
43
+ def milestone_issues(project, milestone, options = {})
42
44
  get("/projects/#{url_encode project}/milestones/#{milestone}/issues", query: options)
43
45
  end
44
46
 
@@ -52,7 +54,7 @@ class Gitlab::Client
52
54
  # @option options [Integer] :page The page number.
53
55
  # @option options [Integer] :per_page The number of results per page.
54
56
  # @return [Array<Gitlab::ObjectifiedHash>]
55
- def milestone_merge_requests(project, milestone, options={})
57
+ def milestone_merge_requests(project, milestone, options = {})
56
58
  get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options)
57
59
  end
58
60
 
@@ -67,7 +69,7 @@ class Gitlab::Client
67
69
  # @option options [String] :description The description of a milestone.
68
70
  # @option options [String] :due_date The due date of a milestone.
69
71
  # @return [Gitlab::ObjectifiedHash] Information about created milestone.
70
- def create_milestone(project, title, options={})
72
+ def create_milestone(project, title, options = {})
71
73
  body = { title: title }.merge(options)
72
74
  post("/projects/#{url_encode project}/milestones", body: body)
73
75
  end
@@ -85,8 +87,20 @@ class Gitlab::Client
85
87
  # @option options [String] :due_date The due date of a milestone.
86
88
  # @option options [String] :state_event The state of a milestone ('close' or 'activate').
87
89
  # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
88
- def edit_milestone(project, id, options={})
90
+ def edit_milestone(project, id, options = {})
89
91
  put("/projects/#{url_encode project}/milestones/#{id}", body: options)
90
92
  end
93
+
94
+ # Delete a project milestone.
95
+ #
96
+ # @example
97
+ # Gitlab.delete_milestone(5, 2)
98
+ #
99
+ # @param [Integer, String] project The ID or name of a project.
100
+ # @param [Integer] id The ID of a milestone.
101
+ # @return [nil] This API call returns an empty response body.
102
+ def delete_milestone(project, id)
103
+ delete("/projects/#{url_encode project}/milestones/#{id}")
104
+ end
91
105
  end
92
106
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to namespaces
3
5
  # @see https://docs.gitlab.com/ce/api/namespaces.html
@@ -13,8 +15,8 @@ class Gitlab::Client
13
15
  # @options options [Integer] :per_page The number of results per page.
14
16
  # @options opttion [String] :search The string to search for.
15
17
  # @return [Array<Gitlab::ObjectifiedHash>]
16
- def namespaces(options={})
17
- get("/namespaces", query: options)
18
+ def namespaces(options = {})
19
+ get('/namespaces', query: options)
18
20
  end
19
21
  end
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to notes.
3
5
  # @see https://docs.gitlab.com/ce/api/notes.html
@@ -11,7 +13,7 @@ class Gitlab::Client
11
13
  # @option options [Integer] :page The page number.
12
14
  # @option options [Integer] :per_page The number of results per page.
13
15
  # @return [Array<Gitlab::ObjectifiedHash>]
14
- def notes(project, options={})
16
+ def notes(project, options = {})
15
17
  get("/projects/#{url_encode project}/notes", query: options)
16
18
  end
17
19
 
@@ -25,7 +27,7 @@ class Gitlab::Client
25
27
  # @option options [Integer] :page The page number.
26
28
  # @option options [Integer] :per_page The number of results per page.
27
29
  # @return [Array<Gitlab::ObjectifiedHash>]
28
- def issue_notes(project, issue, options={})
30
+ def issue_notes(project, issue, options = {})
29
31
  get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options)
30
32
  end
31
33
 
@@ -39,7 +41,7 @@ class Gitlab::Client
39
41
  # @option options [Integer] :page The page number.
40
42
  # @option options [Integer] :per_page The number of results per page.
41
43
  # @return [Array<Gitlab::ObjectifiedHash>]
42
- def snippet_notes(project, snippet, options={})
44
+ def snippet_notes(project, snippet, options = {})
43
45
  get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options)
44
46
  end
45
47
 
@@ -53,10 +55,24 @@ class Gitlab::Client
53
55
  # @option options [Integer] :page The page number.
54
56
  # @option options [Integer] :per_page The number of results per page.
55
57
  # @return [Array<Gitlab::ObjectifiedHash>]
56
- def merge_request_notes(project, merge_request, options={})
58
+ def merge_request_notes(project, merge_request, options = {})
57
59
  get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
58
60
  end
59
- alias_method :merge_request_comments, :merge_request_notes
61
+ alias merge_request_comments merge_request_notes
62
+
63
+ # Gets a list of notes for an epic.
64
+ #
65
+ # @example
66
+ # Gitlab.epic_notes(5, 10)
67
+ #
68
+ # @param [Integer] project The ID of a group.
69
+ # @param [Integer] epic The ID of an epic.
70
+ # @option options [Integer] :page The page number.
71
+ # @option options [Integer] :per_page The number of results per page.
72
+ # @return [Array<Gitlab::ObjectifiedHash>]
73
+ def epic_notes(group, epic, options = {})
74
+ get("/groups/#{url_encode group}/epics/#{epic}/notes", query: options)
75
+ end
60
76
 
61
77
  # Gets a single wall note.
62
78
  #
@@ -158,7 +174,20 @@ class Gitlab::Client
158
174
  def create_merge_request_note(project, merge_request, body)
159
175
  post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
160
176
  end
161
- alias_method :create_merge_request_comment, :create_merge_request_note
177
+ alias create_merge_request_comment create_merge_request_note
178
+
179
+ # Creates a new epic note.
180
+ #
181
+ # @example
182
+ # Gitlab.create_epic_note(6, 1, 'Adding a note to my epic.')
183
+ #
184
+ # @param [Integer, String] group The ID or name of a group.
185
+ # @param [Integer] epic The ID of an epic.
186
+ # @param [String] body The body of a note.
187
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
188
+ def create_epic_note(group, epic, body)
189
+ post("/groups/#{url_encode group}/epics/#{epic}/notes", body: { body: body })
190
+ end
162
191
 
163
192
  # Deletes a wall note.
164
193
  #
@@ -210,7 +239,7 @@ class Gitlab::Client
210
239
  def delete_merge_request_note(project, merge_request, id)
211
240
  delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
212
241
  end
213
- alias_method :delete_merge_request_comment, :delete_merge_request_note
242
+ alias delete_merge_request_comment delete_merge_request_note
214
243
 
215
244
  # Modifies a wall note.
216
245
  #
@@ -219,9 +248,10 @@ class Gitlab::Client
219
248
  #
220
249
  # @param [Integer] project The ID of a project.
221
250
  # @param [Integer] id The ID of a note.
251
+ # @param [String] body The content of a note.
222
252
  # @return [Gitlab::ObjectifiedHash]
223
253
  def edit_note(project, id, body)
224
- put("/projects/#{url_encode project}/notes/#{id}", body: body)
254
+ put("/projects/#{url_encode project}/notes/#{id}", body: note_content(body))
225
255
  end
226
256
 
227
257
  # Modifies an issue note.
@@ -232,9 +262,10 @@ class Gitlab::Client
232
262
  # @param [Integer] project The ID of a project.
233
263
  # @param [Integer] issue The ID of an issue.
234
264
  # @param [Integer] id The ID of a note.
265
+ # @param [String] body The content of a note.
235
266
  # @return [Gitlab::ObjectifiedHash]
236
267
  def edit_issue_note(project, issue, id, body)
237
- put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: body)
268
+ put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: note_content(body))
238
269
  end
239
270
 
240
271
  # Modifies a snippet note.
@@ -245,9 +276,10 @@ class Gitlab::Client
245
276
  # @param [Integer] project The ID of a project.
246
277
  # @param [Integer] snippet The ID of a snippet.
247
278
  # @param [Integer] id The ID of a note.
279
+ # @param [String] body The content of a note.
248
280
  # @return [Gitlab::ObjectifiedHash]
249
281
  def edit_snippet_note(project, snippet, id, body)
250
- put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: body)
282
+ put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: note_content(body))
251
283
  end
252
284
 
253
285
  # Modifies a merge_request note.
@@ -258,10 +290,24 @@ class Gitlab::Client
258
290
  # @param [Integer] project The ID of a project.
259
291
  # @param [Integer] merge_request The ID of a merge_request.
260
292
  # @param [Integer] id The ID of a note.
293
+ # @param [String] body The content of a note.
261
294
  # @return [Gitlab::ObjectifiedHash]
262
295
  def edit_merge_request_note(project, merge_request, id, body)
263
- put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: 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
264
311
  end
265
- alias_method :edit_merge_request_comment, :edit_merge_request_note
266
312
  end
267
313
  end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to pipeline schedules.
5
+ # @see https://docs.gitlab.com/ce/api/pipeline_schedules.html
6
+ module PipelineSchedules
7
+ # Gets a list of project pipeline schedules.
8
+ #
9
+ # @example
10
+ # Gitlab.pipeline_schedules(5)
11
+ # Gitlab.pipeline_schedules(5, { scope: 'active' })
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] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'.
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def pipeline_schedules(project, options = {})
18
+ get("/projects/#{url_encode project}/pipeline_schedules", query: options)
19
+ end
20
+
21
+ # Gets a single pipeline schedule.
22
+ #
23
+ # @example
24
+ # Gitlab.pipeline_schedule(5, 3)
25
+ #
26
+ # @param [Integer, String] project The ID or name of a project.
27
+ # @param [Integer] id The ID of the pipeline schedule.
28
+ # @return [Gitlab::ObjectifiedHash]
29
+ def pipeline_schedule(project, id)
30
+ get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
31
+ end
32
+
33
+ # Create a pipeline schedule.
34
+ #
35
+ # @example
36
+ # Gitlab.create_pipeline_schedule(5, { description: 'example' })
37
+ #
38
+ # @param [Integer, String] project The ID or name of a project.
39
+ # @param [Hash] options A customizable set of options.
40
+ # @option options [String] :description The description of pipeline scehdule.
41
+ # @option options [String] :ref The branch/tag name will be triggered.
42
+ # @option options [String] :cron The cron (e.g. 0 1 * * *).
43
+ # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
44
+ # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
45
+ # @return [Array<Gitlab::ObjectifiedHash>]
46
+ def create_pipeline_schedule(project, options = {})
47
+ post("/projects/#{url_encode project}/pipeline_schedules", body: options)
48
+ end
49
+
50
+ # Updates the pipeline schedule of a project.
51
+ #
52
+ # @example
53
+ # Gitlab.edit_pipeline_schedule(3, 2, { description: 'example2' })
54
+ #
55
+ # @param [Integer, String] project The ID or name of a project.
56
+ # @param [Integer] The pipeline schedule ID.
57
+ # @param [Hash] options A customizable set of options.
58
+ # @option options [String] :description The description of pipeline scehdule.
59
+ # @option options [String] :ref The branch/tag name will be triggered.
60
+ # @option options [String] :cron The cron (e.g. 0 1 * * *).
61
+ # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
62
+ # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
63
+ # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
64
+ def edit_pipeline_schedule(project, pipeline_schedule_id, options = {})
65
+ put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", body: options)
66
+ end
67
+
68
+ # Take ownership of a pipeline schedule.
69
+ #
70
+ # @example
71
+ # Gitlab.pipeline_schedule_take_ownership(5, 1)
72
+ #
73
+ # @param [Integer, String] project The ID or name of a project.
74
+ # @param [Integer] trigger_id The pipeline schedule ID.
75
+ # @return [Gitlab::ObjectifiedHash] The updated pipeline schedule.
76
+ def pipeline_schedule_take_ownership(project, pipeline_schedule_id)
77
+ post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
78
+ end
79
+
80
+ # Run a scheduled pipeline immediately.
81
+ #
82
+ # @example
83
+ # Gitlab.run_pipeline_schedule(5, 1)
84
+ #
85
+ # @param [Integer, String] project The ID or name of a project.
86
+ # @param [Integer] trigger_id The pipeline schedule ID.
87
+ # @return [Gitlab::ObjectifiedHash] Pipeline created message.
88
+ def run_pipeline_schedule(project, pipeline_schedule_id)
89
+ post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/play")
90
+ end
91
+
92
+ # Delete a pipeline schedule.
93
+ #
94
+ # @example
95
+ # Gitlab.delete_pipeline_schedule(5, 1)
96
+ #
97
+ # @param [Integer, String] project The ID or name of a project.
98
+ # @param [Integer] trigger_id The pipeline schedule ID.
99
+ # @return [Gitlab::ObjectifiedHash] The deleted pipeline schedule.
100
+ def delete_pipeline_schedule(project, pipeline_schedule_id)
101
+ delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}")
102
+ end
103
+
104
+ # Create a pipeline schedule variable.
105
+ #
106
+ # @example
107
+ # Gitlab.create_pipeline_schedule_variable(5, 1, { key: 'foo', value: 'bar' })
108
+ #
109
+ # @param [Integer, String] project The ID or name of a project.
110
+ # @param [Integer] trigger_id The pipeline schedule ID.
111
+ # @param [Hash] options A customizable set of options.
112
+ # @option options [String] :key The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed.
113
+ # @option options [String] :value The value of a variable
114
+ # @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
115
+ def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {})
116
+ post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", body: options)
117
+ end
118
+
119
+ # Updates the variable of a pipeline schedule.
120
+ #
121
+ # @example
122
+ # Gitlab.edit_pipeline_schedule_variable(3, 2, "foo" { value: 'bar' })
123
+ #
124
+ # @param [Integer, String] project The ID or name of a project.
125
+ # @param [Integer] The pipeline schedule ID.
126
+ # @param [String] The key of a variable.
127
+ # @param [Hash] options A customizable set of options.
128
+ # @option options [String] :value The value of a variable.
129
+ # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
130
+ def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options = {})
131
+ put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", body: options)
132
+ end
133
+
134
+ # Delete the variable of a pipeline schedule
135
+ #
136
+ # @example
137
+ # Gitlab.delete_pipeline_schedule_variable(3, 2, "foo")
138
+ #
139
+ # @param [Integer, String] project The ID or name of a project.
140
+ # @param [Integer] The pipeline schedule ID.
141
+ # @param [String] The key of a variable.
142
+ # @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable.
143
+ def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, _options = {})
144
+ delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}")
145
+ end
146
+ end
147
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to pipelines.
3
5
  # @see https://docs.gitlab.com/ce/api/pipeline_triggers.html
@@ -35,7 +37,7 @@ class Gitlab::Client
35
37
  # @param [String] description The trigger name
36
38
  # @return [Gitlab::ObjectifiedHash] The created trigger.
37
39
  def create_trigger(project, description)
38
- post("/projects/#{url_encode project}/triggers", body: {description: description})
40
+ post("/projects/#{url_encode project}/triggers", body: { description: description })
39
41
  end
40
42
 
41
43
  # Update a project trigger
@@ -48,7 +50,7 @@ class Gitlab::Client
48
50
  # @param [Hash] options A customizable set of options.
49
51
  # @option options [String] :description The trigger name.
50
52
  # @return [Gitlab::ObjectifiedHash] The updated trigger.
51
- def update_trigger(project, trigger_id, options={})
53
+ def update_trigger(project, trigger_id, options = {})
52
54
  put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options)
53
55
  end
54
56
 
@@ -75,13 +77,13 @@ class Gitlab::Client
75
77
  def remove_trigger(project, trigger_id)
76
78
  delete("/projects/#{url_encode project}/triggers/#{trigger_id}")
77
79
  end
78
- alias_method :delete_trigger, :remove_trigger
80
+ alias delete_trigger remove_trigger
79
81
 
80
82
  # Run the given project pipeline trigger.
81
83
  #
82
84
  # @example
83
- # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master')
84
- # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
85
+ # Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master')
86
+ # Gitlab.run_trigger(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
85
87
  #
86
88
  # @see https://docs.gitlab.com/ce/ci/triggers/README.html
87
89
  #
@@ -90,12 +92,12 @@ class Gitlab::Client
90
92
  # @param [String] ref Branch or tag name to build.
91
93
  # @param [Hash] variables A set of build variables to use for the build. (optional)
92
94
  # @return [Gitlab::ObjectifiedHash] The trigger.
93
- def run_trigger(project, token, ref, variables={})
95
+ def run_trigger(project, token, ref, variables = {})
94
96
  post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: {
95
- token: token,
96
- ref: ref,
97
- variables: variables
98
- })
97
+ token: token,
98
+ ref: ref,
99
+ variables: variables
100
+ })
99
101
  end
100
102
  end
101
103
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to pipelines.
3
5
  # @see https://docs.gitlab.com/ce/api/pipelines.html
@@ -13,7 +15,7 @@ class Gitlab::Client
13
15
  # @option options [Integer] :page The page number.
14
16
  # @option options [Integer] :per_page The number of results per page.
15
17
  # @return [Array<Gitlab::ObjectifiedHash>]
16
- def pipelines(project, options={})
18
+ def pipelines(project, options = {})
17
19
  get("/projects/#{url_encode project}/pipelines", query: options)
18
20
  end
19
21
 
@@ -29,6 +31,18 @@ class Gitlab::Client
29
31
  get("/projects/#{url_encode project}/pipelines/#{id}")
30
32
  end
31
33
 
34
+ # Gets a single pipeline's test report.
35
+ #
36
+ # @example
37
+ # Gitlab.pipeline_test_report(5, 36)
38
+ #
39
+ # @param [Integer, String] project The ID or name of a project.
40
+ # @param [Integer] id The ID of a pipeline.
41
+ # @return [Gitlab::ObjectifiedHash]
42
+ def pipeline_test_report(project, id)
43
+ get("/projects/#{url_encode project}/pipelines/#{id}/test_report")
44
+ end
45
+
32
46
  # Create a pipeline.
33
47
  #
34
48
  # @example
@@ -36,9 +50,20 @@ class Gitlab::Client
36
50
  #
37
51
  # @param [Integer, String] project The ID or name of a project.
38
52
  # @param [String] ref Reference to commit.
53
+ # @param [Hash] variables Variables passed to pipelines
39
54
  # @return [Gitlab::ObjectifiedHash] The pipelines changes.
40
- def create_pipeline(project, ref)
41
- post("/projects/#{url_encode project}/pipeline?ref=#{ref}")
55
+ def create_pipeline(project, ref, variables = {})
56
+ body = {}
57
+
58
+ # This mapping is necessary, cause the API expects an array with objects (with `key` and `value` keys)
59
+ # See: https://docs.gitlab.com/ee/api/pipelines.html#create-a-new-pipeline
60
+ body[:variables] = variables.map { |(key, value)| { key: key, value: value } } if variables.any?
61
+
62
+ post(
63
+ "/projects/#{url_encode project}/pipeline",
64
+ query: { ref: ref },
65
+ body: body
66
+ )
42
67
  end
43
68
 
44
69
  # Cancels a pipeline.
@@ -64,5 +89,17 @@ class Gitlab::Client
64
89
  def retry_pipeline(project, id)
65
90
  post("/projects/#{url_encode project}/pipelines/#{id}/retry")
66
91
  end
92
+
93
+ # Delete a pipeline
94
+ #
95
+ # @example
96
+ # Gitlab.delete_pipeline(5, 1)
97
+ #
98
+ # @param [Integer, String] project The ID or name of a project.
99
+ # @param [Integer] id The ID of a pipeline.
100
+ # @return [void] This API call returns an empty response body.
101
+ def delete_pipeline(project, id)
102
+ delete("/projects/#{url_encode project}/pipelines/#{id}")
103
+ end
67
104
  end
68
105
  end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to project badges.
5
+ # @see https://docs.gitlab.com/ee/api/project_badges.html
6
+ module ProjectBadges
7
+ # Gets a list of a projects badges and its group badges.
8
+ #
9
+ # @example
10
+ # Gitlab.project_badges(5)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @return [Array<Gitlab::ObjectifiedHash>] List of all badges of a project
14
+ def project_badges(project)
15
+ get("/projects/#{url_encode project}/badges")
16
+ end
17
+
18
+ # Gets a badge of a project.
19
+ #
20
+ # @example
21
+ # Gitlab.project_badge(5, 42)
22
+ #
23
+ # @param [Integer, String] project The ID or name of a project.
24
+ # @param [Integer] badge_id The badge ID.
25
+ # @return [Gitlab::ObjectifiedHash] Information about the requested badge
26
+ def project_badge(project, badge_id)
27
+ get("/projects/#{url_encode project}/badges/#{badge_id}")
28
+ end
29
+
30
+ # Adds a badge to a project.
31
+ #
32
+ # @example
33
+ # Gitlab.add_project_badge(5, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
34
+ #
35
+ # @param [Integer, String] project The ID or name of a project.
36
+ # @param [Hash] options A customizable set of options.
37
+ # @option options [String] :link_url(required) URL of the badge link
38
+ # @option options [String] :image_url(required) URL of the badge image
39
+ # @return [Gitlab::ObjectifiedHash] Information about the added project badge.
40
+ def add_project_badge(project, options = {})
41
+ post("/projects/#{url_encode project}/badges", body: options)
42
+ end
43
+
44
+ # Updates a badge of a project..
45
+ #
46
+ # @example
47
+ # Gitlab.edit_project_badge(5, 1, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
48
+ #
49
+ # @param [Integer, String] project The ID or name of a project.
50
+ # @param [Integer] badge_id The badge ID.
51
+ # @param [Hash] options A customizable set of options.
52
+ # @option options [String] :link_url(optional) URL of the badge link
53
+ # @option options [String] :image_url(optional) URL of the badge image
54
+ # @return [Gitlab::ObjectifiedHash] Information about the updated project badge.
55
+ def edit_project_badge(project, badge_id, options = {})
56
+ put("/projects/#{url_encode project}/badges/#{badge_id}", body: options)
57
+ end
58
+
59
+ # Removes a badge from a project. Only projects badges will be removed by using this endpoint.
60
+ #
61
+ # @example
62
+ # Gitlab.remove_project_badge(5, 42)
63
+ #
64
+ # @param [Integer, String] project The ID or name of a project.
65
+ # @param [Integer] badge_id The badge ID.
66
+ # @return [nil] This API call returns an empty response body.
67
+ def remove_project_badge(project, badge_id)
68
+ delete("/projects/#{url_encode project}/badges/#{badge_id}")
69
+ end
70
+
71
+ # Preview a badge from a project.
72
+ #
73
+ # @example
74
+ # Gitlab.preview_project_badge(3, 'https://abc.com/gitlab/gitlab-ce/commits/master', 'https://shields.io/my/badge1')
75
+ #
76
+ # @param [Integer, String] project The ID or name of a project.
77
+ # @param [String] :link_url URL of the badge link
78
+ # @param [String] :image_url URL of the badge image
79
+ # @return [Gitlab::ObjectifiedHash] Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation.
80
+ def preview_project_badge(project, link_url, image_url)
81
+ query = { link_url: link_url, image_url: image_url }
82
+ get("/projects/#{url_encode project}/badges/render", query: query)
83
+ end
84
+ end
85
+ end