gitlab-akerl 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.prospectus +11 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGELOG.md +229 -0
  6. data/CONTRIBUTING.md +195 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +24 -0
  9. data/README.md +192 -0
  10. data/Rakefile +9 -0
  11. data/bin/console +10 -0
  12. data/bin/setup +6 -0
  13. data/exe/gitlab +7 -0
  14. data/gitlab-akerl.gemspec +31 -0
  15. data/lib/gitlab.rb +45 -0
  16. data/lib/gitlab/api.rb +19 -0
  17. data/lib/gitlab/cli.rb +89 -0
  18. data/lib/gitlab/cli_helpers.rb +241 -0
  19. data/lib/gitlab/client.rb +48 -0
  20. data/lib/gitlab/client/branches.rb +91 -0
  21. data/lib/gitlab/client/build_triggers.rb +51 -0
  22. data/lib/gitlab/client/build_variables.rb +66 -0
  23. data/lib/gitlab/client/builds.rb +106 -0
  24. data/lib/gitlab/client/commits.rb +121 -0
  25. data/lib/gitlab/client/groups.rb +144 -0
  26. data/lib/gitlab/client/issues.rb +113 -0
  27. data/lib/gitlab/client/labels.rb +57 -0
  28. data/lib/gitlab/client/merge_requests.rb +168 -0
  29. data/lib/gitlab/client/milestones.rb +78 -0
  30. data/lib/gitlab/client/namespaces.rb +20 -0
  31. data/lib/gitlab/client/notes.rb +161 -0
  32. data/lib/gitlab/client/pipelines.rb +68 -0
  33. data/lib/gitlab/client/projects.rb +471 -0
  34. data/lib/gitlab/client/repositories.rb +78 -0
  35. data/lib/gitlab/client/repository_files.rb +88 -0
  36. data/lib/gitlab/client/runners.rb +115 -0
  37. data/lib/gitlab/client/services.rb +50 -0
  38. data/lib/gitlab/client/snippets.rb +91 -0
  39. data/lib/gitlab/client/system_hooks.rb +59 -0
  40. data/lib/gitlab/client/tags.rb +96 -0
  41. data/lib/gitlab/client/users.rb +250 -0
  42. data/lib/gitlab/configuration.rb +55 -0
  43. data/lib/gitlab/error.rb +85 -0
  44. data/lib/gitlab/file_response.rb +46 -0
  45. data/lib/gitlab/help.rb +95 -0
  46. data/lib/gitlab/objectified_hash.rb +34 -0
  47. data/lib/gitlab/page_links.rb +33 -0
  48. data/lib/gitlab/paginated_response.rb +97 -0
  49. data/lib/gitlab/request.rb +117 -0
  50. data/lib/gitlab/shell.rb +84 -0
  51. data/lib/gitlab/shell_history.rb +59 -0
  52. data/lib/gitlab/version.rb +3 -0
  53. data/spec/fixtures/branch.json +1 -0
  54. data/spec/fixtures/branch_delete.json +3 -0
  55. data/spec/fixtures/branches.json +1 -0
  56. data/spec/fixtures/build.json +38 -0
  57. data/spec/fixtures/build_artifacts.json +0 -0
  58. data/spec/fixtures/build_cancel.json +24 -0
  59. data/spec/fixtures/build_erase.json +24 -0
  60. data/spec/fixtures/build_retry.json +24 -0
  61. data/spec/fixtures/builds.json +78 -0
  62. data/spec/fixtures/builds_commits.json +64 -0
  63. data/spec/fixtures/compare_merge_request_diff.json +31 -0
  64. data/spec/fixtures/error_already_exists.json +1 -0
  65. data/spec/fixtures/error_project_not_found.json +1 -0
  66. data/spec/fixtures/get_repository_file.json +1 -0
  67. data/spec/fixtures/git_hook.json +1 -0
  68. data/spec/fixtures/group.json +60 -0
  69. data/spec/fixtures/group_create.json +1 -0
  70. data/spec/fixtures/group_create_with_description.json +1 -0
  71. data/spec/fixtures/group_delete.json +1 -0
  72. data/spec/fixtures/group_member.json +1 -0
  73. data/spec/fixtures/group_member_delete.json +1 -0
  74. data/spec/fixtures/group_member_edit.json +1 -0
  75. data/spec/fixtures/group_members.json +1 -0
  76. data/spec/fixtures/group_projects.json +44 -0
  77. data/spec/fixtures/group_search.json +2 -0
  78. data/spec/fixtures/groups.json +2 -0
  79. data/spec/fixtures/issue.json +1 -0
  80. data/spec/fixtures/issues.json +1 -0
  81. data/spec/fixtures/key.json +1 -0
  82. data/spec/fixtures/keys.json +1 -0
  83. data/spec/fixtures/label.json +1 -0
  84. data/spec/fixtures/labels.json +1 -0
  85. data/spec/fixtures/merge_request.json +1 -0
  86. data/spec/fixtures/merge_request_changes.json +1 -0
  87. data/spec/fixtures/merge_request_comment.json +1 -0
  88. data/spec/fixtures/merge_request_comments.json +1 -0
  89. data/spec/fixtures/merge_request_commits.json +1 -0
  90. data/spec/fixtures/merge_requests.json +1 -0
  91. data/spec/fixtures/milestone.json +1 -0
  92. data/spec/fixtures/milestone_issues.json +1 -0
  93. data/spec/fixtures/milestones.json +1 -0
  94. data/spec/fixtures/namespaces.json +1 -0
  95. data/spec/fixtures/note.json +1 -0
  96. data/spec/fixtures/notes.json +1 -0
  97. data/spec/fixtures/pipeline.json +23 -0
  98. data/spec/fixtures/pipeline_cancel.json +23 -0
  99. data/spec/fixtures/pipeline_create.json +23 -0
  100. data/spec/fixtures/pipeline_retry.json +23 -0
  101. data/spec/fixtures/pipelines.json +48 -0
  102. data/spec/fixtures/project.json +1 -0
  103. data/spec/fixtures/project_commit.json +13 -0
  104. data/spec/fixtures/project_commit_comment.json +1 -0
  105. data/spec/fixtures/project_commit_comments.json +1 -0
  106. data/spec/fixtures/project_commit_diff.json +10 -0
  107. data/spec/fixtures/project_commit_status.json +42 -0
  108. data/spec/fixtures/project_commits.json +1 -0
  109. data/spec/fixtures/project_edit.json +21 -0
  110. data/spec/fixtures/project_events.json +1 -0
  111. data/spec/fixtures/project_for_user.json +1 -0
  112. data/spec/fixtures/project_fork.json +50 -0
  113. data/spec/fixtures/project_fork_link.json +1 -0
  114. data/spec/fixtures/project_forked_for_user.json +50 -0
  115. data/spec/fixtures/project_hook.json +1 -0
  116. data/spec/fixtures/project_hooks.json +1 -0
  117. data/spec/fixtures/project_issues.json +1 -0
  118. data/spec/fixtures/project_key.json +6 -0
  119. data/spec/fixtures/project_keys.json +6 -0
  120. data/spec/fixtures/project_runner_enable.json +7 -0
  121. data/spec/fixtures/project_runners.json +16 -0
  122. data/spec/fixtures/project_search.json +1 -0
  123. data/spec/fixtures/project_star.json +44 -0
  124. data/spec/fixtures/project_tag_annotated.json +1 -0
  125. data/spec/fixtures/project_tag_lightweight.json +1 -0
  126. data/spec/fixtures/project_tags.json +1 -0
  127. data/spec/fixtures/project_unstar.json +44 -0
  128. data/spec/fixtures/project_update_commit_status.json +20 -0
  129. data/spec/fixtures/projects.json +1 -0
  130. data/spec/fixtures/raw_file.json +2 -0
  131. data/spec/fixtures/release_create.json +1 -0
  132. data/spec/fixtures/release_update.json +1 -0
  133. data/spec/fixtures/repository_file.json +1 -0
  134. data/spec/fixtures/runner.json +26 -0
  135. data/spec/fixtures/runner_delete.json +7 -0
  136. data/spec/fixtures/runner_edit.json +26 -0
  137. data/spec/fixtures/runners.json +16 -0
  138. data/spec/fixtures/runners_all.json +30 -0
  139. data/spec/fixtures/service.json +1 -0
  140. data/spec/fixtures/session.json +1 -0
  141. data/spec/fixtures/shell_history.json +2 -0
  142. data/spec/fixtures/snippet.json +1 -0
  143. data/spec/fixtures/snippet_content.json +3 -0
  144. data/spec/fixtures/snippets.json +1 -0
  145. data/spec/fixtures/system_hook.json +1 -0
  146. data/spec/fixtures/system_hooks.json +1 -0
  147. data/spec/fixtures/tag.json +1 -0
  148. data/spec/fixtures/tag_create.json +1 -0
  149. data/spec/fixtures/tag_create_with_description.json +1 -0
  150. data/spec/fixtures/tag_delete.json +1 -0
  151. data/spec/fixtures/tags.json +1 -0
  152. data/spec/fixtures/team_member.json +1 -0
  153. data/spec/fixtures/team_members.json +1 -0
  154. data/spec/fixtures/tree.json +1 -0
  155. data/spec/fixtures/trigger.json +7 -0
  156. data/spec/fixtures/triggers.json +16 -0
  157. data/spec/fixtures/user.json +1 -0
  158. data/spec/fixtures/user_block_unblock.json +1 -0
  159. data/spec/fixtures/user_email.json +1 -0
  160. data/spec/fixtures/user_emails.json +1 -0
  161. data/spec/fixtures/user_search.json +1 -0
  162. data/spec/fixtures/users.json +1 -0
  163. data/spec/fixtures/variable.json +4 -0
  164. data/spec/fixtures/variables.json +10 -0
  165. data/spec/gitlab/cli_helpers_spec.rb +57 -0
  166. data/spec/gitlab/cli_spec.rb +110 -0
  167. data/spec/gitlab/client/branches_spec.rb +99 -0
  168. data/spec/gitlab/client/build_triggers_spec.rb +67 -0
  169. data/spec/gitlab/client/build_variables_spec.rb +86 -0
  170. data/spec/gitlab/client/builds_spec.rb +148 -0
  171. data/spec/gitlab/client/client_spec.rb +11 -0
  172. data/spec/gitlab/client/commits_spec.rb +137 -0
  173. data/spec/gitlab/client/groups_spec.rb +197 -0
  174. data/spec/gitlab/client/issues_spec.rb +138 -0
  175. data/spec/gitlab/client/labels_spec.rb +68 -0
  176. data/spec/gitlab/client/merge_requests_spec.rb +177 -0
  177. data/spec/gitlab/client/milestones_spec.rb +82 -0
  178. data/spec/gitlab/client/namespaces_spec.rb +22 -0
  179. data/spec/gitlab/client/notes_spec.rb +205 -0
  180. data/spec/gitlab/client/pipelines_spec.rb +95 -0
  181. data/spec/gitlab/client/projects_spec.rb +603 -0
  182. data/spec/gitlab/client/repositories_spec.rb +109 -0
  183. data/spec/gitlab/client/repository_files_spec.rb +62 -0
  184. data/spec/gitlab/client/runners_spec.rb +185 -0
  185. data/spec/gitlab/client/services_spec.rb +55 -0
  186. data/spec/gitlab/client/snippets_spec.rb +100 -0
  187. data/spec/gitlab/client/system_hooks_spec.rb +69 -0
  188. data/spec/gitlab/client/tags_spec.rb +109 -0
  189. data/spec/gitlab/client/users_spec.rb +418 -0
  190. data/spec/gitlab/error_spec.rb +45 -0
  191. data/spec/gitlab/file_response_spec.rb +33 -0
  192. data/spec/gitlab/help_spec.rb +46 -0
  193. data/spec/gitlab/objectified_hash_spec.rb +48 -0
  194. data/spec/gitlab/page_links_spec.rb +16 -0
  195. data/spec/gitlab/paginated_response_spec.rb +60 -0
  196. data/spec/gitlab/request_spec.rb +73 -0
  197. data/spec/gitlab/shell_history_spec.rb +53 -0
  198. data/spec/gitlab/shell_spec.rb +80 -0
  199. data/spec/gitlab_spec.rb +97 -0
  200. data/spec/spec_helper.rb +74 -0
  201. metadata +476 -0
