gitlab 4.5.0 → 4.6.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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/stale.yml +18 -0
  3. data/.rubocop_todo.yml +46 -0
  4. data/Gemfile +2 -0
  5. data/README.md +22 -22
  6. data/Rakefile +3 -5
  7. data/bin/console +1 -0
  8. data/exe/gitlab +5 -1
  9. data/gitlab.gemspec +9 -6
  10. data/lib/gitlab.rb +6 -3
  11. data/lib/gitlab/api.rb +5 -3
  12. data/lib/gitlab/cli.rb +11 -5
  13. data/lib/gitlab/cli_helpers.rb +31 -22
  14. data/lib/gitlab/client.rb +7 -8
  15. data/lib/gitlab/client/access_requests.rb +100 -93
  16. data/lib/gitlab/client/award_emojis.rb +127 -127
  17. data/lib/gitlab/client/boards.rb +82 -82
  18. data/lib/gitlab/client/branches.rb +89 -89
  19. data/lib/gitlab/client/build_variables.rb +117 -117
  20. data/lib/gitlab/client/builds.rb +98 -98
  21. data/lib/gitlab/client/commits.rb +154 -154
  22. data/lib/gitlab/client/deployments.rb +29 -29
  23. data/lib/gitlab/client/environments.rb +80 -80
  24. data/lib/gitlab/client/events.rb +54 -54
  25. data/lib/gitlab/client/group_milestones.rb +85 -86
  26. data/lib/gitlab/client/groups.rb +178 -178
  27. data/lib/gitlab/client/issues.rb +195 -196
  28. data/lib/gitlab/client/jobs.rb +150 -150
  29. data/lib/gitlab/client/keys.rb +14 -14
  30. data/lib/gitlab/client/labels.rb +79 -79
  31. data/lib/gitlab/client/merge_request_approvals.rb +102 -102
  32. data/lib/gitlab/client/merge_requests.rb +281 -256
  33. data/lib/gitlab/client/milestones.rb +85 -85
  34. data/lib/gitlab/client/namespaces.rb +18 -18
  35. data/lib/gitlab/client/notes.rb +260 -260
  36. data/lib/gitlab/client/pipeline_schedules.rb +123 -123
  37. data/lib/gitlab/client/pipeline_triggers.rb +93 -93
  38. data/lib/gitlab/client/pipelines.rb +62 -62
  39. data/lib/gitlab/client/projects.rb +526 -505
  40. data/lib/gitlab/client/repositories.rb +68 -55
  41. data/lib/gitlab/client/repository_files.rb +103 -103
  42. data/lib/gitlab/client/runners.rb +113 -115
  43. data/lib/gitlab/client/services.rb +46 -45
  44. data/lib/gitlab/client/sidekiq.rb +32 -32
  45. data/lib/gitlab/client/snippets.rb +86 -86
  46. data/lib/gitlab/client/system_hooks.rb +57 -57
  47. data/lib/gitlab/client/tags.rb +87 -88
  48. data/lib/gitlab/client/todos.rb +41 -41
  49. data/lib/gitlab/client/users.rb +242 -228
  50. data/lib/gitlab/client/versions.rb +16 -0
  51. data/lib/gitlab/configuration.rb +7 -5
  52. data/lib/gitlab/error.rb +3 -1
  53. data/lib/gitlab/file_response.rb +4 -2
  54. data/lib/gitlab/help.rb +9 -9
  55. data/lib/gitlab/objectified_hash.rb +5 -4
  56. data/lib/gitlab/page_links.rb +9 -7
  57. data/lib/gitlab/paginated_response.rb +14 -4
  58. data/lib/gitlab/request.rb +8 -5
  59. data/lib/gitlab/shell.rb +6 -4
  60. data/lib/gitlab/shell_history.rb +7 -5
  61. data/lib/gitlab/version.rb +3 -1
  62. metadata +8 -5
@@ -1,193 +1,193 @@
1
- class Gitlab::Client
2
- # Defines methods related to groups.
3
- # @see https://docs.gitlab.com/ce/api/groups.html
4
- module Groups
5
- # Gets a list of groups.
6
- #
7
- # @example
8
- # Gitlab.groups
9
- # Gitlab.groups({ per_page: 40, page: 2 })
10
- #
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 groups(options={})
16
- get("/groups", query: options)
17
- end
1
+ # frozen_string_literal: true
18
2
 
