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,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to builds.
3
- # @see https://docs.gitlab.com/ce/api/build_variables.html
5
+ # @see https://docs.gitlab.com/ce/api/project_level_variables.html
6
+ # @see https://docs.gitlab.com/ce/api/group_level_variables.html
4
7
  module BuildVariables
5
8
  # Gets a list of the project's build variables
6
9
  #
@@ -16,7 +19,7 @@ class Gitlab::Client
16
19
  # Gets details of a project's specific build variable.
17
20
  #
18
21
  # @example
19
- # Gitlab.build(5, "TEST_VARIABLE_1")
22
+ # Gitlab.variable(5, "TEST_VARIABLE_1")
20
23
  #
21
24
  # @param [Integer, String] project The ID or name of a project.
22
25
  # @param [String] key The key of a variable.
@@ -33,22 +36,24 @@ class Gitlab::Client
33
36
  # @param [Integer, String] project The ID or name of a project.
34
37
  # @param [String] key The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed
35
38
  # @param [String] value The value of a variable
39
+ # @param [Hash] opts optional parameters
36
40
  # @return [Gitlab::ObjectifiedHash] The variable.
37
- def create_variable(project, key, value)
38
- post("/projects/#{url_encode project}/variables", body: { key: key, value: value })
41
+ def create_variable(project, key, value, **opts)
42
+ post("/projects/#{url_encode project}/variables", body: opts.merge(key: key, value: value))
39
43
  end
40
44
 
41
45
  # Update a project's build variable.
42
46
  #
43
47
  # @example
44
- # Gitlab.create_variable(5, "NEW_VARIABLE", "updated value")
48
+ # Gitlab.update_variable(5, "NEW_VARIABLE", "updated value")
45
49
  #
46
50
  # @param [Integer, String] project The ID or name of a project.
47
51
  # @param [String] key The key of a variable
48
52
  # @param [String] value The value of a variable
53
+ # @param [Hash] opts optional parameters
49
54
  # @return [Gitlab::ObjectifiedHash] The variable.
50
- def update_variable(project, key, value)
51
- put("/projects/#{url_encode project}/variables/#{key}", body: { value: value })
55
+ def update_variable(project, key, value, **opts)
56
+ put("/projects/#{url_encode project}/variables/#{key}", body: opts.merge(value: value))
52
57
  end
53
58
 
54
59
  # Remove a project's build variable.
@@ -58,9 +63,73 @@ class Gitlab::Client
58
63
  #
59
64
  # @param [Integer, String] project The ID or name of a project.
60
65
  # @param [String] key The key of a variable.
66
+ # @param [Hash] opts optional parameters
67
+ # @return [Gitlab::ObjectifiedHash] The variable.
68
+ def remove_variable(project, key, **opts)
69
+ delete("/projects/#{url_encode project}/variables/#{key}", query: opts)
70
+ end
71
+
72
+ # Gets a list of the group's build variables
73
+ #
74
+ # @example
75
+ # Gitlab.group_variables(5)
76
+ #
77
+ # @param [Integer, String] group The ID or name of a group.
78
+ # @return [Array<Gitlab::ObjectifiedHash>] The list of variables.
79
+ def group_variables(group)
80
+ get("/groups/#{url_encode group}/variables")
81
+ end
82
+
83
+ # Gets details of a group's specific build variable.
84
+ #
85
+ # @example
86
+ # Gitlab.group_variable(5, "TEST_VARIABLE_1")
87
+ #
88
+ # @param [Integer, String] group The ID or name of a group.
89
+ # @param [String] key The key of a variable.
90
+ # @return [Gitlab::ObjectifiedHash] The variable.
91
+ def group_variable(group, key)
92
+ get("/groups/#{url_encode group}/variables/#{key}")
93
+ end
94
+
95
+ # Create a build variable for a group.
96
+ #
97
+ # @example
98
+ # Gitlab.create_group_variable(5, "NEW_VARIABLE", "new value")
99
+ #
100
+ # @param [Integer, String] group The ID or name of a group.
101
+ # @param [String] key The key of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9` and `_` are allowed
102
+ # @param [String] value The value of a variable
103
+ # @param [Hash] opts optional parameters
104
+ # @return [Gitlab::ObjectifiedHash] The variable.
105
+ def create_group_variable(group, key, value, **opts)
106
+ post("/groups/#{url_encode group}/variables", body: opts.merge(key: key, value: value))
107
+ end
108
+
109
+ # Update a group's build variable.
110
+ #
111
+ # @example
112
+ # Gitlab.update_group_variable(5, "NEW_VARIABLE", "updated value")
113
+ #
114
+ # @param [Integer, String] group The ID or name of a group.
115
+ # @param [String] key The key of a variable
116
+ # @param [String] value The value of a variable
117
+ # @param [Hash] opts optional parameters
118
+ # @return [Gitlab::ObjectifiedHash] The variable.
119
+ def update_group_variable(group, key, value, **opts)
120
+ put("/groups/#{url_encode group}/variables/#{key}", body: opts.merge(value: value))
121
+ end
122
+
123
+ # Remove a group's build variable.
124
+ #
125
+ # @example
126
+ # Gitlab.remove_group_variable(5, "VARIABLE_1")
127
+ #
128
+ # @param [Integer, String] group The ID or name of a group.
129
+ # @param [String] key The key of a variable.
61
130
  # @return [Gitlab::ObjectifiedHash] The variable.
