fs-gitlab 4.18.1
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +270 -0
- data/LICENSE.txt +24 -0
- data/README.md +260 -0
- data/exe/gitlab +11 -0
- data/lib/gitlab/api.rb +24 -0
- data/lib/gitlab/cli.rb +89 -0
- data/lib/gitlab/cli_helpers.rb +243 -0
- data/lib/gitlab/client/access_requests.rb +103 -0
- data/lib/gitlab/client/application_settings.rb +172 -0
- data/lib/gitlab/client/avatar.rb +21 -0
- data/lib/gitlab/client/award_emojis.rb +137 -0
- data/lib/gitlab/client/boards.rb +146 -0
- data/lib/gitlab/client/branches.rb +135 -0
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +135 -0
- data/lib/gitlab/client/builds.rb +108 -0
- data/lib/gitlab/client/commits.rb +216 -0
- data/lib/gitlab/client/container_registry.rb +85 -0
- data/lib/gitlab/client/deployments.rb +34 -0
- data/lib/gitlab/client/environments.rb +89 -0
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/events.rb +60 -0
- data/lib/gitlab/client/features.rb +48 -0
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_boards.rb +141 -0
- data/lib/gitlab/client/group_labels.rb +88 -0
- data/lib/gitlab/client/group_milestones.rb +94 -0
- data/lib/gitlab/client/groups.rb +358 -0
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +231 -0
- data/lib/gitlab/client/jobs.rb +250 -0
- data/lib/gitlab/client/keys.rb +29 -0
- data/lib/gitlab/client/labels.rb +88 -0
- data/lib/gitlab/client/lint.rb +19 -0
- data/lib/gitlab/client/markdown.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +265 -0
- data/lib/gitlab/client/merge_requests.rb +386 -0
- data/lib/gitlab/client/milestones.rb +106 -0
- data/lib/gitlab/client/namespaces.rb +22 -0
- data/lib/gitlab/client/notes.rb +313 -0
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +147 -0
- data/lib/gitlab/client/pipeline_triggers.rb +103 -0
- data/lib/gitlab/client/pipelines.rb +105 -0
- data/lib/gitlab/client/project_badges.rb +85 -0
- data/lib/gitlab/client/project_clusters.rb +83 -0
- data/lib/gitlab/client/project_release_links.rb +76 -0
- data/lib/gitlab/client/project_releases.rb +79 -0
- data/lib/gitlab/client/projects.rb +708 -0
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +113 -0
- data/lib/gitlab/client/repository_files.rb +131 -0
- data/lib/gitlab/client/repository_submodules.rb +27 -0
- data/lib/gitlab/client/resource_label_events.rb +82 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +211 -0
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +53 -0
- data/lib/gitlab/client/sidekiq.rb +39 -0
- data/lib/gitlab/client/snippets.rb +95 -0
- data/lib/gitlab/client/system_hooks.rb +64 -0
- data/lib/gitlab/client/tags.rb +97 -0
- data/lib/gitlab/client/templates.rb +100 -0
- data/lib/gitlab/client/todos.rb +46 -0
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +397 -0
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +95 -0
- data/lib/gitlab/configuration.rb +57 -0
- data/lib/gitlab/error.rb +170 -0
- data/lib/gitlab/file_response.rb +48 -0
- data/lib/gitlab/help.rb +94 -0
- data/lib/gitlab/objectified_hash.rb +51 -0
- data/lib/gitlab/page_links.rb +35 -0
- data/lib/gitlab/paginated_response.rb +110 -0
- data/lib/gitlab/request.rb +109 -0
- data/lib/gitlab/shell.rb +83 -0
- data/lib/gitlab/shell_history.rb +57 -0
- data/lib/gitlab/version.rb +5 -0
- data/lib/gitlab.rb +56 -0
- metadata +204 -0
@@ -0,0 +1,358 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to groups.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/groups.html
|
6
|
+
module Groups
|
7
|
+
# Gets a list of groups.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.groups
|
11
|
+
# Gitlab.groups({ per_page: 40, page: 2 })
|
12
|
+
#
|
13
|
+
# @param [Hash] options A customizable set of options.
|
14
|
+
# @option options [Integer] :page The page number.
|
15
|
+
# @option options [Integer] :per_page The number of results per page.
|
16
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
17
|
+
def groups(options = {})
|
18
|
+
get('/groups', query: options)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Gets a single group.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# Gitlab.group(42)
|
25
|
+
#
|
26
|
+
# @param [Integer] id The ID of a group.
|
27
|
+
# @param [Hash] options A customizable set of options.
|
28
|
+
# @option options [Boolean] :with_custom_attributes Include custom attributes in response (admins only)
|
29
|
+
# @option options [Boolean] :with_projects Include details about group projects (default: true)
|
30
|
+
# @return [Gitlab::ObjectifiedHash]
|
31
|
+
def group(id, options = {})
|
32
|
+
get("/groups/#{url_encode id}", query: options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Creates a new group.
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# Gitlab.create_group('new-group', 'group-path')
|
39
|
+
# Gitlab.create_group('gitlab', 'gitlab-path', { description: 'New Gitlab project' })
|
40
|
+
#
|
41
|
+
# @param [String] name The name of a group.
|
42
|
+
# @param [String] path The path of a group.
|
43
|
+
# @return [Gitlab::ObjectifiedHash] Information about created group.
|
44
|
+
def create_group(name, path, options = {})
|
45
|
+
body = { name: name, path: path }.merge(options)
|
46
|
+
post('/groups', body: body)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Delete's a group.
|
50
|
+
#
|
51
|
+
# @example
|
52
|
+
# Gitlab.delete_group(42)
|
53
|
+
# @param [Integer] id The ID of a group
|
54
|
+
# @return [Gitlab::ObjectifiedHash] Information about the deleted group.
|
55
|
+
def delete_group(id)
|
56
|
+
delete("/groups/#{url_encode id}")
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get a list of group members.
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# Gitlab.group_members(1)
|
63
|
+
# Gitlab.group_members(1, { per_page: 40 })
|
64
|
+
#
|
65
|
+
# @param [Integer] id The ID of a group.
|
66
|
+
# @param [Hash] options A customizable set of options.
|
67
|
+
# @option options [Integer] :page The page number.
|
68
|
+
# @option options [Integer] :per_page The number of results per page.
|
69
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
70
|
+
def group_members(id, options = {})
|
71
|
+
get("/groups/#{url_encode id}/members", query: options)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Gets a list of all group members including inherited members.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Gitlab.all_group_members(1)
|
78
|
+
# Gitlab.all_group_members(1, { per_page: 40 })
|
79
|
+
#
|
80
|
+
# @param [Integer] id The ID of a group.
|
81
|
+
# @param [Hash] options A customizable set of options.
|
82
|
+
# @option options [Integer] :page The page number.
|
83
|
+
# @option options [Integer] :per_page The number of results per page.
|
84
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
85
|
+
def all_group_members(id, options = {})
|
86
|
+
get("/groups/#{url_encode id}/members/all", query: options)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Get a list of descendant groups of a group.
|
90
|
+
#
|
91
|
+
# @example
|
92
|
+
# Gitlab.group_descendants(42)
|
93
|
+
#
|
94
|
+
# @param [Integer] id the ID of a group
|
95
|
+
# @param [Hash] options A customizable set of options.
|
96
|
+
# @option options [String] :skip_groups Skip the group IDs passed.
|
97
|
+
# @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
|
98
|
+
# @option options [String] :search Return the list of authorized groups matching the search criteria.
|
99
|
+
# @option options [String] :order_by Order groups by name or path. Default is name.
|
100
|
+
# @option options [String] :sort Order groups in asc or desc order. Default is asc.
|
101
|
+
# @option options [String] :statistics Include group statistics (admins only).
|
102
|
+
# @option options [String] :owned Limit to groups owned by the current user.
|
103
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of all subgroups under a group
|
104
|
+
def group_descendants(id, options = {})
|
105
|
+
get("/groups/#{url_encode id}/descendant_groups", query: options)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Get a list of group members that are billable.
|
109
|
+
#
|
110
|
+
# @example
|
111
|
+
# Gitlab.group_billable_members(1)
|
112
|
+
# Gitlab.group_billable_members(1, { per_page: 40 })
|
113
|
+
#
|
114
|
+
# @param [Integer] id The ID of a group.
|
115
|
+
# @param [Hash] options A customizable set of options.
|
116
|
+
# @option options [Integer] :page The page number.
|
117
|
+
# @option options [Integer] :per_page The number of results per page.
|
118
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
119
|
+
def group_billable_members(id, options = {})
|
120
|
+
get("/groups/#{url_encode id}/billable_members", query: options)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Get details of a single group member.
|
124
|
+
#
|
125
|
+
# @example
|
126
|
+
# Gitlab.group_member(1, 10)
|
127
|
+
#
|
128
|
+
# @param [Integer] team_id The ID of the group to find a member in.
|
129
|
+
# @param [Integer] user_id The user id of the member to find.
|
130
|
+
# @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
|
131
|
+
def group_member(team_id, user_id)
|
132
|
+
get("/groups/#{url_encode team_id}/members/#{user_id}")
|
133
|
+
end
|
134
|
+
|
135
|
+
# Gets a list of merge requests of a group.
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
# Gitlab.group_merge_requests(5)
|
139
|
+
#
|
140
|
+
# @param [Integer, String] group_id The ID or name of a group.
|
141
|
+
# @param [Hash] options A customizable set of options.
|
142
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
143
|
+
def group_merge_requests(group, options = {})
|
144
|
+
get("/groups/#{group}/merge_requests", query: options)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Adds a user to group.
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# Gitlab.add_group_member(1, 2, 40)
|
151
|
+
#
|
152
|
+
# @param [Integer] team_id The group id to add a member to.
|
153
|
+
# @param [Integer] user_id The user id of the user to add to the team.
|
154
|
+
# @param [Integer] access_level Project access level.
|
155
|
+
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
156
|
+
def add_group_member(team_id, user_id, access_level)
|
157
|
+
post("/groups/#{url_encode team_id}/members", body: { user_id: user_id, access_level: access_level })
|
158
|
+
end
|
159
|
+
|
160
|
+
# Edit a user of a group.
|
161
|
+
#
|
162
|
+
# @example
|
163
|
+
# Gitlab.edit_group_member(1, 2, 40)
|
164
|
+
#
|
165
|
+
# @param [Integer] team_id The group id of member to edit.
|
166
|
+
# @param [Integer] user_id The user id of the user to edit.
|
167
|
+
# @param [Integer] access_level Project access level.
|
168
|
+
# @return [Gitlab::ObjectifiedHash] Information about edited team member.
|
169
|
+
def edit_group_member(team_id, user_id, access_level)
|
170
|
+
put("/groups/#{url_encode team_id}/members/#{user_id}", body: { access_level: access_level })
|
171
|
+
end
|
172
|
+
|
173
|
+
# Removes user from user group.
|
174
|
+
#
|
175
|
+
# @example
|
176
|
+
# Gitlab.remove_group_member(1, 2)
|
177
|
+
#
|
178
|
+
# @param [Integer] team_id The group ID.
|
179
|
+
# @param [Integer] user_id The ID of a user.
|
180
|
+
# @return [Gitlab::ObjectifiedHash] Information about removed team member.
|
181
|
+
def remove_group_member(team_id, user_id)
|
182
|
+
delete("/groups/#{url_encode team_id}/members/#{user_id}")
|
183
|
+
end
|
184
|
+
|
185
|
+
# Transfers a project to a group
|
186
|
+
#
|
187
|
+
# @example
|
188
|
+
# Gitlab.transfer_project_to_group(3, 50)
|
189
|
+
#
|
190
|
+
# @param [Integer] id The ID of a group.
|
191
|
+
# @param [Integer] project_id The ID of a project.
|
192
|
+
def transfer_project_to_group(id, project_id)
|
193
|
+
body = { id: id, project_id: project_id }
|
194
|
+
post("/groups/#{url_encode id}/projects/#{project_id}", body: body)
|
195
|
+
end
|
196
|
+
|
197
|
+
# Search for groups by name
|
198
|
+
#
|
199
|
+
# @example
|
200
|
+
# Gitlab.group_search('gitlab')
|
201
|
+
#
|
202
|
+
# @param [String] search A string to search for in group names and paths.
|
203
|
+
# @param [Hash] options A customizable set of options.
|
204
|
+
# @option options [String] :per_page Number of projects to return per page
|
205
|
+
# @option options [String] :page The page to retrieve
|
206
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
207
|
+
def group_search(search, options = {})
|
208
|
+
options[:search] = search
|
209
|
+
get('/groups', query: options)
|
210
|
+
end
|
211
|
+
|
212
|
+
# Get a list of projects under a group
|
213
|
+
# @example
|
214
|
+
# Gitlab.group_projects(1)
|
215
|
+
#
|
216
|
+
# @param [Integer] id The ID of a group
|
217
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
|
218
|
+
def group_projects(id, options = {})
|
219
|
+
get("/groups/#{url_encode id}/projects", query: options)
|
220
|
+
end
|
221
|
+
|
222
|
+
# Get a list of subgroups under a group
|
223
|
+
# @example
|
224
|
+
# Gitlab.group_subgroups(1)
|
225
|
+
#
|
226
|
+
# @param [Integer] id the ID of a group
|
227
|
+
# @param [Hash] options A customizable set of options.
|
228
|
+
# @option options [String] :skip_groups Skip the group IDs passed.
|
229
|
+
# @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
|
230
|
+
# @option options [String] :search Return the list of authorized groups matching the search criteria.
|
231
|
+
# @option options [String] :order_by Order groups by name or path. Default is name.
|
232
|
+
# @option options [String] :sort Order groups in asc or desc order. Default is asc.
|
233
|
+
# @option options [String] :statistics Include group statistics (admins only).
|
234
|
+
# @option options [String] :owned Limit to groups owned by the current user.
|
235
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
|
236
|
+
def group_subgroups(id, options = {})
|
237
|
+
get("/groups/#{url_encode id}/subgroups", query: options)
|
238
|
+
end
|
239
|
+
|
240
|
+
# Updates an existing group.
|
241
|
+
#
|
242
|
+
# @example
|
243
|
+
# Gitlab.edit_group(42)
|
244
|
+
# Gitlab.edit_group(42, { name: 'Group Name' })
|
245
|
+
#
|
246
|
+
# @param [Integer] group The ID.
|
247
|
+
# @param [Hash] options A customizable set of options
|
248
|
+
# @option options [String] :name The name of the group.
|
249
|
+
# @option options [String] :path The path of the group.
|
250
|
+
# @option options [String] :description The description of the group.
|
251
|
+
# @option options [String] :visibility The visibility level of the group. Can be private, internal, or public
|
252
|
+
# @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
|
253
|
+
# @option options [String] :request_access_enabled Allow users to request member access.
|
254
|
+
# @return [Gitlab::ObjectifiedHash] Information about the edited group.
|
255
|
+
def edit_group(id, options = {})
|
256
|
+
put("/groups/#{url_encode id}", body: options)
|
257
|
+
end
|
258
|
+
|
259
|
+
# Gets a list of issues of a group.
|
260
|
+
#
|
261
|
+
# @example
|
262
|
+
# Gitlab.group_issues(5)
|
263
|
+
#
|
264
|
+
# @param [Integer, String] group_id The ID or name of a group.
|
265
|
+
# @param [Hash] options A customizable set of options.
|
266
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
267
|
+
def group_issues(group, options = {})
|
268
|
+
get("/groups/#{group}/issues", query: options)
|
269
|
+
end
|
270
|
+
|
271
|
+
# Sync group with LDAP
|
272
|
+
#
|
273
|
+
# @example
|
274
|
+
# Gitlab.sync_ldap_group(1)
|
275
|
+
#
|
276
|
+
# @param [Integer] id The ID or name of a group.
|
277
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
278
|
+
def sync_ldap_group(id)
|
279
|
+
post("/groups/#{url_encode id}/ldap_sync")
|
280
|
+
end
|
281
|
+
|
282
|
+
# Add LDAP group link
|
283
|
+
#
|
284
|
+
# @example
|
285
|
+
# Gitlab.add_ldap_group_links(1, 'all', 50, 'ldap')
|
286
|
+
#
|
287
|
+
# @param [Integer] id The ID of a group
|
288
|
+
# @param [String] cn The CN of a LDAP group
|
289
|
+
# @param [Integer] group_access Minimum access level for members of the LDAP group.
|
290
|
+
# @param [String] provider LDAP provider for the LDAP group
|
291
|
+
# @return [Gitlab::ObjectifiedHash] Information about added ldap group link
|
292
|
+
def add_ldap_group_links(id, commonname, group_access, provider)
|
293
|
+
post("/groups/#{url_encode id}/ldap_group_links", body: { cn: commonname, group_access: group_access, provider: provider })
|
294
|
+
end
|
295
|
+
|
296
|
+
# Delete LDAP group link
|
297
|
+
#
|
298
|
+
# @example
|
299
|
+
# Gitlab.delete_ldap_group_links(1, 'all')
|
300
|
+
#
|
301
|
+
# @param [Integer] id The ID of a group
|
302
|
+
# @param [String] cn The CN of a LDAP group
|
303
|
+
# @return [Gitlab::ObjectifiedHash] Empty hash
|
304
|
+
def delete_ldap_group_links(id, commonname, provider)
|
305
|
+
delete("/groups/#{url_encode id}/ldap_group_links/#{url_encode provider}/#{url_encode commonname}")
|
306
|
+
end
|
307
|
+
|
308
|
+
# Gets group custom_attributes.
|
309
|
+
#
|
310
|
+
# @example
|
311
|
+
# Gitlab.group_custom_attributes(2)
|
312
|
+
#
|
313
|
+
# @param [Integer] group_id The ID of a group.
|
314
|
+
# @return [Gitlab::ObjectifiedHash]
|
315
|
+
def group_custom_attributes(group_id)
|
316
|
+
get("/groups/#{group_id}/custom_attributes")
|
317
|
+
end
|
318
|
+
|
319
|
+
# Gets single group custom_attribute.
|
320
|
+
#
|
321
|
+
# @example
|
322
|
+
# Gitlab.group_custom_attribute('key', 2)
|
323
|
+
#
|
324
|
+
# @param [String] key The custom_attributes key
|
325
|
+
# @param [Integer] group_id The ID of a group.
|
326
|
+
# @return [Gitlab::ObjectifiedHash]
|
327
|
+
def group_custom_attribute(key, group_id)
|
328
|
+
get("/groups/#{group_id}/custom_attributes/#{key}")
|
329
|
+
end
|
330
|
+
|
331
|
+
# Creates a new custom_attribute
|
332
|
+
#
|
333
|
+
# @example
|
334
|
+
# Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)
|
335
|
+
#
|
336
|
+
# @param [String] key The custom_attributes key
|
337
|
+
# @param [String] value The custom_attributes value
|
338
|
+
# @param [Integer] group_id The ID of a group.
|
339
|
+
# @return [Gitlab::ObjectifiedHash]
|
340
|
+
def add_group_custom_attribute(key, value, group_id)
|
341
|
+
url = "/groups/#{group_id}/custom_attributes/#{key}"
|
342
|
+
put(url, body: { value: value })
|
343
|
+
end
|
344
|
+
|
345
|
+
# Delete custom_attribute
|
346
|
+
# Will delete a custom_attribute
|
347
|
+
#
|
348
|
+
# @example
|
349
|
+
# Gitlab.delete_group_custom_attribute('somekey', 2)
|
350
|
+
#
|
351
|
+
# @param [String] key The custom_attribute key to delete
|
352
|
+
# @param [Integer] group_id The ID of a group.
|
353
|
+
# @return [Boolean]
|
354
|
+
def delete_group_custom_attribute(key, group_id = nil)
|
355
|
+
delete("/groups/#{group_id}/custom_attributes/#{key}")
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to issue links.
|
5
|
+
# @see https://docs.gitlab.com/ee/api/issue_links.html
|
6
|
+
module IssueLinks
|
7
|
+
# Gets a list of links for a issue.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.issue_links(5, 10)
|
11
|
+
#
|
12
|
+
# @param [Integer] project The ID of a project.
|
13
|
+
# @param [Integer] issue The ID of an issue.
|
14
|
+
# @option options [Integer] :page The page number.
|
15
|
+
# @option options [Integer] :per_page The number of results per page.
|
16
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
17
|
+
def issue_links(project, issue, options = {})
|
18
|
+
get("/projects/#{url_encode project}/issues/#{issue}/links", query: options)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Creates a new issue link.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# Gitlab.create_issue_link(6, 1, 6, 2)
|
25
|
+
#
|
26
|
+
# @param [Integer, String] project The ID or name of a project.
|
27
|
+
# @param [Integer] issue The ID of an issue.
|
28
|
+
# @param [Integer] target_project_id Project ID the target issue is located in.
|
29
|
+
# @param [Integer] target_issue_iid The ID of the target issue.
|
30
|
+
# @return [Gitlab::ObjectifiedHash] Information about created link.
|
31
|
+
def create_issue_link(project, issue, target_project_id, target_issue_iid)
|
32
|
+
post("/projects/#{url_encode project}/issues/#{issue}/links", body: { target_project_id: target_project_id, target_issue_iid: target_issue_iid })
|
33
|
+
end
|
34
|
+
|
35
|
+
# Deletes an issue link.
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# Gitlab.delete_issue_link(5, 10, 123)
|
39
|
+
#
|
40
|
+
# @param [Integer] project The ID of a project.
|
41
|
+
# @param [Integer] issue The ID of an issue.
|
42
|
+
# @param [Integer] id The ID of a link.
|
43
|
+
# @return [Gitlab::ObjectifiedHash]
|
44
|
+
def delete_issue_link(project, issue, id)
|
45
|
+
delete("/projects/#{url_encode project}/issues/#{issue}/links/#{id}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to issues.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/issues.html
|
6
|
+
module Issues
|
7
|
+
# Gets a list of user's issues.
|
8
|
+
# Will return a list of project's issues if project ID passed.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# Gitlab.issues
|
12
|
+
# Gitlab.issues(5)
|
13
|
+
# Gitlab.issues({ per_page: 40 })
|
14
|
+
#
|
15
|
+
# @param [Integer, String] project The ID or name of a project.
|
16
|
+
# @param [Hash] options A customizable set of options.
|
17
|
+
# @option options [Integer] :page The page number.
|
18
|
+
# @option options [Integer] :per_page The number of results per page.
|
19
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
20
|
+
def issues(project = nil, options = {})
|
21
|
+
if project.to_s.empty? && project.to_i.zero?
|
22
|
+
get('/issues', query: options)
|
23
|
+
else
|
24
|
+
get("/projects/#{url_encode project}/issues", query: options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Gets a single issue.
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# Gitlab.issue(5, 42)
|
32
|
+
#
|
33
|
+
# @param [Integer, String] project The ID or name of a project.
|
34
|
+
# @param [Integer] id The ID of an issue.
|
35
|
+
# @return [Gitlab::ObjectifiedHash]
|
36
|
+
def issue(project, id)
|
37
|
+
get("/projects/#{url_encode project}/issues/#{id}")
|
38
|
+
end
|
39
|
+
|
40
|
+
# Creates a new issue.
|
41
|
+
#
|
42
|
+
# @example
|
43
|
+
# Gitlab.create_issue(5, 'New issue')
|
44
|
+
# Gitlab.create_issue(5, 'New issue', { description: 'This is a new issue', assignee_id: 42 })
|
45
|
+
#
|
46
|
+
# @param [Integer, String] project The ID or name of a project.
|
47
|
+
# @param [String] title The title of an issue.
|
48
|
+
# @param [Hash] options A customizable set of options.
|
49
|
+
# @option options [String] :description The description of an issue.
|
50
|
+
# @option options [Integer] :assignee_id The ID of a user to assign issue.
|
51
|
+
# @option options [Integer] :milestone_id The ID of a milestone to assign issue.
|
52
|
+
# @option options [String] :labels Comma-separated label names for an issue.
|
53
|
+
# @return [Gitlab::ObjectifiedHash] Information about created issue.
|
54
|
+
def create_issue(project, title, options = {})
|
55
|
+
body = { title: title }.merge(options)
|
56
|
+
post("/projects/#{url_encode project}/issues", body: body)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Updates an issue.
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
# Gitlab.edit_issue(6, 1, { title: 'Updated title' })
|
63
|
+
#
|
64
|
+
# @param [Integer, String] project The ID or name of a project.
|
65
|
+
# @param [Integer] id The ID of an issue.
|
66
|
+
# @param [Hash] options A customizable set of options.
|
67
|
+
# @option options [String] :title The title of an issue.
|
68
|
+
# @option options [String] :description The description of an issue.
|
69
|
+
# @option options [Integer] :assignee_id The ID of a user to assign issue.
|
70
|
+
# @option options [Integer] :milestone_id The ID of a milestone to assign issue.
|
71
|
+
# @option options [String] :labels Comma-separated label names for an issue.
|
72
|
+
# @option options [String] :state_event The state event of an issue ('close' or 'reopen').
|
73
|
+
# @return [Gitlab::ObjectifiedHash] Information about updated issue.
|
74
|
+
def edit_issue(project, id, options = {})
|
75
|
+
put("/projects/#{url_encode project}/issues/#{id}", body: options)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Closes an issue.
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Gitlab.close_issue(3, 42)
|
82
|
+
#
|
83
|
+
# @param [Integer, String] project The ID or name of a project.
|
84
|
+
# @param [Integer] id The ID of an issue.
|
85
|
+
# @return [Gitlab::ObjectifiedHash] Information about closed issue.
|
86
|
+
def close_issue(project, id)
|
87
|
+
put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'close' })
|
88
|
+
end
|
89
|
+
|
90
|
+
# Reopens an issue.
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
# Gitlab.reopen_issue(3, 42)
|
94
|
+
#
|
95
|
+
# @param [Integer, String] project The ID or name of a project.
|
96
|
+
# @param [Integer] id The ID of an issue.
|
97
|
+
# @return [Gitlab::ObjectifiedHash] Information about reopened issue.
|
98
|
+
def reopen_issue(project, id)
|
99
|
+
put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'reopen' })
|
100
|
+
end
|
101
|
+
|
102
|
+
# Subscribe to an issue.
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# Gitlab.subscribe_to_issue(3, 42)
|
106
|
+
#
|
107
|
+
# @param [Integer, String] project The ID or name of a project.
|
108
|
+
# @param [Integer] id The ID of an issue.
|
109
|
+
# @return [Gitlab::ObjectifiedHash] Information about subscribed issue.
|
110
|
+
def subscribe_to_issue(project, id)
|
111
|
+
post("/projects/#{url_encode project}/issues/#{id}/subscribe")
|
112
|
+
end
|
113
|
+
|
114
|
+
# Unsubscribe from an issue.
|
115
|
+
#
|
116
|
+
# @example
|
117
|
+
# Gitlab.unsubscribe_from_issue(3, 42)
|
118
|
+
#
|
119
|
+
# @param [Integer, String] project The ID or name of a project.
|
120
|
+
# @param [Integer] id The ID of an issue.
|
121
|
+
# @return [Gitlab::ObjectifiedHash] Information about unsubscribed issue.
|
122
|
+
def unsubscribe_from_issue(project, id)
|
123
|
+
post("/projects/#{url_encode project}/issues/#{id}/unsubscribe")
|
124
|
+
end
|
125
|
+
|
126
|
+
# Deletes an issue.
|
127
|
+
# Only for admins and project owners
|
128
|
+
#
|
129
|
+
# @example
|
130
|
+
# Gitlab.delete_issue(3, 42)
|
131
|
+
#
|
132
|
+
# @param [Integer, String] project The ID or name of a project.
|
133
|
+
# @param [Integer] id The ID of an issue.
|
134
|
+
# @return [Gitlab::ObjectifiedHash] Information about deleted issue.
|
135
|
+
def delete_issue(project, id)
|
136
|
+
delete("/projects/#{url_encode project}/issues/#{id}")
|
137
|
+
end
|
138
|
+
|
139
|
+
# Move an issue.
|
140
|
+
#
|
141
|
+
# @example
|
142
|
+
# Gitlab.move_issue(3, 42, { to_project_id: '4' })
|
143
|
+
#
|
144
|
+
# @param [Integer, String] project The ID or name of a project.
|
145
|
+
# @param [Integer] id The ID of an issue.
|
146
|
+
# @option options [String] :to_project_id The ID of the new project.
|
147
|
+
# @return [Gitlab::ObjectifiedHash] Information about moved issue.
|
148
|
+
def move_issue(project, id, options = {})
|
149
|
+
post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Sets an estimated time of work for an issue.
|
153
|
+
#
|
154
|
+
# @example
|
155
|
+
# Gitlab.estimate_time_of_issue(3, 42, '3h30m')
|
156
|
+
#
|
157
|
+
# @param [Integer, String] project The ID or name of a project.
|
158
|
+
# @param [Integer] id The ID of an issue.
|
159
|
+
# @param [String] duration The duration in human format. e.g: 3h30m
|
160
|
+
def estimate_time_of_issue(project, id, duration)
|
161
|
+
post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
|
162
|
+
end
|
163
|
+
|
164
|
+
# Resets the estimated time for an issue to 0 seconds.
|
165
|
+
#
|
166
|
+
# @example
|
167
|
+
# Gitlab.reset_time_estimate_of_issue(3, 42)
|
168
|
+
#
|
169
|
+
# @param [Integer, String] project The ID or name of a project.
|
170
|
+
# @param [Integer] id The ID of an issue.
|
171
|
+
def reset_time_estimate_of_issue(project, id)
|
172
|
+
post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate")
|
173
|
+
end
|
174
|
+
|
175
|
+
# Adds spent time for an issue
|
176
|
+
#
|
177
|
+
# @example
|
178
|
+
# Gitlab.estimate_time_of_issue(3, 42, '3h30m')
|
179
|
+
#
|
180
|
+
# @param [Integer, String] project The ID or name of a project.
|
181
|
+
# @param [Integer] id The ID of an issue.
|
182
|
+
# @param [String] duration The time spent in human format. e.g: 3h30m
|
183
|
+
def add_time_spent_on_issue(project, id, duration)
|
184
|
+
post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: duration })
|
185
|
+
end
|
186
|
+
|
187
|
+
# Resets the total spent time for this issue to 0 seconds.
|
188
|
+
#
|
189
|
+
# @example
|
190
|
+
# Gitlab.reset_time_spent_on_issue(3, 42)
|
191
|
+
#
|
192
|
+
# @param [Integer, String] project The ID or name of a project.
|
193
|
+
# @param [Integer] id The ID of an issue.
|
194
|
+
def reset_time_spent_on_issue(project, id)
|
195
|
+
post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
|
196
|
+
end
|
197
|
+
|
198
|
+
# Get time tracking stats for an issue
|
199
|
+
#
|
200
|
+
# @example
|
201
|
+
# @gitlab.time_stats_for_issue(3, 42)
|
202
|
+
#
|
203
|
+
# @param [Integer, String] project The ID or name of a project.
|
204
|
+
# @param [Integer] id The ID of an issue.
|
205
|
+
def time_stats_for_issue(project, id)
|
206
|
+
get("/projects/#{url_encode project}/issues/#{id}/time_stats")
|
207
|
+
end
|
208
|
+
|
209
|
+
# Get participants on issue
|
210
|
+
#
|
211
|
+
# @example
|
212
|
+
# @gitlab.participants_on_issue(3, 42)
|
213
|
+
#
|
214
|
+
# @param [Integer, String] project The ID or name of a project.
|
215
|
+
# @param [Integer] id The ID of an issue.
|
216
|
+
def participants_on_issue(project, id)
|
217
|
+
get("/projects/#{url_encode project}/issues/#{id}/participants")
|
218
|
+
end
|
219
|
+
|
220
|
+
# List merge requests that will close issue on merge
|
221
|
+
#
|
222
|
+
# @example
|
223
|
+
# Gitlab.merge_requests_closing_issue_on_merge(3, 42)
|
224
|
+
#
|
225
|
+
# @param [Integer, String] project The ID or name of a project.
|
226
|
+
# @param [Integer] id The ID of an issue.
|
227
|
+
def merge_requests_closing_issue_on_merge(project, id)
|
228
|
+
get("/projects/#{url_encode project}/issues/#{id}/closed_by")
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|