19
- # Gets a single group.
20
- #
21
- # @example
22
- # Gitlab.group(42)
23
- #
24
- # @param [Integer] id The ID of a group.
25
- # @return [Gitlab::ObjectifiedHash]
26
- def group(id)
27
- get("/groups/#{url_encode id}")
28
- end
3
+ # Defines methods related to groups.
4
+ # @see https://docs.gitlab.com/ce/api/groups.html
5
+ module Groups
6
+ # Gets a list of groups.
7
+ #
8
+ # @example
9
+ # Gitlab.groups
10
+ # Gitlab.groups({ per_page: 40, page: 2 })
11
+ #
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 groups(options = {})
17
+ get('/groups', query: options)
18
+ end
29
19
 
30
- # Creates a new group.
31
- #
32
- # @example
33
- # Gitlab.create_group('new-group', 'group-path')
34
- # Gitlab.create_group('gitlab', 'gitlab-path', { description: 'New Gitlab project' })
35
- #
36
- # @param [String] name The name of a group.
37
- # @param [String] path The path of a group.
38
- # @return [Gitlab::ObjectifiedHash] Information about created group.
39
- def create_group(name, path, options={})
40
- body = { name: name, path: path }.merge(options)
41
- post("/groups", body: body)
42
- end
20
+ # Gets a single group.
21
+ #
22
+ # @example
23
+ # Gitlab.group(42)
24
+ #
25
+ # @param [Integer] id The ID of a group.
26
+ # @return [Gitlab::ObjectifiedHash]
27
+ def group(id)
28
+ get("/groups/#{url_encode id}")
29
+ end
43
30
 
44
- # Delete's a group.
45
- #
46
- # @example
47
- # Gitlab.delete_group(42)
48
- # @param [Integer] id The ID of a group
49
- # @return [Gitlab::ObjectifiedHash] Information about the deleted group.
50
- def delete_group(id)
51
- delete("/groups/#{url_encode id}")
52
- end
31
+ # Creates a new group.
32
+ #
33
+ # @example
34
+ # Gitlab.create_group('new-group', 'group-path')
35
+ # Gitlab.create_group('gitlab', 'gitlab-path', { description: 'New Gitlab project' })
36
+ #
37
+ # @param [String] name The name of a group.
38
+ # @param [String] path The path of a group.
39
+ # @return [Gitlab::ObjectifiedHash] Information about created group.
40
+ def create_group(name, path, options = {})
41
+ body = { name: name, path: path }.merge(options)
42
+ post('/groups', body: body)
43
+ end
53
44
 
54
- # Get a list of group members.
55
- #
56
- # @example
57
- # Gitlab.group_members(1)
58
- # Gitlab.group_members(1, { per_page: 40 })
59
- #
60
- # @param [Integer] id The ID of a group.
61
- # @param [Hash] options A customizable set of options.
62
- # @option options [Integer] :page The page number.
63
- # @option options [Integer] :per_page The number of results per page.
64
- # @return [Array<Gitlab::ObjectifiedHash>]
65
- def group_members(id, options={})
66
- get("/groups/#{url_encode id}/members", query: options)
67
- end
45
+ # Delete's a group.
46
+ #
47
+ # @example
48
+ # Gitlab.delete_group(42)
49
+ # @param [Integer] id The ID of a group
50
+ # @return [Gitlab::ObjectifiedHash] Information about the deleted group.
51
+ def delete_group(id)
52
+ delete("/groups/#{url_encode id}")
53
+ end
68
54
 
69
- # Get details of a single group member.
70
- #
71
- # @example
72
- # Gitlab.group_member(1, 10)
73
- #
74
- # @param [Integer] team_id The ID of the group to find a member in.
75
- # @param [Integer] user_id The user id of the member to find.
76
- # @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
77
- def group_member(team_id, user_id)
78
- get("/groups/#{url_encode team_id}/members/#{user_id}")
79
- end
55
+ # Get a list of group members.
56
+ #
57
+ # @example
58
+ # Gitlab.group_members(1)
59
+ # Gitlab.group_members(1, { per_page: 40 })
60
+ #
61
+ # @param [Integer] id The ID of a group.
62
+ # @param [Hash] options A customizable set of options.
63
+ # @option options [Integer] :page The page number.
64
+ # @option options [Integer] :per_page The number of results per page.
65
+ # @return [Array<Gitlab::ObjectifiedHash>]
66
+ def group_members(id, options = {})
67
+ get("/groups/#{url_encode id}/members", query: options)
68
+ end
69
+
70
+ # Get details of a single group member.
71
+ #
72
+ # @example
73
+ # Gitlab.group_member(1, 10)
74
+ #
75
+ # @param [Integer] team_id The ID of the group to find a member in.
76
+ # @param [Integer] user_id The user id of the member to find.
77
+ # @return [Gitlab::ObjectifiedHash] (id, username, name, email, state, access_level ...)
78
+ def group_member(team_id, user_id)
79
+ get("/groups/#{url_encode team_id}/members/#{user_id}")
80
+ end
80
81
 