62
- def remove_variable(project, key)
63
- delete("/projects/#{url_encode project}/variables/#{key}")
131
+ def remove_group_variable(group, key)
132
+ delete("/groups/#{url_encode group}/variables/#{key}")
64
133
  end
65
134
  end
66
135
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to builds.
3
5
  # @see https://docs.gitlab.com/ce/api/builds.html
@@ -14,7 +16,7 @@ class Gitlab::Client
14
16
  # @option options [Integer] :per_page The number of results per page.
15
17
  # @param [Integer, String] project The ID or name of a project.
16
18
  # @return [Array<Gitlab::ObjectifiedHash>]
17
- def builds(project, options={})
19
+ def builds(project, options = {})
18
20
  get("/projects/#{url_encode project}/builds", query: options)
19
21
  end
20
22
 
@@ -40,15 +42,15 @@ class Gitlab::Client
40
42
  # @return [Gitlab::FileResponse]
41
43
  def build_artifacts(project, id)
42
44
  get("/projects/#{url_encode project}/builds/#{id}/artifacts",
43
- format: nil,
44
- headers: { Accept: 'application/octet-stream' },
45
- parser: proc { |body, _|
46
- if body.encoding == Encoding::ASCII_8BIT # binary response
47
- ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
48
- else # error with json response
49
- ::Gitlab::Request.parse(body)
50
- end
51
- })
45
+ format: nil,
46
+ headers: { Accept: 'application/octet-stream' },
47
+ parser: proc { |body, _|
48
+ if body.encoding == Encoding::ASCII_8BIT # binary response
49
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
50
+ else # error with json response
51
+ ::Gitlab::Request.parse(body)
52
+ end
53
+ })
52
54
  end
53
55
 
54
56
  # Gets a list of builds for specific commit in a project.
@@ -63,7 +65,7 @@ class Gitlab::Client
63
65
  # @option options [Integer] :page The page number.
64
66
  # @option options [Integer] :per_page The number of results per page.
65
67
  # @return [Array<Gitlab::ObjectifiedHash>] The list of builds.
66
- def commit_builds(project, sha, options={})
68
+ def commit_builds(project, sha, options = {})
67
69
  get("/projects/#{url_encode project}/repository/commits/#{sha}/builds", query: options)
68
70
  end
69
71
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to repository commits.
3
5
  # @see https://docs.gitlab.com/ce/api/commits.html
@@ -6,18 +8,18 @@ class Gitlab::Client
6
8
  #
7
9
  # @example
8
10
  # Gitlab.commits('viking')
9
- # Gitlab.repo_commits('gitlab', { ref_name: 'api' })
11
+ # Gitlab.repo_commits('gitlab', { ref: 'api' })
10
12
  #
11
13
  # @param [Integer, String] project The ID or name of a project.
12
14
  # @param [Hash] options A customizable set of options.
13
- # @option options [String] :ref_name The branch or tag name of a project repository.
15
+ # @option options [String] :ref The branch or tag name of a project repository.
14
16
  # @option options [Integer] :page The page number.
