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 projects.
3
5
  # @see https://docs.gitlab.com/ce/api/projects.html
@@ -10,14 +12,11 @@ class Gitlab::Client
10
12
  # @param [Hash] options A customizable set of options.
11
13
  # @option options [Integer] :page The page number.
12
14
  # @option options [Integer] :per_page The number of results per page.
13
- # @option options [String] :scope Scope of projects. 'owned' for list of projects owned by the authenticated user, 'all' to get all projects (admin only)
15
+ # (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#list-all-projects Gitlab docs} for all valid options)
16
+ #
14
17
  # @return [Array<Gitlab::ObjectifiedHash>]
15
- def projects(options={})
16
- if options[:scope]
17
- get("/projects/#{options[:scope]}", query: options)
18
- else
19
- get("/projects", query: options)
20
- end
18
+ def projects(options = {})
19
+ get('/projects', query: options)
21
20
  end
22
21
 
23
22
  # Search for projects by name.
@@ -33,10 +32,10 @@ class Gitlab::Client
33
32
  # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
34
33
  # @option options [String] :sort Return requests sorted in asc or desc order
35
34
  # @return [Array<Gitlab::ObjectifiedHash>]
36
- def project_search(query, options={})
37
- get("/projects", query: options.merge(search:query))
35
+ def project_search(query, options = {})
36
+ get('/projects', query: options.merge(search: query))
38
37
  end
39
- alias_method :search_projects, :project_search
38
+ alias search_projects project_search
40
39
 
41
40
  # Gets information about a project.
42
41
  #
@@ -45,24 +44,12 @@ class Gitlab::Client
45
44
  # Gitlab.project('gitlab')
46
45
  #
47
46
  # @param [Integer, String] id The ID or path of a project.
47
+ # @param options [string] :license Include project license data
48
+ # @param options [string] :statistics Include project statistics.
49
+ # @param options [string] :with_custom_attributes Include custom attributes in response. (admins only)
48
50
  # @return [Gitlab::ObjectifiedHash]
49
- def project(id)
50
- get("/projects/#{url_encode id}")
51
- end
52
-
53
- # Gets a list of project events.
54
- #
55
- # @example
56
- # Gitlab.project_events(42)
57
- # Gitlab.project_events('gitlab')
58
- #
59
- # @param [Integer, String] project The ID or path of a project.
60
- # @param [Hash] options A customizable set of options.
61
- # @option options [Integer] :page The page number.
62
- # @option options [Integer] :per_page The number of results per page.
63
- # @return [Array<Gitlab::ObjectifiedHash>]
64
- def project_events(project, options={})
65
- get("/projects/#{url_encode project}/events", query: options)
51
+ def project(id, options = {})
52
+ get("/projects/#{url_encode id}", query: options)
66
53
  end
67
54
 
68
55
  # Creates a new project.
@@ -83,11 +70,11 @@ class Gitlab::Client
83
70
  # @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
84
71
  # @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
85
72
  # @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
86
- # @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true).
73
+ # @option options [String] :visibility The setting for making a project public ('private', 'internal', 'public').
87
74
  # @option options [Integer] :user_id The user/owner id of a project.
88
75
  # @return [Gitlab::ObjectifiedHash] Information about created project.
89
- def create_project(name, options={})
90
- url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : "/projects"
76
+ def create_project(name, options = {})
77
+ url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : '/projects'
91
78
  post(url, body: { name: name }.merge(options))
92
79
  end
93
80
 
@@ -114,10 +101,26 @@ class Gitlab::Client
114
101
  # @option options [Integer] :page The page number.
115
102
  # @option options [Integer] :per_page The number of results per page.
116
103
  # @return [Array<Gitlab::ObjectifiedHash>]
117
- def team_members(project, options={})
104
+ def team_members(project, options = {})
118
105
  get("/projects/#{url_encode project}/members", query: options)
119
106
  end
120
107
 