81
- # Adds a user to group.
82
- #
83
- # @example
84
- # Gitlab.add_group_member(1, 2, 40)
85
- #
86
- # @param [Integer] team_id The group id to add a member to.
87
- # @param [Integer] user_id The user id of the user to add to the team.
88
- # @param [Integer] access_level Project access level.
89
- # @return [Gitlab::ObjectifiedHash] Information about added team member.
90
- def add_group_member(team_id, user_id, access_level)
91
- post("/groups/#{url_encode team_id}/members", body: { user_id: user_id, access_level: access_level })
92
- end
82
+ # Adds a user to group.
83
+ #
84
+ # @example
85
+ # Gitlab.add_group_member(1, 2, 40)
86
+ #
87
+ # @param [Integer] team_id The group id to add a member to.
88
+ # @param [Integer] user_id The user id of the user to add to the team.
89
+ # @param [Integer] access_level Project access level.
90
+ # @return [Gitlab::ObjectifiedHash] Information about added team member.
91
+ def add_group_member(team_id, user_id, access_level)
92
+ post("/groups/#{url_encode team_id}/members", body: { user_id: user_id, access_level: access_level })
93
+ end
93
94
 
94
- # Edit a user of a group.
95
- #
96
- # @example
97
- # Gitlab.edit_group_member(1, 2, 40)
98
- #
99
- # @param [Integer] team_id The group id of member to edit.
100
- # @param [Integer] user_id The user id of the user to edit.
101
- # @param [Integer] access_level Project access level.
102
- # @return [Gitlab::ObjectifiedHash] Information about edited team member.
103
- def edit_group_member(team_id, user_id, access_level)
104
- put("/groups/#{url_encode team_id}/members/#{user_id}", body: { access_level: access_level })
105
- end
95
+ # Edit a user of a group.
96
+ #
97
+ # @example
98
+ # Gitlab.edit_group_member(1, 2, 40)
99
+ #
100
+ # @param [Integer] team_id The group id of member to edit.
101
+ # @param [Integer] user_id The user id of the user to edit.
102
+ # @param [Integer] access_level Project access level.
103
+ # @return [Gitlab::ObjectifiedHash] Information about edited team member.
104
+ def edit_group_member(team_id, user_id, access_level)
105
+ put("/groups/#{url_encode team_id}/members/#{user_id}", body: { access_level: access_level })
106
+ end
106
107
 
107
- # Removes user from user group.
108
- #
109
- # @example
110
- # Gitlab.remove_group_member(1, 2)
111
- #
112
- # @param [Integer] team_id The group ID.
113
- # @param [Integer] user_id The ID of a user.
114
- # @return [Gitlab::ObjectifiedHash] Information about removed team member.
115
- def remove_group_member(team_id, user_id)
116
- delete("/groups/#{url_encode team_id}/members/#{user_id}")
117
- end
108
+ # Removes user from user group.
109
+ #
110
+ # @example
111
+ # Gitlab.remove_group_member(1, 2)
112
+ #
113
+ # @param [Integer] team_id The group ID.
114
+ # @param [Integer] user_id The ID of a user.
115
+ # @return [Gitlab::ObjectifiedHash] Information about removed team member.
116
+ def remove_group_member(team_id, user_id)
117
+ delete("/groups/#{url_encode team_id}/members/#{user_id}")
118
+ end
118
119
 
119
- # Transfers a project to a group
120
- #
121
- # @example
122
- # Gitlab.transfer_project_to_group(3, 50)
123
- #
124
- # @param [Integer] id The ID of a group.
125
- # @param [Integer] project_id The ID of a project.
126
- def transfer_project_to_group(id, project_id)
127
- body = { id: id, project_id: project_id }
128
- post("/groups/#{url_encode id}/projects/#{project_id}", body: body)
129
- end
120
+ # Transfers a project to a group
121
+ #
122
+ # @example
123
+ # Gitlab.transfer_project_to_group(3, 50)
124
+ #
125
+ # @param [Integer] id The ID of a group.
126
+ # @param [Integer] project_id The ID of a project.
127
+ def transfer_project_to_group(id, project_id)
128
+ body = { id: id, project_id: project_id }
129
+ post("/groups/#{url_encode id}/projects/#{project_id}", body: body)
130
+ end
130
131
 