15
17
  # @option options [Integer] :per_page The number of results per page.
16
18
  # @return [Array<Gitlab::ObjectifiedHash>]
17
- def commits(project, options={})
19
+ def commits(project, options = {})
18
20
  get("/projects/#{url_encode project}/repository/commits", query: options)
19
21
  end
20
- alias_method :repo_commits, :commits
22
+ alias repo_commits commits
21
23
 
22
24
  # Gets a specific commit identified by the commit hash or name of a branch or tag.
23
25
  #
@@ -31,7 +33,57 @@ class Gitlab::Client
31
33
  def commit(project, sha)
32
34
  get("/projects/#{url_encode project}/repository/commits/#{sha}")
33
35
  end
34
- alias_method :repo_commit, :commit
36
+ alias repo_commit commit
37
+
38
+ # Get all references (from branches or tags) a commit is pushed to.
39
+ #
40
+ # @example
41
+ # Gitlab.commit_refs(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
42
+ #
43
+ # @param [Integer, String] project The ID or name of a project.
44
+ # @param [String] sha The commit hash
45
+ # @param [Hash] options A customizable set of options.
46
+ # @option options [String] :type The scope of commits. Possible values `branch`, `tag`, `all`. Default is `all`.
47
+ # @option options [Integer] :page The page number.
48
+ # @option options [Integer] :per_page The number of results per page.
49
+ # @return [Gitlab::ObjectifiedHash]
50
+ def commit_refs(project, sha, options = {})
51
+ get("/projects/#{url_encode project}/repository/commits/#{sha}/refs", query: options)
52
+ end
53
+
54
+ # Cherry picks a commit to a given branch.
55
+ #
56
+ # @example
57
+ # Gitlab.cherry_pick_commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'master')
58
+ #
59
+ # @param [Integer, String] project The ID or name of a project.
60
+ # @param [String] sha The commit hash or name of a repository branch or tag
61
+ # @param [String] branch The name of the branch
62
+ # @param [Hash] options A customizable set of options.
63
+ # @option options [Boolean] :dry_run Don't commit any changes
64
+ # @return [Gitlab::ObjectifiedHash]
65
+ def cherry_pick_commit(project, sha, branch, options = {})
66
+ options[:branch] = branch
67
+
68
+ post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: options)
69
+ end
70
+
71
+ # Reverts a commit in a given branch.
72
+ #
73
+ # @example
74
+ # Gitlab.revert_commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'master')
75
+ #
76
+ # @param [Integer, String] project The ID or name of a project.
77
+ # @param [String] sha The commit hash or name of a repository branch or tag
78
+ # @param [String] branch The name of the branch
79
+ # @param [Hash] options A customizable set of options.
80
+ # @option options [Boolean] :dry_run Don't commit any changes
81
+ # @return [Gitlab::ObjectifiedHash]
82
+ def revert_commit(project, sha, branch, options = {})
83
+ options[:branch] = branch
84
+
85
+ post("/projects/#{url_encode project}/repository/commits/#{sha}/revert", body: options)
86
+ end
35
87
 
36
88
  # Get the diff of a commit in a project.
37
89
  #
@@ -45,7 +97,7 @@ class Gitlab::Client
45
97
  def commit_diff(project, sha)
46
98
  get("/projects/#{url_encode project}/repository/commits/#{sha}/diff")
47
99
  end
48
- alias_method :repo_commit_diff, :commit_diff
100
+ alias repo_commit_diff commit_diff
49
101
 
50
102
  # Gets a list of comments for a commit.
51
103
  #
@@ -57,10 +109,10 @@ class Gitlab::Client
57
109
  # @option options [Integer] :page The page number.
58
110
  # @option options [Integer] :per_page The number of results per page.
59
111
  # @return [Array<Gitlab::ObjectifiedHash>]
60
- def commit_comments(project, commit, options={})
112
+ def commit_comments(project, commit, options = {})
61
113
  get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: options)
62
114
  end
63
- alias_method :repo_commit_comments, :commit_comments
115
+ alias repo_commit_comments commit_comments
64
116
 
65
117
  # Creates a new comment for a commit.
66
118
  #