@@ -0,0 +1,57 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to labels.
3
+ # @see https://docs.gitlab.com/ce/api/labels.html
4
+ module Labels
5
+ # Gets a list of project's labels.
6
+ #
7
+ # @example
8
+ # Gitlab.labels(5)
9
+ #
10
+ # @param [Integer] project The ID of a project.
11
+ # @return [Array<Gitlab::ObjectifiedHash>]
12
+ def labels(project)
13
+ get("/projects/#{project}/labels")
14
+ end
15
+
16
+ # Creates a new label.
17
+ #
18
+ # @example
19
+ # Gitlab.create_label(42, "Backlog", '#DD10AA')
20
+ #
21
+ # @param [Integer] project The ID of a project.
22
+ # @option [String] name The name of a label.
23
+ # @option [String] color The color of a label.
24
+ # @return [Gitlab::ObjectifiedHash] Information about created label.
25
+ def create_label(project, name, color)
26
+ post("/projects/#{project}/labels", body: { name: name, color: color })
27
+ end
28
+
29
+ # Updates a label.
30
+ #
31
+ # @example
32
+ # Gitlab.edit_label(42, "Backlog", { new_name: 'TODO' })
33
+ # Gitlab.edit_label(42, "Backlog", { new_name: 'TODO', color: '#DD10AA' })
34
+ #
35
+ # @param [Integer] project The ID of a project.
36
+ # @param [String] name The name of a label.
37
+ # @param [Hash] options A customizable set of options.
38
+ # @option options [String] :new_name The new name of a label.
39
+ # @option options [String] :color The color of a label.
40
+ # @return [Gitlab::ObjectifiedHash] Information about updated label.
41
+ def edit_label(project, name, options={})
42
+ put("/projects/#{project}/labels", body: options.merge(name: name))
43
+ end
44
+
45
+ # Deletes a label.
46
+ #
47
+ # @example
48
+ # Gitlab.delete_label(2, 'Backlog')
49
+ #
50
+ # @param [Integer] project The ID of a project.
51
+ # @param [String] name The name of a label.
52
+ # @return [Gitlab::ObjectifiedHash] Information about deleted label.
53
+ def delete_label(project, name)
54
+ delete("/projects/#{project}/labels", body: { name: name })
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,168 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to merge requests.
3
+ # @see https://docs.gitlab.com/ce/api/merge_requests.html
4
+ module MergeRequests
5
+ # Gets a list of project merge requests.
6
+ #
7
+ # @example
8
+ # Gitlab.merge_requests(5)
9
+ # Gitlab.merge_requests({ per_page: 40 })
10
+ #
11
+ # @param [Integer] project The ID of a project.
12
+ # @param [Hash] options A customizable set of options.
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>]
16
+ def merge_requests(project, options={})
17
+ get("/projects/#{project}/merge_requests", query: options)
18
+ end
19
+
20
+ # Gets a single merge request.
21
+ #
22
+ # @example
23
+ # Gitlab.merge_request(5, 36)
24
+ #
25
+ # @param [Integer] project The ID of a project.
26
+ # @param [Integer] id The ID of a merge request.
27
+ # @return <Gitlab::ObjectifiedHash]
28
+ def merge_request(project, id)
29
+ get("/projects/#{project}/merge_request/#{id}")
30
+ end
31
+
32
+ # Creates a merge request.
33
+ #
34
+ # @example
35
+ # Gitlab.create_merge_request(5, 'New merge request',
36
+ # { source_branch: 'source_branch', target_branch: 'target_branch' })
37
+ # Gitlab.create_merge_request(5, 'New merge request',
38
+ # { source_branch: 'source_branch', target_branch: 'target_branch', assignee_id: 42 })
39
+ #
40
+ # @param [Integer] project The ID of a project.
41
+ # @param [String] title The title of a merge request.
42
+ # @param [Hash] options A customizable set of options.
43
+ # @option options [String] :source_branch (required) The source branch name.
44
+ # @option options [String] :target_branch (required) The target branch name.
45
+ # @option options [Integer] :assignee_id (optional) The ID of a user to assign merge request.
46
+ # @option options [Integer] :target_project_id (optional) The target project ID.
47
+ # @return [Gitlab::ObjectifiedHash] Information about created merge request.
48
+ def create_merge_request(project, title, options={})
49
+ body = { title: title }.merge(options)
50
+ post("/projects/#{project}/merge_requests", body: body)
51
+ end
52
+
53
+ # Updates a merge request.
54
+ #
55
+ # @example
56
+ # Gitlab.update_merge_request(5, 42, { title: 'New title' })
57
+ #
58
+ # @param [Integer] project The ID of a project.
59
+ # @param [Integer] id The ID of a merge request.
60
+ # @param [Hash] options A customizable set of options.
61
+ # @option options [String] :title The title of a merge request.
62
+ # @option options [String] :source_branch The source branch name.
63
+ # @option options [String] :target_branch The target branch name.
64
+ # @option options [Integer] :assignee_id The ID of a user to assign merge request.
65
+ # @option options [String] :state_event New state (close|reopen|merge).
66
+ # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
67
+ def update_merge_request(project, id, options={})
68
+ put("/projects/#{project}/merge_request/#{id}", body: options)
69
+ end
70
+
71
+ # Accepts a merge request.
72
+ #
73
+ # @example
74
+ # Gitlab.accept_merge_request(5, 42, { merge_commit_message: 'Nice!' })
75
+ #
76
+ # @param [Integer] project The ID of a project.
77
+ # @param [Integer] id The ID of a merge request.
78
+ # @param [Hash] options A customizable set of options.
79
+ # @option options [String] :merge_commit_message Custom merge commit message
80
+ # @return [Gitlab::ObjectifiedHash] Information about updated merge request.
81
+ def accept_merge_request(project, id, options={})
82
+ put("/projects/#{project}/merge_request/#{id}/merge", body: options)
83
+ end
84
+
85
+ # Adds a comment to a merge request.
86
+ #
87
+ # @example
88
+ # Gitlab.create_merge_request_comment(5, 1, "Awesome merge!")
89
+ # Gitlab.create_merge_request_comment('gitlab', 1, "Awesome merge!")
90
+ #
91
+ # @param [Integer] project The ID of a project.
92
+ # @param [Integer] id The ID of a merge request.
93
+ # @param [String] note The content of a comment.
94
+ # @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
95
+ def create_merge_request_comment(project, id, note)
96
+ post("/projects/#{project}/merge_requests/#{id}/notes", body: { body: note })
97
+ end
98
+
99
+ # Adds a comment to a merge request.
100
+ #
101
+ # @example
102
+ # Gitlab.edit_merge_request_comment(5, 1,2, "Awesome merge!")
103
+ # Gitlab.edit_merge_request_comment('gitlab', 1, 2, "Awesome merge!")
104
+ #
105
+ # @param [Integer] project The ID of a project.
106
+ # @param [Integer] id The ID of a merge request.
107
+ # @param [Integer] id The ID of the merge-request comment
108
+ # @param [String] note The content of a comment.
109
+ # @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
110
+ def edit_merge_request_comment(project, id, note_id , note)
111
+ put("/projects/#{project}/merge_requests/#{id}/notes/#{note_id}", body: { body: note })
112
+ end
113
+
114
+ # Deletes a comment from a merge request.
115
+ #
116
+ # @example
117
+ # Gitlab.delete_merge_request_comment(5, 1,2)
118
+ # Gitlab.delete_merge_request_comment('gitlab', 1, 2)
119
+ #
120
+ # @param [Integer] project The ID of a project.
121
+ # @param [Integer] id The ID of a merge request.
122
+ # @param [Integer] id The ID of the merge-request comment
123
+ # @return [Gitlab::ObjectifiedHash] Information about created merge request comment.
124
+ def delete_merge_request_comment(project, id, note_id)
125
+ delete("/projects/#{project}/merge_requests/#{id}/notes/#{note_id}")
126
+ end
127
+
128
+ # Gets the comments on a merge request.
129
+ #
130
+ # @example
131
+ # Gitlab.merge_request_comments(5, 1)
132
+ # Gitlab.merge_request_comments(5, 1, { per_page: 10, page: 2 })
133
+ #
134
+ # @param [Integer] project The ID of a project.
135
+ # @param [Integer] id The ID of a merge request.
136
+ # @param [Hash] options A customizable set of options.
137
+ # @option options [Integer] :page The page number.
138
+ # @option options [Integer] :per_page The number of results per page.
139
+ # @return [Gitlab::ObjectifiedHash] The merge request's comments.
140
+ def merge_request_comments(project, id, options={})
141
+ get("/projects/#{project}/merge_requests/#{id}/notes", query: options)
142
+ end
143
+
144
+ # Gets the changes of a merge request.
145
+ #
146
+ # @example
147
+ # Gitlab.merge_request_changes(5, 1)
148
+ #
149
+ # @param [Integer] project The ID of a project.
150
+ # @param [Integer] id The ID of a merge request.
151
+ # @return [Gitlab::ObjectifiedHash] The merge request's changes.
152
+ def merge_request_changes(project, id)
153
+ get("/projects/#{project}/merge_request/#{id}/changes")
154
+ end
155
+
156
+ # Gets the commits of a merge request.
157
+ #
158
+ # @example
159
+ # Gitlab.merge_request_commits(5, 1)
160
+ #
161
+ # @param [Integer] project The ID of a project.
162
+ # @param [Integer] id The ID of a merge request.
163
+ # @return [Array<Gitlab::ObjectifiedHash>] The merge request's commits.
164
+ def merge_request_commits(project, id)
165
+ get("/projects/#{project}/merge_request/#{id}/commits")
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,78 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to milestones.
3
+ # @see https://docs.gitlab.com/ce/api/milestones.html
4
+ module Milestones
5
+ # Gets a list of project's milestones.
6
+ #
7
+ # @example
8
+ # Gitlab.milestones(5)
9
+ #
10
+ # @param [Integer] project The ID of a project.
11
+ # @param [Hash] options A customizable set of options.
12
+ # @option options [Integer] :page The page number.
13
+ # @option options [Integer] :per_page The number of results per page.
14
+ # @return [Array<Gitlab::ObjectifiedHash>]
15
+ def milestones(project, options={})
16
+ get("/projects/#{project}/milestones", query: options)
17
+ end
18
+
19
+ # Gets a single milestone.
20
+ #
21
+ # @example
22
+ # Gitlab.milestone(5, 36)
23
+ #
24
+ # @param [Integer, String] project The ID of a project.
25
+ # @param [Integer] id The ID of a milestone.
26
+ # @return [Gitlab::ObjectifiedHash]
27
+ def milestone(project, id)
28
+ get("/projects/#{project}/milestones/#{id}")
29
+ end
30
+
31
+ # Gets the issues of a given milestone.
32
+ #
33
+ # @example
34
+ # Gitlab.milestone_issues(5, 2)
35
+ #
36
+ # @param [Integer, String] project The ID of a project.
37
+ # @param [Integer, String] milestone The ID of a milestone.
38
+ # @option options [Integer] :page The page number.
39
+ # @option options [Integer] :per_page The number of results per page.
40
+ # @return [Array<Gitlab::ObjectifiedHash>]
41
+ def milestone_issues(project, milestone, options={})
42
+ get("/projects/#{project}/milestones/#{milestone}/issues", query: options)
43
+ end
44
+
45
+ # Creates a new milestone.
46
+ #
47
+ # @example
48
+ # Gitlab.create_milestone(5, 'v1.0')
49
+ #
50
+ # @param [Integer] project The ID of a project.
51
+ # @param [String] title The title of a milestone.
52
+ # @param [Hash] options A customizable set of options.
53
+ # @option options [String] :description The description of a milestone.
54
+ # @option options [String] :due_date The due date of a milestone.
55
+ # @return [Gitlab::ObjectifiedHash] Information about created milestone.
56
+ def create_milestone(project, title, options={})
57
+ body = { title: title }.merge(options)
58
+ post("/projects/#{project}/milestones", body: body)
59
+ end
60
+
61
+ # Updates a milestone.
62
+ #
63
+ # @example
64
+ # Gitlab.edit_milestone(5, 2, { state_event: 'activate' })
65
+ #
66
+ # @param [Integer] project The ID of a project.
67
+ # @param [Integer] id The ID of a milestone.
68
+ # @param [Hash] options A customizable set of options.
69
+ # @option options [String] :title The title of a milestone.
70
+ # @option options [String] :description The description of a milestone.
71
+ # @option options [String] :due_date The due date of a milestone.
72
+ # @option options [String] :state_event The state of a milestone ('close' or 'activate').
73
+ # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
74
+ def edit_milestone(project, id, options={})
75
+ put("/projects/#{project}/milestones/#{id}", body: options)
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,20 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to namespaces
3
+ # @see https://docs.gitlab.com/ce/api/namespaces.html
4
+ module Namespaces
5
+ # Gets a list of namespaces.
6
+ # @see https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces
7
+ #
8
+ # @example
9
+ # Gitlab.namespaces
10
+ #
11
+ # @param [Hash] options A customizable set of options.
12
+ # @options options [Integer] :page The page number.
13
+ # @options options [Integer] :per_page The number of results per page.
14
+ # @options opttion [String] :search The string to search for.
15
+ # @return [Array<Gitlab::ObjectifiedHash>]
16
+ def namespaces(options={})
17
+ get("/namespaces", query: options)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,161 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to notes.
3
+ # @see https://docs.gitlab.com/ce/api/notes.html
4
+ module Notes
5
+ # Gets a list of projects notes.
6
+ #
7
+ # @example
8
+ # Gitlab.notes(5)
9
+ #
10
+ # @param [Integer] project The ID of a project.
11
+ # @option options [Integer] :page The page number.
12
+ # @option options [Integer] :per_page The number of results per page.
13
+ # @return [Array<Gitlab::ObjectifiedHash>]
14
+ def notes(project, options={})
15
+ get("/projects/#{project}/notes", query: options)
16
+ end
17
+
18
+ # Gets a list of notes for a issue.
19
+ #
20
+ # @example
21
+ # Gitlab.issue_notes(5, 10)
22
+ #
23
+ # @param [Integer] project The ID of a project.
24
+ # @param [Integer] issue The ID of an issue.
25
+ # @option options [Integer] :page The page number.
26
+ # @option options [Integer] :per_page The number of results per page.
27
+ # @return [Array<Gitlab::ObjectifiedHash>]
28
+ def issue_notes(project, issue, options={})
29
+ get("/projects/#{project}/issues/#{issue}/notes", query: options)
30
+ end
31
+
32
+ # Gets a list of notes for a snippet.
33
+ #
34
+ # @example
35
+ # Gitlab.snippet_notes(5, 1)
36
+ #
37
+ # @param [Integer] project The ID of a project.
38
+ # @param [Integer] snippet The ID of a snippet.
39
+ # @option options [Integer] :page The page number.
40
+ # @option options [Integer] :per_page The number of results per page.
41
+ # @return [Array<Gitlab::ObjectifiedHash>]
42
+ def snippet_notes(project, snippet, options={})
43
+ get("/projects/#{project}/snippets/#{snippet}/notes", query: options)
44
+ end
45
+
46
+ # Gets a list of notes for a merge request.
47
+ #
48
+ # @example
49
+ # Gitlab.merge_request_notes(5, 1)
50
+ #
51
+ # @param [Integer] project The ID of a project.
52
+ # @param [Integer] merge_request The ID of a merge request.
53
+ # @option options [Integer] :page The page number.
54
+ # @option options [Integer] :per_page The number of results per page.
55
+ # @return [Array<Gitlab::ObjectifiedHash>]
56
+ def merge_request_notes(project, merge_request, options={})
57
+ get("/projects/#{project}/merge_requests/#{merge_request}/notes", query: options)
58
+ end
59
+
60
+ # Gets a single wall note.
61
+ #
62
+ # @example
63
+ # Gitlab.note(5, 15)
64
+ #
65
+ # @param [Integer] project The ID of a project.
66
+ # @param [Integer] id The ID of a note.
67
+ # @return [Gitlab::ObjectifiedHash]
68
+ def note(project, id)
69
+ get("/projects/#{project}/notes/#{id}")
70
+ end
71
+
72
+ # Gets a single issue note.
73
+ #
74
+ # @example
75
+ # Gitlab.issue_note(5, 10, 1)
76
+ #
77
+ # @param [Integer] project The ID of a project.
78
+ # @param [Integer] issue The ID of an issue.
79
+ # @param [Integer] id The ID of a note.
80
+ # @return [Gitlab::ObjectifiedHash]
81
+ def issue_note(project, issue, id)
82
+ get("/projects/#{project}/issues/#{issue}/notes/#{id}")
83
+ end
84
+
85
+ # Gets a single snippet note.
86
+ #
87
+ # @example
88
+ # Gitlab.snippet_note(5, 11, 3)
89
+ #
90
+ # @param [Integer] project The ID of a project.
91
+ # @param [Integer] snippet The ID of a snippet.
92
+ # @param [Integer] id The ID of a note.
93
+ # @return [Gitlab::ObjectifiedHash]
94
+ def snippet_note(project, snippet, id)
95
+ get("/projects/#{project}/snippets/#{snippet}/notes/#{id}")
96
+ end
97
+
98
+ # Gets a single merge_request note.
99
+ #
100
+ # @example
101
+ # Gitlab.merge_request_note(5, 11, 3)
102
+ #
103
+ # @param [Integer] project The ID of a project.
104
+ # @param [Integer] merge_request The ID of a merge_request.
105
+ # @param [Integer] id The ID of a note.
106
+ # @return [Gitlab::ObjectifiedHash]
107
+ def merge_request_note(project, merge_request, id)
108
+ get("/projects/#{project}/merge_requests/#{merge_request}/notes/#{id}")
109
+ end
110
+
111
+ # Creates a new wall note.
112
+ #
113
+ # @example
114
+ # Gitlab.create_note(5, 'This is a wall note!')
115
+ #
116
+ # @param [Integer] project The ID of a project.
117
+ # @param [String] body The body of a note.
118
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
119
+ def create_note(project, body)
120
+ post("/projects/#{project}/notes", body: { body: body })
121
+ end
122
+
123
+ # Creates a new issue note.
124
+ #
125
+ # @example
126
+ # Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
127
+ #
128
+ # @param [Integer] project The ID of a project.
129
+ # @param [Integer] issue The ID of an issue.
130
+ # @param [String] body The body of a note.
131
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
132
+ def create_issue_note(project, issue, body)
133
+ post("/projects/#{project}/issues/#{issue}/notes", body: { body: body })
134
+ end
135
+
136
+ # Creates a new snippet note.
137
+ #
138
+ # @example
139
+ # Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
140
+ #
141
+ # @param [Integer] project The ID of a project.
142
+ # @param [Integer] snippet The ID of a snippet.
143
+ # @param [String] body The body of a note.
144
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
145
+ def create_snippet_note(project, snippet, body)
146
+ post("/projects/#{project}/snippets/#{snippet}/notes", body: { body: body })
147
+ end
148
+
149
+ # Creates a new note for a single merge request.
150
+ #
151
+ # @example
152
+ # Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
153
+ #
154
+ # @param [Integer] project The ID of a project.
155
+ # @param [Integer] merge_request The ID of a merge request.
156
+ # @param [String] body The content of a note.
157
+ def create_merge_request_note(project, merge_request, body)
158
+ post("/projects/#{project}/merge_requests/#{merge_request}/notes", body: { body: body })
159
+ end
160
+ end
161
+ end