131
- # Search for groups by name
132
- #
133
- # @example
134
- # Gitlab.group_search('gitlab')
135
- #
136
- # @param [String] search A string to search for in group names and paths.
137
- # @param [Hash] options A customizable set of options.
138
- # @option options [String] :per_page Number of projects to return per page
139
- # @option options [String] :page The page to retrieve
140
- # @return [Array<Gitlab::ObjectifiedHash>]
141
- def group_search(search, options={})
142
- options[:search] = search
143
- get("/groups", query: options)
144
- end
132
+ # Search for groups by name
133
+ #
134
+ # @example
135
+ # Gitlab.group_search('gitlab')
136
+ #
137
+ # @param [String] search A string to search for in group names and paths.
138
+ # @param [Hash] options A customizable set of options.
139
+ # @option options [String] :per_page Number of projects to return per page
140
+ # @option options [String] :page The page to retrieve
141
+ # @return [Array<Gitlab::ObjectifiedHash>]
142
+ def group_search(search, options = {})
143
+ options[:search] = search
144
+ get('/groups', query: options)
145
+ end
145
146
 
146
- # Get a list of projects under a group
147
- # @example
148
- # Gitlab.group_projects(1)
149
- #
150
- # @param [Integer] id The ID of a group
151
- # @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
152
- def group_projects(id, options={})
153
- get("/groups/#{url_encode id}/projects", query: options)
154
- end
147
+ # Get a list of projects under a group
148
+ # @example
149
+ # Gitlab.group_projects(1)
150
+ #
151
+ # @param [Integer] id The ID of a group
152
+ # @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group
153
+ def group_projects(id, options = {})
154
+ get("/groups/#{url_encode id}/projects", query: options)
155
+ end
155
156
 
156
- # Get a list of subgroups under a group
157
- # @example
158
- # Gitlab.group_subgroups(1)
159
- #
160
- # @param [Integer] id the ID of a group
161
- # @param [Hash] options A customizable set of options.
162
- # @option options [String] :skip_groups Skip the group IDs passed.
163
- # @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
164
- # @option options [String] :search Return the list of authorized groups matching the search criteria.
165
- # @option options [String] :order_by Order groups by name or path. Default is name.
166
- # @option options [String] :sort Order groups in asc or desc order. Default is asc.
167
- # @option options [String] :statistics Include group statistics (admins only).
168
- # @option options [String] :owned Limit to groups owned by the current user.
169
- # @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
170
- def group_subgroups(id, options={})
171
- get("/groups/#{url_encode id}/subgroups", query: options)
172
- end
157
+ # Get a list of subgroups under a group
158
+ # @example
159
+ # Gitlab.group_subgroups(1)
160
+ #
161
+ # @param [Integer] id the ID of a group
162
+ # @param [Hash] options A customizable set of options.
163
+ # @option options [String] :skip_groups Skip the group IDs passed.
164
+ # @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
165
+ # @option options [String] :search Return the list of authorized groups matching the search criteria.
166
+ # @option options [String] :order_by Order groups by name or path. Default is name.
167
+ # @option options [String] :sort Order groups in asc or desc order. Default is asc.
168
+ # @option options [String] :statistics Include group statistics (admins only).
169
+ # @option options [String] :owned Limit to groups owned by the current user.
170
+ # @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group
171
+ def group_subgroups(id, options = {})
172
+ get("/groups/#{url_encode id}/subgroups", query: options)
173
+ end
173
174
 