@@ -75,10 +127,10 @@ class Gitlab::Client
75
127
  # @option options [Integer] :line The line number.
76
128
  # @option options [String] :line_type The line type (new or old).
77
129
  # @return [Gitlab::ObjectifiedHash] Information about created comment.
78
- def create_commit_comment(project, commit, note, options={})
130
+ def create_commit_comment(project, commit, note, options = {})
79
131
  post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: options.merge(note: note))
80
132
  end
81
- alias_method :repo_create_commit_comment, :create_commit_comment
133
+ alias repo_create_commit_comment create_commit_comment
82
134
 
83
135
  # Get the status of a commit
84
136
  #
@@ -94,10 +146,10 @@ class Gitlab::Client
94
146
  # @option options [String] :stage Filter by stage
95
147
  # @option options [String] :name Filter by status name, eg. jenkins
96
148
  # @option options [Boolean] :all The flag to return all statuses, not only latest ones
97
- def commit_status(project, sha, options={})
149
+ def commit_status(project, sha, options = {})
98
150
  get("/projects/#{url_encode project}/repository/commits/#{sha}/statuses", query: options)
99
151
  end
100
- alias_method :repo_commit_status, :commit_status
152
+ alias repo_commit_status commit_status
101
153
 
102
154
  # Adds or updates a status of a commit.
103
155
  #
@@ -113,10 +165,10 @@ class Gitlab::Client
113
165
  # @option options [String] :ref The ref (branch or tag) to which the status refers
114
166
  # @option options [String] :name Filter by status name, eg. jenkins
115
167
  # @option options [String] :target_url The target URL to associate with this status
116
- def update_commit_status(project, sha, state, options={})
117
- post("/projects/#{url_encode project}/statuses/#{sha}", query: options.merge(state: state))
168
+ def update_commit_status(project, sha, state, options = {})
169
+ post("/projects/#{url_encode project}/statuses/#{sha}", body: options.merge(state: state))
118
170
  end
119
- alias_method :repo_update_commit_status, :update_commit_status
171
+ alias repo_update_commit_status update_commit_status
120
172
 
121
173
  # Creates a single commit with one or more changes
122
174
  #
@@ -134,13 +186,31 @@ class Gitlab::Client
134
186
  # @option options [String] :author_email the email address of the author
135
187
  # @option options [String] :author_name the name of the author
136
188
  # @return [Gitlab::ObjectifiedHash] hash of commit related data
137
- def create_commit(project, branch, message, actions, options={})
189
+ def create_commit(project, branch, message, actions, options = {})
138
190
  payload = {
139
- branch: branch,
140
- commit_message: message,
141
- actions: actions,
191
+ branch: branch,
192
+ commit_message: message,
193
+ actions: actions
142
194
  }.merge(options)
143
195
  post("/projects/#{url_encode project}/repository/commits", body: payload)
144
196
  end
197
+
198
+ # Gets a list of merge requests for a commit.
199
+ #
200
+ # @see https://docs.gitlab.com/ce/api/commits.html#list-merge-requests-associated-with-a-commit
201
+ # Introduced in Gitlab 10.7
202
+ #
203
+ # @example
204
+ # Gitlab.commit_merge_requests(5, 'c9f9662a9b1116c838b523ed64c6abdb4aae4b8b')
205
+ #
206
+ # @param [Integer] project The ID of a project.
207
+ # @param [String] sha The commit hash.
208
+ # @option options [Integer] :page The page number.
209
+ # @option options [Integer] :per_page The number of results per page.
210
+ # @return [Array<Gitlab::ObjectifiedHash>]
211
+ def commit_merge_requests(project, commit, options = {})
212
+ get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: options)
213
+ end
214
+ alias repo_commit_merge_requests commit_merge_requests
145
215
  end
146
216
  end