108
+ # Gets a list of all project team members including inherited members.
109
+ #
110
+ # @example
111
+ # Gitlab.all_members(42)
112
+ # Gitlab.all_members('gitlab')
113
+ #
114
+ # @param [Integer, String] project The ID or path of a project.
115
+ # @param [Hash] options A customizable set of options.
116
+ # @option options [String] :query The search query.
117
+ # @option options [Integer] :page The page number.
118
+ # @option options [Integer] :per_page The number of results per page.
119
+ # @return [Array<Gitlab::ObjectifiedHash>]
120
+ def all_members(project, options = {})
121
+ get("/projects/#{url_encode project}/members/all", query: options)
122
+ end
123
+
121
124
  # Gets a project team member.
122
125
  #
123
126
  # @example
@@ -134,28 +137,34 @@ class Gitlab::Client
134
137
  #
135
138
  # @example
136
139
  # Gitlab.add_team_member('gitlab', 2, 40)
140
+ # Gitlab.add_team_member('gitlab', 2, 40, { expires_at: "2018-12-31"})
137
141
  #
138
142
  # @param [Integer, String] project The ID or path of a project.
139
143
  # @param [Integer] id The ID of a user.
140
144
  # @param [Integer] access_level The access level to project.
141
145
  # @param [Hash] options A customizable set of options.
146
+ # @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
142
147
  # @return [Gitlab::ObjectifiedHash] Information about added team member.
143
- def add_team_member(project, id, access_level)
144
- post("/projects/#{url_encode project}/members", body: { user_id: id, access_level: access_level })
148
+ def add_team_member(project, id, access_level, options = {})
149
+ body = { user_id: id, access_level: access_level }.merge(options)
150
+ post("/projects/#{url_encode project}/members", body: body)
145
151
  end
146
152
 
147
153
  # Updates a team member's project access level.
148
154
  #
149
155
  # @example
150
156
  # Gitlab.edit_team_member('gitlab', 3, 20)
157
+ # Gitlab.edit_team_member('gitlab', 3, 20, { expires_at: "2018-12-31"})
151
158
  #
152
159
  # @param [Integer, String] project The ID or path of a project.
153
160
  # @param [Integer] id The ID of a user.
154
161
  # @param [Integer] access_level The access level to project.
155
162
  # @param [Hash] options A customizable set of options.
163
+ # @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
156
164
  # @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
157
- def edit_team_member(project, id, access_level)
158
- put("/projects/#{url_encode project}/members/#{id}", body: { access_level: access_level })
165
+ def edit_team_member(project, id, access_level, options = {})
166
+ body = { access_level: access_level }.merge(options)
167
+ put("/projects/#{url_encode project}/members/#{id}", body: body)
159
168
  end
160
169
 
161
170
  # Removes a user from project team.
@@ -182,7 +191,7 @@ class Gitlab::Client
182
191
  # @option options [Integer] :page The page number.
183
192
  # @option options [Integer] :per_page The number of results per page.
184
193
  # @return [Array<Gitlab::ObjectifiedHash>]
185
- def project_hooks(project, options={})
194
+ def project_hooks(project, options = {})
186
195
  get("/projects/#{url_encode project}/hooks", query: options)
187
196
  end
188
197
 
@@ -212,7 +221,7 @@ class Gitlab::Client
212
221
  # @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
213
222
  # @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
214
223
  # @return [Gitlab::ObjectifiedHash] Information about added hook.
215
- def add_project_hook(project, url, options={})
224
+ def add_project_hook(project, url, options = {})
216
225
  body = { url: url }.merge(options)
217
226
  post("/projects/#{url_encode project}/hooks", body: body)
218
227
  end
@@ -231,7 +240,7 @@ class Gitlab::Client
231
240
  # @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
232
241
  # @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
233
242
  # @return [Gitlab::ObjectifiedHash] Information about updated hook.