174
- # Updates an existing group.
175
- #
176
- # @example
177
- # Gitlab.edit_group(42)
178
- # Gitlab.edit_group(42, { name: 'Group Name' })
179
- #
180
- # @param [Integer] group The ID.
181
- # @param [Hash] options A customizable set of options
182
- # @option options [String] :name The name of the group.
183
- # @option options [String] :path The path of the group.
184
- # @option options [String] :description The description of the group.
185
- # @option options [String] :visibility The visibility level of the group. Can be private, internal, or public
186
- # @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
187
- # @option options [String] :request_access_enabled Allow users to request member access.
188
- # @return [Gitlab::ObjectifiedHash] Information about the edited group.
189
- def edit_group(id, options={})
190
- put("/groups/#{url_encode id}", body: options)
191
- end
175
+ # Updates an existing group.
176
+ #
177
+ # @example
178
+ # Gitlab.edit_group(42)
179
+ # Gitlab.edit_group(42, { name: 'Group Name' })
180
+ #
181
+ # @param [Integer] group The ID.
182
+ # @param [Hash] options A customizable set of options
183
+ # @option options [String] :name The name of the group.
184
+ # @option options [String] :path The path of the group.
185
+ # @option options [String] :description The description of the group.
186
+ # @option options [String] :visibility The visibility level of the group. Can be private, internal, or public
187
+ # @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr.
188
+ # @option options [String] :request_access_enabled Allow users to request member access.
189
+ # @return [Gitlab::ObjectifiedHash] Information about the edited group.
190
+ def edit_group(id, options = {})
191
+ put("/groups/#{url_encode id}", body: options)
192
192
  end
193
193
  end
@@ -1,208 +1,207 @@
1
- class Gitlab::Client
2
- # Defines methods related to issues.
3
- # @see https://docs.gitlab.com/ce/api/issues.html
4
- module Issues
5
- # Gets a list of user's issues.
6
- # Will return a list of project's issues if project ID passed.
7
- #
8
- # @example
9
- # Gitlab.issues
10
- # Gitlab.issues(5)
11
- # Gitlab.issues({ per_page: 40 })
12
- #
13
- # @param [Integer, String] project The ID or name of a project.
14
- # @param [Hash] options A customizable set of options.
15
- # @option options [Integer] :page The page number.
16
- # @option options [Integer] :per_page The number of results per page.
17
- # @return [Array<Gitlab::ObjectifiedHash>]
18
- def issues(project=nil, options={})
19
- if project.to_s.empty? && project.to_i.zero?
20
- get("/issues", query: options)
21
- else
22
- get("/projects/#{url_encode project}/issues", query: options)
23
- end
24
- end
1
+ # frozen_string_literal: true
25
2
 
26
- # Gets a single issue.
27
- #
28
- # @example
29
- # Gitlab.issue(5, 42)
30
- #
31
- # @param [Integer, String] project The ID or name of a project.
32
- # @param [Integer] id The ID of an issue.
33
- # @return [Gitlab::ObjectifiedHash]
34
- def issue(project, id)
35
- get("/projects/#{url_encode project}/issues/#{id}")
3
+ # Defines methods related to issues.
4
+ # @see https://docs.gitlab.com/ce/api/issues.html
5
+ module Issues
6
+ # Gets a list of user's issues.
7
+ # Will return a list of project's issues if project ID passed.
8
+ #
9
+ # @example
10
+ # Gitlab.issues
11
+ # Gitlab.issues(5)
12
+ # Gitlab.issues({ per_page: 40 })
13
+ #
14
+ # @param [Integer, String] project The ID or name of a project.
15
+ # @param [Hash] options A customizable set of options.
16
+ # @option options [Integer] :page The page number.
17
+ # @option options [Integer] :per_page The number of results per page.
18
+ # @return [Array<Gitlab::ObjectifiedHash>]
19
+ def issues(project = nil, options = {})
20
+ if project.to_s.empty? && project.to_i.zero?
21
+ get('/issues', query: options)
22
+ else
23
+ get("/projects/#{url_encode project}/issues", query: options)
36
24
  end
25
+ end
37
26
 
38
- # Creates a new issue.
39
- #
40
- # @example
41
- # Gitlab.create_issue(5, 'New issue')
42
- # Gitlab.create_issue(5, 'New issue', { description: 'This is a new issue', assignee_id: 42 })
43
- #
44
- # @param [Integer, String] project The ID or name of a project.
45
- # @param [String] title The title of an issue.
46
- # @param [Hash] options A customizable set of options.
47
- # @option options [String] :description The description of an issue.
48
- # @option options [Integer] :assignee_id The ID of a user to assign issue.
49
- # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
50
- # @option options [String] :labels Comma-separated label names for an issue.
51
- # @return [Gitlab::ObjectifiedHash] Information about created issue.
52
- def create_issue(project, title, options={})
53
- body = { title: title }.merge(options)
54
- post("/projects/#{url_encode project}/issues", body: body)
55
- end
27
+ # Gets a single issue.
28
+ #
29
+ # @example
30
+ # Gitlab.issue(5, 42)
31
+ #
32
+ # @param [Integer, String] project The ID or name of a project.
33
+ # @param [Integer] id The ID of an issue.
34
+ # @return [Gitlab::ObjectifiedHash]
35
+ def issue(project, id)
36
+ get("/projects/#{url_encode project}/issues/#{id}")
37
+ end
56
38
 