@@ -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,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to deployments.
5
+ # @see https://docs.gitlab.com/ce/api/deployments.html
6
+ module Deployments
7
+ # Gets a list of project deployments.
8
+ #
9
+ # @example
10
+ # Gitlab.deployments(5)
11
+ # Gitlab.deployments(5, { per_page: 10, page: 2 })
12
+ #
13
+ # @param [Integer, String] project The ID or name of a project.
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 deployments(project, options = {})
19
+ get("/projects/#{url_encode project}/deployments", query: options)
20
+ end
21
+
22
+ # Gets a single deployment.
23
+ #
24
+ # @example
25
+ # Gitlab.deployment(5, 36)
26
+ #
27
+ # @param [Integer, String] project The ID or name of a project.
28
+ # @param [Integer] id The ID of an deployment.
29
+ # @return [Gitlab::ObjectifiedHash]
30
+ def deployment(project, id)
31
+ get("/projects/#{url_encode project}/deployments/#{id}")
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to environments.
3
5
  # @see https://docs.gitlab.com/ce/api/environments.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 environments(project, options={})
18
+ def environments(project, options = {})
17
19
  get("/projects/#{url_encode project}/environments", query: options)
18
20
  end
19
21
 
@@ -40,7 +42,7 @@ class Gitlab::Client
40
42
  # @option options [String] :external_url Optional URL for viewing the deployed project in this environment
41
43
  # @return [Gitlab::ObjectifiedHash] The updated environment.
42
44
  def create_environment(project, env_name, options = {})
43
- body = {name: env_name}.merge(options)
45
+ body = { name: env_name }.merge(options)
44
46
  post("/projects/#{url_encode project}/environments", body: body)
45
47
  end
46
48
 
@@ -56,7 +58,7 @@ class Gitlab::Client
56
58
  # @option options [String] env_name Name for the environment
57
59
  # @option options [String] external_url Optional URL for viewing the deployed project in this environment
58
60
  # @return [Gitlab::ObjectifiedHash] The updated environment.
59
- def edit_environment(project, id, options={})
61
+ def edit_environment(project, id, options = {})
60
62
  put("/projects/#{url_encode project}/environments/#{id}", body: options)
61
63
  end
62
64
 
@@ -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,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to events.
5
+ # @see https://docs.gitlab.com/ce/api/events.html
6
+ module Events
7
+ # Gets a list of authenticated user's events
8
+ #
9
+ # @example
10
+ # Gitlab.events()
11
+ # Gitlab.events({ action: 'created', target_type: 'issue' })
12
+ #
13
+ # @param [Hash] options A customizable set of options.
14
+ # @option options [String] :action Only events of specific action type
15
+ # @option options [String] :target_type Only events of specific target type
16
+ # @option options [String] :before Only events created before YYYY-MM-DD
17
+ # @option options [String] :after Only events created after YYYY-MM-DD
18
+ # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
19
+ # @return [Array<Gitlab::ObjectifiedHash>]
20
+ def events(options = {})
21
+ get('/events', query: options)
22
+ end
23
+
24
+ # Gets a list of user contribution events
25
+ #
26
+ # @example
27
+ # Gitlab.user_events(1)
28
+ # Gitlab.user_events(1, { action: created})
29
+ #
30
+ # @param [Integer, String] user The ID or username of user
31
+ # @param [Hash] options A customizable set of options.
32
+ # @option options [String] :action Only events of specific action type
33
+ # @option options [String] :target_type Only events of specific target type
34
+ # @option options [String] :before Only events created before YYYY-MM-DD
35
+ # @option options [String] :after Only events created after YYYY-MM-DD
36
+ # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
37
+ # @return [Array<Gitlab::ObjectifiedHash>]
38
+ def user_events(user, options = {})
39
+ get("/users/#{url_encode user}/events", query: options)
40
+ end
41
+
42
+ # Gets a list of visible project events
43
+ #
44
+ # @example
45
+ # Gitlab.project_events(1)
46
+ # Gitlab.project_events(1, { action: created })
47
+ #
48
+ # @param [Integer] project The ID of project
49
+ # @param [Hash] options A customizable set of options.
50
+ # @option options [String] :action Only events of specific action type
51
+ # @option options [String] :target_type Only events of specific target type
52
+ # @option options [String] :before Only events created before YYYY-MM-DD
53
+ # @option options [String] :after Only events created after YYYY-MM-DD
54
+ # @option options [String] :sort Sort by created_at either 'asc' or 'desc'
55
+ # @return [Array<Gitlab::ObjectifiedHash>]
56
+ def project_events(project, options = {})
57
+ get("/projects/#{url_encode project}/events", query: options)
58
+ end
59
+ end
60
+ end