234
- def edit_project_hook(project, id, url, options={})
243
+ def edit_project_hook(project, id, url, options = {})
235
244
  body = { url: url }.merge(options)
236
245
  put("/projects/#{url_encode project}/hooks/#{id}", body: body)
237
246
  end
@@ -271,7 +280,7 @@ class Gitlab::Client
271
280
  # @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
272
281
  # @param option [String] :commit_message_regex Commit message regex
273
282
  # @return [Gitlab::ObjectifiedHash] Information about added push rule.
274
- def add_push_rule(id, options={})
283
+ def add_push_rule(id, options = {})
275
284
  post("/projects/#{url_encode id}/push_rule", body: options)
276
285
  end
277
286
 
@@ -286,7 +295,7 @@ class Gitlab::Client
286
295
  # @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
287
296
  # @param option [String] :commit_message_regex Commit message regex
288
297
  # @return [Gitlab::ObjectifiedHash] Information about updated push rule.
289
- def edit_push_rule(id, options={})
298
+ def edit_push_rule(id, options = {})
290
299
  put("/projects/#{url_encode id}/push_rule", body: options)
291
300
  end
292
301
 
@@ -298,7 +307,7 @@ class Gitlab::Client
298
307
  #
299
308
  # @param [Integer] id The ID of a project.
300
309
  # @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
301
- def delete_push_rule(id, options={})
310
+ def delete_push_rule(id)
302
311
  delete("/projects/#{url_encode id}/push_rule")
303
312
  end
304
313
 
@@ -336,7 +345,7 @@ class Gitlab::Client
336
345
  # @option options [Integer] :page The page number.
337
346
  # @option options [Integer] :per_page The number of results per page.
338
347
  # @return [Array<Gitlab::ObjectifiedHash>]
339
- def deploy_keys(project, options={})
348
+ def deploy_keys(project, options = {})
340
349
  get("/projects/#{url_encode project}/deploy_keys", query: options)
341
350
  end
342
351
 
@@ -355,14 +364,15 @@ class Gitlab::Client
355
364
  # Creates a new deploy key.
356
365
  #
357
366
  # @example
358
- # Gitlab.create_deploy_key(42, 'My Key', 'Key contents')
367
+ # Gitlab.create_deploy_key(42, 'My Key', 'Key contents', can_push: true)
359
368
  #
360
369
  # @param [Integer, String] project The ID or path of a project.
361
370
  # @param [String] title The title of a deploy key.
362
371
  # @param [String] key The content of a deploy key.
372
+ # @param [Hash] options A customizable set of options.
363
373
  # @return [Gitlab::ObjectifiedHash] Information about created deploy key.
364
- def create_deploy_key(project, title, key)
365
- post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key })
374
+ def create_deploy_key(project, title, key, options = {})
375
+ post("/projects/#{url_encode project}/deploy_keys", body: { title: title, key: key }.merge(options))
366
376
  end
367
377
 
368
378
  # Enables a deploy key at the project.
@@ -389,6 +399,20 @@ class Gitlab::Client
389
399
  post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
390
400
  end
391
401
 
402
+ # Updates an existing deploy key.
403
+ #
404
+ # @example
405
+ # Gitlab.edit_deploy_key(42, 66, 'New key name', can_push: false)
406
+ #
407
+ # @param [Integer, String] project The ID or path of a project.
408
+ # @param [Integer] id The ID of a deploy key.
409
+ # @param [String] title The title of a deploy key.
410
+ # @param [Hash] options A customizable set of options.
411
+ # @return [Gitlab::ObjectifiedHash] Information about created deploy key.
412
+ def edit_deploy_key(project, id, title, options = {})
413
+ put("/projects/#{url_encode project}/deploy_keys/#{id}", body: { title: title }.merge(options))
414
+ end
415
+
392
416
  # Deletes a deploy key from project.
393
417
  #
394
418
  # @example
@@ -411,10 +435,28 @@ class Gitlab::Client
411
435
  # @param [Hash] options A customizable set of options.