57
- # Updates an issue.
58
- #
59
- # @example
60
- # Gitlab.edit_issue(6, 1, { title: 'Updated title' })
61
- #
62
- # @param [Integer, String] project The ID or name of a project.
63
- # @param [Integer] id The ID of an issue.
64
- # @param [Hash] options A customizable set of options.
65
- # @option options [String] :title The title of an issue.
66
- # @option options [String] :description The description of an issue.
67
- # @option options [Integer] :assignee_id The ID of a user to assign issue.
68
- # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
69
- # @option options [String] :labels Comma-separated label names for an issue.
70
- # @option options [String] :state_event The state event of an issue ('close' or 'reopen').
71
- # @return [Gitlab::ObjectifiedHash] Information about updated issue.
72
- def edit_issue(project, id, options={})
73
- put("/projects/#{url_encode project}/issues/#{id}", body: options)
74
- end
39
+ # Creates a new issue.
40
+ #
41
+ # @example
42
+ # Gitlab.create_issue(5, 'New issue')
43
+ # Gitlab.create_issue(5, 'New issue', { description: 'This is a new issue', assignee_id: 42 })
44
+ #
45
+ # @param [Integer, String] project The ID or name of a project.
46
+ # @param [String] title The title of an issue.
47
+ # @param [Hash] options A customizable set of options.
48
+ # @option options [String] :description The description of an issue.
49
+ # @option options [Integer] :assignee_id The ID of a user to assign issue.
50
+ # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
51
+ # @option options [String] :labels Comma-separated label names for an issue.
52
+ # @return [Gitlab::ObjectifiedHash] Information about created issue.
53
+ def create_issue(project, title, options = {})
54
+ body = { title: title }.merge(options)
55
+ post("/projects/#{url_encode project}/issues", body: body)
56
+ end
75
57
 
76
- # Closes an issue.
77
- #
78
- # @example
79
- # Gitlab.close_issue(3, 42)
80
- #
81
- # @param [Integer, String] project The ID or name of a project.
82
- # @param [Integer] id The ID of an issue.
83
- # @return [Gitlab::ObjectifiedHash] Information about closed issue.
84
- def close_issue(project, id)
85
- put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'close' })
86
- end
58
+ # Updates an issue.
59
+ #
60
+ # @example
61
+ # Gitlab.edit_issue(6, 1, { title: 'Updated title' })
62
+ #
63
+ # @param [Integer, String] project The ID or name of a project.
64
+ # @param [Integer] id The ID of an issue.
65
+ # @param [Hash] options A customizable set of options.
66
+ # @option options [String] :title The title of an issue.
67
+ # @option options [String] :description The description of an issue.
68
+ # @option options [Integer] :assignee_id The ID of a user to assign issue.
69
+ # @option options [Integer] :milestone_id The ID of a milestone to assign issue.
70
+ # @option options [String] :labels Comma-separated label names for an issue.
71
+ # @option options [String] :state_event The state event of an issue ('close' or 'reopen').
72
+ # @return [Gitlab::ObjectifiedHash] Information about updated issue.
73
+ def edit_issue(project, id, options = {})
74
+ put("/projects/#{url_encode project}/issues/#{id}", body: options)
75
+ end
87
76
 
88
- # Reopens an issue.
89
- #
90
- # @example
91
- # Gitlab.reopen_issue(3, 42)
92
- #
93
- # @param [Integer, String] project The ID or name of a project.
94
- # @param [Integer] id The ID of an issue.
95
- # @return [Gitlab::ObjectifiedHash] Information about reopened issue.
96
- def reopen_issue(project, id)
97
- put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'reopen' })
98
- end
77
+ # Closes an issue.
78
+ #
79
+ # @example
80
+ # Gitlab.close_issue(3, 42)
81
+ #
82
+ # @param [Integer, String] project The ID or name of a project.
83
+ # @param [Integer] id The ID of an issue.
84
+ # @return [Gitlab::ObjectifiedHash] Information about closed issue.
85
+ def close_issue(project, id)
86
+ put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'close' })
87
+ end
99
88
 
100
- # Subscribe to an issue.
101
- #
102
- # @example
103
- # Gitlab.subscribe_to_issue(3, 42)
104
- #
105
- # @param [Integer, String] project The ID or name of a project.
106
- # @param [Integer] id The ID of an issue.
107
- # @return [Gitlab::ObjectifiedHash] Information about subscribed issue.
108
- def subscribe_to_issue(project, id)
109
- post("/projects/#{url_encode project}/issues/#{id}/subscribe")
110
- end
89
+ # Reopens an issue.
90
+ #
91
+ # @example
92
+ # Gitlab.reopen_issue(3, 42)
93
+ #
94
+ # @param [Integer, String] project The ID or name of a project.
95
+ # @param [Integer] id The ID of an issue.
96
+ # @return [Gitlab::ObjectifiedHash] Information about reopened issue.
97
+ def reopen_issue(project, id)
98
+ put("/projects/#{url_encode project}/issues/#{id}", body: { state_event: 'reopen' })
99
+ end
111
100
 
112
- # Unsubscribe from an issue.
113
- #
114
- # @example
115
- # Gitlab.unsubscribe_from_issue(3, 42)
116
- #
117
- # @param [Integer, String] project The ID or name of a project.
118
- # @param [Integer] id The ID of an issue.
119
- # @return [Gitlab::ObjectifiedHash] Information about unsubscribed issue.
120
- def unsubscribe_from_issue(project, id)
121
- post("/projects/#{url_encode project}/issues/#{id}/unsubscribe")
122
- end
101
+ # Subscribe to an issue.
102
+ #
103
+ # @example
104
+ # Gitlab.subscribe_to_issue(3, 42)
105
+ #
106
+ # @param [Integer, String] project The ID or name of a project.
107
+ # @param [Integer] id The ID of an issue.
108
+ # @return [Gitlab::ObjectifiedHash] Information about subscribed issue.
109
+ def subscribe_to_issue(project, id)
110
+ post("/projects/#{url_encode project}/issues/#{id}/subscribe")
111
+ end
123
112
 
124
- # Deletes an issue.
125
- # Only for admins and project owners
126
- #
127
- # @example
128
- # Gitlab.delete_issue(3, 42)
129
- #
130
- # @param [Integer, String] project The ID or name of a project.
131
- # @param [Integer] id The ID of an issue.
132
- # @return [Gitlab::ObjectifiedHash] Information about deleted issue.
133
- def delete_issue(project, id)
134
- delete("/projects/#{url_encode project}/issues/#{id}")
135
- end
113
+ # Unsubscribe from an issue.
114
+ #
115
+ # @example
116
+ # Gitlab.unsubscribe_from_issue(3, 42)
117
+ #
118
+ # @param [Integer, String] project The ID or name of a project.
119
+ # @param [Integer] id The ID of an issue.
120
+ # @return [Gitlab::ObjectifiedHash] Information about unsubscribed issue.
121
+ def unsubscribe_from_issue(project, id)
122
+ post("/projects/#{url_encode project}/issues/#{id}/unsubscribe")
123
+ end
136
124
 