412
436
  # @option options [String] :sudo The username the project will be forked for
413
437
  # @return [Gitlab::ObjectifiedHash] Information about the forked project.
414
- def create_fork(id, options={})
438
+ def create_fork(id, options = {})
415
439
  post("/projects/#{url_encode id}/fork", body: options)
416
440
  end
417
441
 
442
+ # Get a list of all visible projects across GitLab for the authenticated user.
443
+ # When accessed without authentication, only public projects are returned.
444
+ #
445
+ # Note: This feature was introduced in GitLab 10.1
446
+ #
447
+ # @example
448
+ # Gitlab.project_forks(42)
449
+ #
450
+ # @param [Hash] options A customizable set of options.
451
+ # @option options [Integer] :page The page number.
452
+ # @option options [Integer] :per_page The number of results per page.
453
+ # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
454
+ # @option options [String] :sort Return requests sorted in asc or desc order
455
+ # @return [Array<Gitlab::ObjectifiedHash>]
456
+ def project_forks(id, options = {})
457
+ get("/projects/#{url_encode id}/forks", query: options)
458
+ end
459
+
418
460
  # Updates an existing project.
419
461
  #
420
462
  # @example
@@ -430,7 +472,7 @@ class Gitlab::Client
430
472
  # (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#edit-project Gitlab docs} for all valid options)
431
473
  #
432
474
  # @return [Gitlab::ObjectifiedHash] Information about the edited project.
433
- def edit_project(id, options={})
475
+ def edit_project(id, options = {})
434
476
  put("/projects/#{url_encode id}", body: options)
435
477
  end
436
478
 
@@ -446,6 +488,30 @@ class Gitlab::Client
446
488
  post("/projects/#{url_encode project}/share", body: { group_id: id, group_access: group_access })
447
489
  end
448
490
 
491
+ # Unshare project with group.
492
+ #
493
+ # @example
494
+ # Gitlab.unshare_project_with_group('gitlab', 2)
495
+ #
496
+ # @param [Integer, String] project The ID or path of a project.
497
+ # @param [Integer] id The ID of a group.
498
+ # @return [void] This API call returns an empty response body.
499
+ def unshare_project_with_group(project, id)
500
+ delete("/projects/#{url_encode project}/share/#{id}")
501
+ end
502
+
503
+ # Transfer a project to a new namespace.
504
+ #
505
+ # @example
506
+ # Gitlab.transfer_project(42, 'yolo')
507
+ #
508
+ # @param [Integer, String] project The ID or path of a project
509
+ # @param [Integer, String] namespace The ID or path of the namespace to transfer to project to
510
+ # @return [Gitlab::ObjectifiedHash] Information about transfered project.
511
+ def transfer_project(project, namespace)
512
+ put("/projects/#{url_encode project}/transfer", body: { namespace: namespace })
513
+ end
514
+
449
515
  # Stars a project.
450
516
  # @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
451
517
  #
@@ -471,5 +537,172 @@ class Gitlab::Client
471
537
  def unstar_project(id)
472
538
  delete("/projects/#{url_encode id}/star")
473
539
  end
540
+
541
+ # Get a list of visible projects that the given user has starred.
542
+ # @see https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user
543
+ #
544
+ # @example
545
+ # Gitlab.user_starred_projects(1)
546
+ # Gitlab.user_starred_projects(1, { order_by: 'last_activity_at' })
547
+ # Gitlab.user_starred_projects('username', { order_by: 'name', sort: 'asc' })
548
+ #
549
+ # @param [Integer, String] user_id The ID or username of the user.
550
+ # @param [Hash] options A customizable set of options.
551
+ # @option options [String] :per_page Number of projects to return per page
552
+ # @option options [String] :page The page to retrieve
553
+ # @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
554
+ # @option options [String] :sort Return projects sorted in asc or desc order.
555
+ # @return [Array<Gitlab::ObjectifiedHash>]
556
+ def user_starred_projects(user_id, options = {})
557
+ get("/users/#{url_encode user_id}/starred_projects", query: options)
558
+ end
559
+
560
+ # Get a list of visible projects for the given user.
561
+ # @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
562
+ #
563
+ # @example
564
+ # Gitlab.user_projects(1)
565
+ # Gitlab.user_projects(1, { order_by: 'last_activity_at' })
566
+ # Gitlab.user_projects('username', { order_by: 'name', sort: 'asc' })
567
+ #
568
+ # @param [Integer, String] user_id The ID or username of the user.
569
+ # @param [Hash] options A customizable set of options.
570
+ # @option options [String] :per_page Number of projects to return per page
571
+ # @option options [String] :page The page to retrieve
572
+ # @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
573
+ # @option options [String] :sort Return projects sorted in asc or desc order.
574
+ # @return [Array<Gitlab::ObjectifiedHash>]
575
+ def user_projects(user_id, options = {})
576
+ get("/users/#{url_encode user_id}/projects", query: options)
577
+ end
578
+
579
+ # Uploads a file to the specified project to be used in an issue or
580
+ # merge request description, or a comment.
581
+ # @see https://docs.gitlab.com/ee/api/projects.html#upload-a-file
582
+ #
583
+ # @example
584
+ # Gitlab.upload_file(1, '/full/path/to/avatar.jpg')
585
+ #
586
+ # @param [Integer, String] id The ID or path of a project.
587
+ # @param [String] file_fullpath The fullpath of the file you are interested to upload.
588
+ # @return [Gitlab::ObjectifiedHash]
589
+ def upload_file(id, file_fullpath)
590
+ post("/projects/#{url_encode id}/uploads", body: { file: File.open(file_fullpath, 'r') })
591
+ end
592
+
593
+ # Get all project templates of a particular type
594
+ # @see https://docs.gitlab.com/ce/api/project_templates.html
595
+ #
596
+ # @example
597
+ # Gitlab.project_templates(1, 'dockerfiles')
598
+ # Gitlab.project_templates(1, 'licenses')
599
+ #
600
+ # @param [Integer, String] id The ID or URL-encoded path of the project.
601
+ # @param [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
602
+ # @return [Array<Gitlab::ObjectifiedHash>]
603
+ def project_templates(project, type)
604
+ get("/projects/#{url_encode project}/templates/#{type}")
605
+ end
606
+
607
+ # Get one project template of a particular type
608
+ # @see https://docs.gitlab.com/ce/api/project_templates.html
609
+ #
610
+ # @example
611
+ # Gitlab.project_template(1, 'dockerfiles', 'dockey')
612
+ # Gitlab.project_template(1, 'licenses', 'gpl', { project: 'some project', fullname: 'Holder Holding' })
613
+ #
614
+ # @param [Integer, String] project The ID or URL-encoded path of the project.
615
+ # @param [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
616
+ # @param [String] key The key of the template, as obtained from the collection endpoint
617
+ # @param [Hash] options A customizable set of options.
618
+ # @option options [String] project(optional) The project name to use when expanding placeholders in the template. Only affects licenses
619
+ # @option options [String] fullname(optional) The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses
620
+ # @return [Gitlab::ObjectifiedHash]
621
+ def project_template(project, type, key, options = {})
622
+ get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options)
623
+ end
624
+
625
+ # Archives a project.
626
+ #
627
+ # @example
628
+ # Gitlab.archive_project(4)
629
+ #
630
+ # @param [Integer, String] id The ID or path of a project.
631
+ # @return [Gitlab::ObjectifiedHash] Information about archived project.
632
+ def archive_project(id)
633
+ post("/projects/#{url_encode id}/archive")
634
+ end
635
+
636
+ # Unarchives a project.
637
+ #
638
+ # @example
639
+ # Gitlab.unarchive_project(4)
640
+ #
641
+ # @param [Integer, String] id The ID or path of a project.
642
+ # @return [Gitlab::ObjectifiedHash] Information about unarchived project.
643
+ def unarchive_project(id)
644
+ post("/projects/#{url_encode id}/unarchive")
645
+ end
646
+
647
+ # Gets project custom_attributes.
648
+ #
649
+ # @example
650
+ # Gitlab.project_custom_attributes(2)
651
+ #
652
+ # @param [Integer] project_id The ID of a project.
653
+ # @return [Gitlab::ObjectifiedHash]
654
+ def project_custom_attributes(project_id)
655
+ get("/projects/#{project_id}/custom_attributes")
656
+ end
657
+
658
+ # Gets single project custom_attribute.
659
+ #
660
+ # @example
661
+ # Gitlab.project_custom_attribute(key, 2)
662
+ #
663
+ # @param [String] key The custom_attributes key
664
+ # @param [Integer] project_id The ID of a project.
665
+ # @return [Gitlab::ObjectifiedHash]
666
+ def project_custom_attribute(key, project_id)
667
+ get("/projects/#{project_id}/custom_attributes/#{key}")
668
+ end
669
+
670
+ # Creates a new custom_attribute
671
+ #
672
+ # @example
673
+ # Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)
674
+ #
675
+ # @param [String] key The custom_attributes key
676
+ # @param [String] value The custom_attributes value
677
+ # @param [Integer] project_id The ID of a project.
678
+ # @return [Gitlab::ObjectifiedHash]
679
+ def add_project_custom_attribute(key, value, project_id)
680
+ url = "/projects/#{project_id}/custom_attributes/#{key}"
681
+ put(url, body: { value: value })
682
+ end
683
+
684
+ # Delete custom_attribute
685
+ # Will delete a custom_attribute
686
+ #
687
+ # @example
688
+ # Gitlab.delete_project_custom_attribute('somekey', 2)
689
+ #
690
+ # @param [String] key The custom_attribute key to delete
691
+ # @param [Integer] project_id The ID of a project.
692
+ # @return [Boolean]
693
+ def delete_project_custom_attribute(key, project_id = nil)
694
+ delete("/projects/#{project_id}/custom_attributes/#{key}")
695
+ end
696
+
697
+ # List project deploy tokens
698
+ #
699
+ # @example
700
+ # Gitlab.project_deploy_tokens(42)
701
+ #
702
+ # @param [Integer, String] id The ID or path of a project.
703
+ # @option options [Boolean] :active Limit by active status. Optional.
704
+ def project_deploy_tokens(project, options = {})
705
+ get("/projects/#{url_encode project}/deploy_tokens", query: options)
706
+ end
474
707
  end