137
- # Move an issue.
138
- #
139
- # @example
140
- # Gitlab.move_issue(3, 42, { to_project_id: '4' })
141
- #
142
- # @param [Integer, String] project The ID or name of a project.
143
- # @param [Integer] id The ID of an issue.
144
- # @option options [String] :to_project_id The ID of the new project.
145
- # @return [Gitlab::ObjectifiedHash] Information about moved issue.
146
- def move_issue(project, id, options={})
147
- post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
148
- end
149
-
150
- # Sets an estimated time of work for an issue.
151
- #
152
- # @example
153
- # Gitlab.estimate_time_of_issue(3, 42, '3h30m')
154
- #
155
- # @param [Integer, String] project The ID or name of a project.
156
- # @param [Integer] id The ID of an issue.
157
- # @param [String] duration The duration in human format. e.g: 3h30m
158
- def estimate_time_of_issue(project, id, duration)
159
- post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
160
- end
161
-
162
- # Resets the estimated time for an issue to 0 seconds.
163
- #
164
- # @example
165
- # Gitlab.reset_time_estimate_of_issue(3, 42)
166
- #
167
- # @param [Integer, String] project The ID or name of a project.
168
- # @param [Integer] id The ID of an issue.
169
- def reset_time_estimate_of_issue(project, id)
170
- post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate")
171
- end
172
-
173
- # Adds spent time for an issue
174
- #
175
- # @example
176
- # Gitlab.estimate_time_of_issue(3, 42, '3h30m')
177
- #
178
- # @param [Integer, String] project The ID or name of a project.
179
- # @param [Integer] id The ID of an issue.
180
- # @param [String] duration The time spent in human format. e.g: 3h30m
181
- def add_time_spent_on_issue(project, id, duration)
182
- post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: url_encode(duration) })
183
- end
184
-
185
- # Resets the total spent time for this issue to 0 seconds.
186
- #
187
- # @example
188
- # Gitlab.reset_time_spent_on_issue(3, 42)
189
- #
190
- # @param [Integer, String] project The ID or name of a project.
191
- # @param [Integer] id The ID of an issue.
192
- def reset_time_spent_on_issue(project, id)
193
- post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
194
- end
195
-
196
- # Get time tracking stats for an issue
197
- #
198
- # @example
199
- # @gitlab.time_stats_for_issue(3, 42)
200
- #
201
- # @param [Integer, String] project The ID or name of a project.
202
- # @param [Integer] id The ID of an issue.
203
- def time_stats_for_issue(project, id)
204
- get("/projects/#{url_encode project}/issues/#{id}/time_stats")
205
- end
206
-
125
+ # Deletes an issue.
126
+ # Only for admins and project owners
127
+ #
128
+ # @example
129
+ # Gitlab.delete_issue(3, 42)
130
+ #
131
+ # @param [Integer, String] project The ID or name of a project.
132
+ # @param [Integer] id The ID of an issue.
133
+ # @return [Gitlab::ObjectifiedHash] Information about deleted issue.
134
+ def delete_issue(project, id)
135
+ delete("/projects/#{url_encode project}/issues/#{id}")
136
+ end
137
+
138
+ # Move an issue.
139
+ #
140
+ # @example
141
+ # Gitlab.move_issue(3, 42, { to_project_id: '4' })
142
+ #
143
+ # @param [Integer, String] project The ID or name of a project.
144
+ # @param [Integer] id The ID of an issue.
145
+ # @option options [String] :to_project_id The ID of the new project.
146
+ # @return [Gitlab::ObjectifiedHash] Information about moved issue.
147
+ def move_issue(project, id, options = {})
148
+ post("/projects/#{url_encode project}/issues/#{id}/move", body: options)
149
+ end
150
+
151
+ # Sets an estimated time of work for an issue.
152
+ #
153
+ # @example
154
+ # Gitlab.estimate_time_of_issue(3, 42, '3h30m')
155
+ #
156
+ # @param [Integer, String] project The ID or name of a project.
157
+ # @param [Integer] id The ID of an issue.
158
+ # @param [String] duration The duration in human format. e.g: 3h30m
159
+ def estimate_time_of_issue(project, id, duration)
160
+ post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) })
161
+ end
162
+
163
+ # Resets the estimated time for an issue to 0 seconds.
164
+ #
165
+ # @example
166
+ # Gitlab.reset_time_estimate_of_issue(3, 42)
167
+ #
168
+ # @param [Integer, String] project The ID or name of a project.
169
+ # @param [Integer] id The ID of an issue.
170
+ def reset_time_estimate_of_issue(project, id)
171
+ post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate")
172
+ end
173
+
174
+ # Adds spent time for an issue
175
+ #
176
+ # @example
177
+ # Gitlab.estimate_time_of_issue(3, 42, '3h30m')
178
+ #
179
+ # @param [Integer, String] project The ID or name of a project.
180
+ # @param [Integer] id The ID of an issue.
181
+ # @param [String] duration The time spent in human format. e.g: 3h30m
182
+ def add_time_spent_on_issue(project, id, duration)
183
+ post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: url_encode(duration) })
184
+ end
185
+
186
+ # Resets the total spent time for this issue to 0 seconds.
187
+ #
188
+ # @example
189
+ # Gitlab.reset_time_spent_on_issue(3, 42)
190
+ #
191
+ # @param [Integer, String] project The ID or name of a project.
192
+ # @param [Integer] id The ID of an issue.
193
+ def reset_time_spent_on_issue(project, id)
194
+ post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time")
195
+ end
196
+
197
+ # Get time tracking stats for an issue
198
+ #
199
+ # @example
200
+ # @gitlab.time_stats_for_issue(3, 42)
201
+ #
202
+ # @param [Integer, String] project The ID or name of a project.
203
+ # @param [Integer] id The ID of an issue.
204
+ def time_stats_for_issue(project, id)
205
+ get("/projects/#{url_encode project}/issues/#{id}/time_stats")
207
206
  end
208
207
  end