475
708
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to Protected Tags.
5
+ # @see https://docs.gitlab.com/ce/api/protected_tags.html
6
+ module ProtectedTags
7
+ # Gets a list of protected tags from a project
8
+ #
9
+ # @example
10
+ # Gitlab.protected_tags(1)
11
+ #
12
+ # @param [Integer, String] project(required) The ID or name of a project.
13
+ # @option options [Integer] :page The page number.
14
+ # @option options [Integer] :per_page The number of results per page.
15
+ # @return [Array<Gitlab::ObjectifiedHash>] List of all protected tags requested
16
+ def protected_tags(project, options = {})
17
+ get("/projects/#{url_encode project}/protected_tags", query: options)
18
+ end
19
+
20
+ # Gets a single protected tag or wildcard protected tag.
21
+ #
22
+ # @example
23
+ # Gitlab.protected_tag(1, 'release-1-0')
24
+ #
25
+ # @param [Integer, String] project(required) The ID or name of a project.
26
+ # @param [String] name(required) The name of the tag or wildcard
27
+ # @return <Gitlab::ObjectifiedHash] Information about the requested protected tag
28
+ def protected_tag(project, name)
29
+ get("/projects/#{url_encode project}/protected_tags/#{name}")
30
+ end
31
+
32
+ # Protects a single repository tag or several project repository tags using a wildcard protected tag.
33
+ #
34
+ # @example
35
+ # Gitlab.protect_repository_tag(1, 'release-1-0')
36
+ # Gitlab.protect_repository_tag(1, 'release-1-0', create_access_level: 30)
37
+ #
38
+ # @param [Integer, String] project(required) The ID or name of a project.
39
+ # @param [String] name(required) The name of the tag or wildcard
40
+ # @option options [Integer] :create_access_level Access levels allowed to create (defaults: 40, maintainer access level)
41
+ # @return <Gitlab::ObjectifiedHash] Information about the protected repository tag
42
+ def protect_repository_tag(project, name, options = {})
43
+ body = { name: name }.merge(options)
44
+ post("/projects/#{url_encode project}/protected_tags", body: body)
45
+ end
46
+
47
+ # Unprotects the given protected tag or wildcard protected tag.
48
+ #
49
+ # @example
50
+ # Gitlab.unprotect_repository_tag(1, 'release-1-0')
51
+ #
52
+ # @param [Integer, String] project(required) The ID or name of a project.
53
+ # @param [String] name(required) The name of the tag or wildcard
54
+ # @return [nil] This API call returns an empty response body.
55
+ def unprotect_repository_tag(project, name)
56
+ delete("/projects/#{url_encode project}/protected_tags/#{name}")
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to remote mirrors.
5
+ # @see https://docs.gitlab.com/ee/api/remote_mirrors.html
6
+ module RemoteMirrors
7
+ # List a project's remote mirrors
8
+ #
9
+ # @example
10
+ # Gitlab.remote_mirrors(42)
11
+ # Gitlab.remote_mirrors('gitlab-org/gitlab')
12
+ #
13
+ # @param [Integer, String] project The ID or name of a project.
14
+ # @return [Array<Gitlab::ObjectifiedHash>]
15
+ def remote_mirrors(project)
16
+ get("/projects/#{url_encode project}/remote_mirrors")
17
+ end
18
+
19
+ # Create a remote mirror
20
+ #
21
+ # @example
22
+ # Gitlab.create_remote_mirror(42, 'https://mirror-bot@gitlab.com/gitlab-org/gitlab.git', enabled: true)
23
+ #
24
+ # @param [Integer, String] project The ID or name of a project.
25
+ # @param [String] url The full URL of the remote repository.
26
+ # @param [Hash] options A customizable set of options.
27
+ # @option options [Boolean] :enabled Determines if the mirror is enabled.
28
+ # @option options [Boolean] :only_protected_branches Determines if only protected branches are mirrored.
29
+ # @option options [Boolean] :keep_divergent_refs Determines if divergent refs are skipped.
30
+ # @return [Gitlab::ObjectifiedHash]
31
+ def create_remote_mirror(project, url, options = {})
32
+ post("/projects/#{url_encode project}/remote_mirrors", body: options.merge(url: url))
33
+ end
34
+
35
+ # Update a remote mirror's attributes
36
+ #
37
+ # @example
38
+ # Gitlab.edit_remote_mirror(42, 66, only_protected_branches: true)
39
+ #
40
+ # @param [Integer, String] project The ID or name of a project.
41
+ # @param [Integer] id The ID of the remote mirror.
42
+ # @param [Hash] options A customizable set of options.
43
+ # @option options [Boolean] :enabled Determines if the mirror is enabled.
44
+ # @option options [Boolean] :only_protected_branches Determines if only protected branches are mirrored.
45
+ # @option options [Boolean] :keep_divergent_refs Determines if divergent refs are skipped.
46
+ # @return [Gitlab::ObjectifiedHash]
47
+ def edit_remote_mirror(project, id, options = {})
48
+ put("/projects/#{url_encode project}/remote_mirrors/#{id}", body: options)
49
+ end
50
+ end
51
+ end