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,92 +1,92 @@
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, String] project The ID or name 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/#{url_encode project}/milestones", query: options)
17
- end
1
+ # frozen_string_literal: true
18
2
 
19
- # Gets a single milestone.
20
- #
21
- # @example
22
- # Gitlab.milestone(5, 36)
23
- #
24
- # @param [Integer, String] project The ID or name of a project.
25
- # @param [Integer] id The ID of a milestone.
26
- # @return [Gitlab::ObjectifiedHash]
27
- def milestone(project, id)
28
- get("/projects/#{url_encode project}/milestones/#{id}")
29
- end
3
+ # Defines methods related to milestones.
4
+ # @see https://docs.gitlab.com/ce/api/milestones.html
5
+ module Milestones
6
+ # Gets a list of project's milestones.
7
+ #
8
+ # @example
9
+ # Gitlab.milestones(5)
10
+ #
11
+ # @param [Integer, String] project The ID or name 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 milestones(project, options = {})
17
+ get("/projects/#{url_encode project}/milestones", query: options)
18
+ end
19
+
20
+ # Gets a single milestone.
21
+ #
22
+ # @example
23
+ # Gitlab.milestone(5, 36)
24
+ #
25
+ # @param [Integer, String] project The ID or name of a project.
26
+ # @param [Integer] id The ID of a milestone.
27
+ # @return [Gitlab::ObjectifiedHash]
28
+ def milestone(project, id)
29
+ get("/projects/#{url_encode project}/milestones/#{id}")
30
+ end
30
31
 
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 or name 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/#{url_encode project}/milestones/#{milestone}/issues", query: options)
43
- end
32
+ # Gets the issues of a given milestone.
33
+ #
34
+ # @example
35
+ # Gitlab.milestone_issues(5, 2)
36
+ #
37
+ # @param [Integer, String] project The ID or name of a project.
38
+ # @param [Integer, String] milestone The ID of a milestone.
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 milestone_issues(project, milestone, options = {})
43
+ get("/projects/#{url_encode project}/milestones/#{milestone}/issues", query: options)
44
+ end
44
45
 
45
- # Gets the merge_requests of a given milestone.
46
- #
47
- # @example
48
- # Gitlab.milestone_merge_requests(5, 2)
49
- #
50
- # @param [Integer, String] project The ID or name of a project.
51
- # @param [Integer, String] milestone The ID of a milestone.
52
- # @option options [Integer] :page The page number.
53
- # @option options [Integer] :per_page The number of results per page.
54
- # @return [Array<Gitlab::ObjectifiedHash>]
55
- def milestone_merge_requests(project, milestone, options={})
56
- get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options)
57
- end
46
+ # Gets the merge_requests of a given milestone.
47
+ #
48
+ # @example
49
+ # Gitlab.milestone_merge_requests(5, 2)
50
+ #
51
+ # @param [Integer, String] project The ID or name of a project.
52
+ # @param [Integer, String] milestone The ID of a milestone.
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 milestone_merge_requests(project, milestone, options = {})
57
+ get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options)
58
+ end
58
59
 
59
- # Creates a new milestone.
60
- #
61
- # @example
62
- # Gitlab.create_milestone(5, 'v1.0')
63
- #
64
- # @param [Integer, String] project The ID or name of a project.
65
- # @param [String] title The title of a milestone.
66
- # @param [Hash] options A customizable set of options.
67
- # @option options [String] :description The description of a milestone.
68
- # @option options [String] :due_date The due date of a milestone.
69
- # @return [Gitlab::ObjectifiedHash] Information about created milestone.
70
- def create_milestone(project, title, options={})
71
- body = { title: title }.merge(options)
72
- post("/projects/#{url_encode project}/milestones", body: body)
73
- end
60
+ # Creates a new milestone.
61
+ #
62
+ # @example
63
+ # Gitlab.create_milestone(5, 'v1.0')
64
+ #
65
+ # @param [Integer, String] project The ID or name of a project.
66
+ # @param [String] title The title of a milestone.
67
+ # @param [Hash] options A customizable set of options.
68
+ # @option options [String] :description The description of a milestone.
69
+ # @option options [String] :due_date The due date of a milestone.
70
+ # @return [Gitlab::ObjectifiedHash] Information about created milestone.
71
+ def create_milestone(project, title, options = {})
72
+ body = { title: title }.merge(options)
73
+ post("/projects/#{url_encode project}/milestones", body: body)
74
+ end
74
75
 
75
- # Updates a milestone.
76
- #
77
- # @example
78
- # Gitlab.edit_milestone(5, 2, { state_event: 'activate' })
79
- #
80
- # @param [Integer, String] project The ID or name of a project.
81
- # @param [Integer] id The ID of a milestone.
82
- # @param [Hash] options A customizable set of options.
83
- # @option options [String] :title The title of a milestone.
84
- # @option options [String] :description The description of a milestone.
85
- # @option options [String] :due_date The due date of a milestone.
86
- # @option options [String] :state_event The state of a milestone ('close' or 'activate').
87
- # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
88
- def edit_milestone(project, id, options={})
89
- put("/projects/#{url_encode project}/milestones/#{id}", body: options)
90
- end
76
+ # Updates a milestone.
77
+ #
78
+ # @example
79
+ # Gitlab.edit_milestone(5, 2, { state_event: 'activate' })
80
+ #
81
+ # @param [Integer, String] project The ID or name of a project.
82
+ # @param [Integer] id The ID of a milestone.
83
+ # @param [Hash] options A customizable set of options.
84
+ # @option options [String] :title The title of a milestone.
85
+ # @option options [String] :description The description of a milestone.
86
+ # @option options [String] :due_date The due date of a milestone.
87
+ # @option options [String] :state_event The state of a milestone ('close' or 'activate').
88
+ # @return [Gitlab::ObjectifiedHash] Information about updated milestone.
89
+ def edit_milestone(project, id, options = {})
90
+ put("/projects/#{url_encode project}/milestones/#{id}", body: options)
91
91
  end
92
92
  end
@@ -1,20 +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
1
+ # frozen_string_literal: true
2
+
3
+ # Defines methods related to namespaces
4
+ # @see https://docs.gitlab.com/ce/api/namespaces.html
5
+ module Namespaces
6
+ # Gets a list of namespaces.
7
+ # @see https://docs.gitlab.com/ce/api/namespaces.html#list-namespaces
8
+ #
9
+ # @example
10
+ # Gitlab.namespaces
11
+ #
12
+ # @param [Hash] options A customizable set of options.
13
+ # @options options [Integer] :page The page number.
14
+ # @options options [Integer] :per_page The number of results per page.
15
+ # @options opttion [String] :search The string to search for.
16
+ # @return [Array<Gitlab::ObjectifiedHash>]
17
+ def namespaces(options = {})
18
+ get('/namespaces', query: options)
19
19
  end
20
20
  end
@@ -1,284 +1,284 @@
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/#{url_encode project}/notes", query: options)
16
- end
1
+ # frozen_string_literal: true
17
2
 
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/#{url_encode project}/issues/#{issue}/notes", query: options)
30
- end
3
+ # Defines methods related to notes.
4
+ # @see https://docs.gitlab.com/ce/api/notes.html
5
+ module Notes
6
+ # Gets a list of projects notes.
7
+ #
8
+ # @example
9
+ # Gitlab.notes(5)
10
+ #
11
+ # @param [Integer] project The ID of a project.
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 notes(project, options = {})
16
+ get("/projects/#{url_encode project}/notes", query: options)
17
+ end
31
18
 
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/#{url_encode project}/snippets/#{snippet}/notes", query: options)
44
- end
19
+ # Gets a list of notes for a issue.
20
+ #
21
+ # @example
22
+ # Gitlab.issue_notes(5, 10)
23
+ #
24
+ # @param [Integer] project The ID of a project.
25
+ # @param [Integer] issue The ID of an issue.
26
+ # @option options [Integer] :page The page number.
27
+ # @option options [Integer] :per_page The number of results per page.
28
+ # @return [Array<Gitlab::ObjectifiedHash>]
29
+ def issue_notes(project, issue, options = {})
30
+ get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options)
31
+ end
45
32
 
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/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
58
- end
59
- alias_method :merge_request_comments, :merge_request_notes
33
+ # Gets a list of notes for a snippet.
34
+ #
35
+ # @example
36
+ # Gitlab.snippet_notes(5, 1)
37
+ #
38
+ # @param [Integer] project The ID of a project.
39
+ # @param [Integer] snippet The ID of a snippet.
40
+ # @option options [Integer] :page The page number.
41
+ # @option options [Integer] :per_page The number of results per page.
42
+ # @return [Array<Gitlab::ObjectifiedHash>]
43
+ def snippet_notes(project, snippet, options = {})
44
+ get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options)
45
+ end
60
46
 
61
- # Gets a single wall note.
62
- #
63
- # @example
64
- # Gitlab.note(5, 15)
65
- #
66
- # @param [Integer] project The ID of a project.
67
- # @param [Integer] id The ID of a note.
68
- # @return [Gitlab::ObjectifiedHash]
69
- def note(project, id)
70
- get("/projects/#{url_encode project}/notes/#{id}")
71
- end
47
+ # Gets a list of notes for a merge request.
48
+ #
49
+ # @example
50
+ # Gitlab.merge_request_notes(5, 1)
51
+ #
52
+ # @param [Integer] project The ID of a project.
53
+ # @param [Integer] merge_request The ID of a merge request.
54
+ # @option options [Integer] :page The page number.
55
+ # @option options [Integer] :per_page The number of results per page.
56
+ # @return [Array<Gitlab::ObjectifiedHash>]
57
+ def merge_request_notes(project, merge_request, options = {})
58
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
59
+ end
60
+ alias merge_request_comments merge_request_notes
72
61
 
73
- # Gets a single issue note.
74
- #
75
- # @example
76
- # Gitlab.issue_note(5, 10, 1)
77
- #
78
- # @param [Integer] project The ID of a project.
79
- # @param [Integer] issue The ID of an issue.
80
- # @param [Integer] id The ID of a note.
81
- # @return [Gitlab::ObjectifiedHash]
82
- def issue_note(project, issue, id)
83
- get("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
84
- end
62
+ # Gets a single wall note.
63
+ #
64
+ # @example
65
+ # Gitlab.note(5, 15)
66
+ #
67
+ # @param [Integer] project The ID of a project.
68
+ # @param [Integer] id The ID of a note.
69
+ # @return [Gitlab::ObjectifiedHash]
70
+ def note(project, id)
71
+ get("/projects/#{url_encode project}/notes/#{id}")
72
+ end
85
73
 
86
- # Gets a single snippet note.
87
- #
88
- # @example
89
- # Gitlab.snippet_note(5, 11, 3)
90
- #
91
- # @param [Integer] project The ID of a project.
92
- # @param [Integer] snippet The ID of a snippet.
93
- # @param [Integer] id The ID of a note.
94
- # @return [Gitlab::ObjectifiedHash]
95
- def snippet_note(project, snippet, id)
96
- get("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
97
- end
74
+ # Gets a single issue note.
75
+ #
76
+ # @example
77
+ # Gitlab.issue_note(5, 10, 1)
78
+ #
79
+ # @param [Integer] project The ID of a project.
80
+ # @param [Integer] issue The ID of an issue.
81
+ # @param [Integer] id The ID of a note.
82
+ # @return [Gitlab::ObjectifiedHash]
83
+ def issue_note(project, issue, id)
84
+ get("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
85
+ end
98
86
 
99
- # Gets a single merge_request note.
100
- #
101
- # @example
102
- # Gitlab.merge_request_note(5, 11, 3)
103
- #
104
- # @param [Integer] project The ID of a project.
105
- # @param [Integer] merge_request The ID of a merge_request.
106
- # @param [Integer] id The ID of a note.
107
- # @return [Gitlab::ObjectifiedHash]
108
- def merge_request_note(project, merge_request, id)
109
- get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
110
- end
87
+ # Gets a single snippet note.
88
+ #
89
+ # @example
90
+ # Gitlab.snippet_note(5, 11, 3)
91
+ #
92
+ # @param [Integer] project The ID of a project.
93
+ # @param [Integer] snippet The ID of a snippet.
94
+ # @param [Integer] id The ID of a note.
95
+ # @return [Gitlab::ObjectifiedHash]
96
+ def snippet_note(project, snippet, id)
97
+ get("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
98
+ end
111
99
 
112
- # Creates a new wall note.
113
- #
114
- # @example
115
- # Gitlab.create_note(5, 'This is a wall note!')
116
- #
117
- # @param [Integer, String] project The ID or name of a project.
118
- # @param [String] body The body of a note.
119
- # @return [Gitlab::ObjectifiedHash] Information about created note.
120
- def create_note(project, body)
121
- post("/projects/#{url_encode project}/notes", body: { body: body })
122
- end
100
+ # Gets a single merge_request note.
101
+ #
102
+ # @example
103
+ # Gitlab.merge_request_note(5, 11, 3)
104
+ #
105
+ # @param [Integer] project The ID of a project.
106
+ # @param [Integer] merge_request The ID of a merge_request.
107
+ # @param [Integer] id The ID of a note.
108
+ # @return [Gitlab::ObjectifiedHash]
109
+ def merge_request_note(project, merge_request, id)
110
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
111
+ end
123
112
 
124
- # Creates a new issue note.
125
- #
126
- # @example
127
- # Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
128
- #
129
- # @param [Integer, String] project The ID or name of a project.
130
- # @param [Integer] issue The ID of an issue.
131
- # @param [String] body The body of a note.
132
- # @return [Gitlab::ObjectifiedHash] Information about created note.
133
- def create_issue_note(project, issue, body)
134
- post("/projects/#{url_encode project}/issues/#{issue}/notes", body: { body: body })
135
- end
113
+ # Creates a new wall note.
114
+ #
115
+ # @example
116
+ # Gitlab.create_note(5, 'This is a wall note!')
117
+ #
118
+ # @param [Integer, String] project The ID or name of a project.
119
+ # @param [String] body The body of a note.
120
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
121
+ def create_note(project, body)
122
+ post("/projects/#{url_encode project}/notes", body: { body: body })
123
+ end
136
124
 
137
- # Creates a new snippet note.
138
- #
139
- # @example
140
- # Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
141
- #
142
- # @param [Integer, String] project The ID or name of a project.
143
- # @param [Integer] snippet The ID of a snippet.
144
- # @param [String] body The body of a note.
145
- # @return [Gitlab::ObjectifiedHash] Information about created note.
146
- def create_snippet_note(project, snippet, body)
147
- post("/projects/#{url_encode project}/snippets/#{snippet}/notes", body: { body: body })
148
- end
125
+ # Creates a new issue note.
126
+ #
127
+ # @example
128
+ # Gitlab.create_issue_note(6, 1, 'Adding a note to my issue.')
129
+ #
130
+ # @param [Integer, String] project The ID or name of a project.
131
+ # @param [Integer] issue The ID of an issue.
132
+ # @param [String] body The body of a note.
133
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
134
+ def create_issue_note(project, issue, body)
135
+ post("/projects/#{url_encode project}/issues/#{issue}/notes", body: { body: body })
136
+ end
149
137
 
150
- # Creates a new note for a single merge request.
151
- #
152
- # @example
153
- # Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
154
- #
155
- # @param [Integer] project The ID of a project.
156
- # @param [Integer] merge_request The ID of a merge request.
157
- # @param [String] body The content of a note.
158
- def create_merge_request_note(project, merge_request, body)
159
- post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
160
- end
161
- alias_method :create_merge_request_comment, :create_merge_request_note
138
+ # Creates a new snippet note.
139
+ #
140
+ # @example
141
+ # Gitlab.create_snippet_note(3, 2, 'Look at this awesome snippet!')
142
+ #
143
+ # @param [Integer, String] project The ID or name of a project.
144
+ # @param [Integer] snippet The ID of a snippet.
145
+ # @param [String] body The body of a note.
146
+ # @return [Gitlab::ObjectifiedHash] Information about created note.
147
+ def create_snippet_note(project, snippet, body)
148
+ post("/projects/#{url_encode project}/snippets/#{snippet}/notes", body: { body: body })
149
+ end
162
150
 
163
- # Deletes a wall note.
164
- #
165
- # @example
166
- # Gitlab.delete_note(5, 15)
167
- #
168
- # @param [Integer] project The ID of a project.
169
- # @param [Integer] id The ID of a note.
170
- # @return [Gitlab::ObjectifiedHash]
171
- def delete_note(project, id)
172
- delete("/projects/#{url_encode project}/notes/#{id}")
173
- end
151
+ # Creates a new note for a single merge request.
152
+ #
153
+ # @example
154
+ # Gitlab.create_merge_request_note(5, 3, 'This MR is ready for review.')
155
+ #
156
+ # @param [Integer] project The ID of a project.
157
+ # @param [Integer] merge_request The ID of a merge request.
158
+ # @param [String] body The content of a note.
159
+ def create_merge_request_note(project, merge_request, body)
160
+ post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
161
+ end
162
+ alias create_merge_request_comment create_merge_request_note
174
163
 
175
- # Deletes an issue note.
176
- #
177
- # @example
178
- # Gitlab.delete_issue_note(5, 10, 1)
179
- #
180
- # @param [Integer] project The ID of a project.
181
- # @param [Integer] issue The ID of an issue.
182
- # @param [Integer] id The ID of a note.
183
- # @return [Gitlab::ObjectifiedHash]
184
- def delete_issue_note(project, issue, id)
185
- delete("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
186
- end
164
+ # Deletes a wall note.
165
+ #
166
+ # @example
167
+ # Gitlab.delete_note(5, 15)
168
+ #
169
+ # @param [Integer] project The ID of a project.
170
+ # @param [Integer] id The ID of a note.
171
+ # @return [Gitlab::ObjectifiedHash]
172
+ def delete_note(project, id)
173
+ delete("/projects/#{url_encode project}/notes/#{id}")
174
+ end
187
175
 
188
- # Deletes a snippet note.
189
- #
190
- # @example
191
- # Gitlab.delete_snippet_note(5, 11, 3)
192
- #
193
- # @param [Integer] project The ID of a project.
194
- # @param [Integer] snippet The ID of a snippet.
195
- # @param [Integer] id The ID of a note.
196
- # @return [Gitlab::ObjectifiedHash]
197
- def delete_snippet_note(project, snippet, id)
198
- delete("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
199
- end
176
+ # Deletes an issue note.
177
+ #
178
+ # @example
179
+ # Gitlab.delete_issue_note(5, 10, 1)
180
+ #
181
+ # @param [Integer] project The ID of a project.
182
+ # @param [Integer] issue The ID of an issue.
183
+ # @param [Integer] id The ID of a note.
184
+ # @return [Gitlab::ObjectifiedHash]
185
+ def delete_issue_note(project, issue, id)
186
+ delete("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}")
187
+ end
200
188
 
201
- # Deletes a merge_request note.
202
- #
203
- # @example
204
- # Gitlab.delete_merge_request_note(5, 11, 3)
205
- #
206
- # @param [Integer] project The ID of a project.
207
- # @param [Integer] merge_request The ID of a merge_request.
208
- # @param [Integer] id The ID of a note.
209
- # @return [Gitlab::ObjectifiedHash]
210
- def delete_merge_request_note(project, merge_request, id)
211
- delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
212
- end
213
- alias_method :delete_merge_request_comment, :delete_merge_request_note
189
+ # Deletes a snippet note.
190
+ #
191
+ # @example
192
+ # Gitlab.delete_snippet_note(5, 11, 3)
193
+ #
194
+ # @param [Integer] project The ID of a project.
195
+ # @param [Integer] snippet The ID of a snippet.
196
+ # @param [Integer] id The ID of a note.
197
+ # @return [Gitlab::ObjectifiedHash]
198
+ def delete_snippet_note(project, snippet, id)
199
+ delete("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}")
200
+ end
214
201
 
215
- # Modifies a wall note.
216
- #
217
- # @example
218
- # Gitlab.edit_note(5, 15, 'This is an edited note')
219
- #
220
- # @param [Integer] project The ID of a project.
221
- # @param [Integer] id The ID of a note.
222
- # @param [String] body The content of a note.
223
- # @return [Gitlab::ObjectifiedHash]
224
- def edit_note(project, id, body)
225
- put("/projects/#{url_encode project}/notes/#{id}", body: note_content(body))
226
- end
202
+ # Deletes a merge_request note.
203
+ #
204
+ # @example
205
+ # Gitlab.delete_merge_request_note(5, 11, 3)
206
+ #
207
+ # @param [Integer] project The ID of a project.
208
+ # @param [Integer] merge_request The ID of a merge_request.
209
+ # @param [Integer] id The ID of a note.
210
+ # @return [Gitlab::ObjectifiedHash]
211
+ def delete_merge_request_note(project, merge_request, id)
212
+ delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}")
213
+ end
214
+ alias delete_merge_request_comment delete_merge_request_note
227
215
 
228
- # Modifies an issue note.
229
- #
230
- # @example
231
- # Gitlab.edit_issue_note(5, 10, 1, 'This is an edited issue note')
232
- #
233
- # @param [Integer] project The ID of a project.
234
- # @param [Integer] issue The ID of an issue.
235
- # @param [Integer] id The ID of a note.
236
- # @param [String] body The content of a note.
237
- # @return [Gitlab::ObjectifiedHash]
238
- def edit_issue_note(project, issue, id, body)
239
- put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: note_content(body))
240
- end
216
+ # Modifies a wall note.
217
+ #
218
+ # @example
219
+ # Gitlab.edit_note(5, 15, 'This is an edited note')
220
+ #
221
+ # @param [Integer] project The ID of a project.
222
+ # @param [Integer] id The ID of a note.
223
+ # @param [String] body The content of a note.
224
+ # @return [Gitlab::ObjectifiedHash]
225
+ def edit_note(project, id, body)
226
+ put("/projects/#{url_encode project}/notes/#{id}", body: note_content(body))
227
+ end
241
228
 
242
- # Modifies a snippet note.
243
- #
244
- # @example
245
- # Gitlab.edit_snippet_note(5, 11, 3, 'This is an edited snippet note')
246
- #
247
- # @param [Integer] project The ID of a project.
248
- # @param [Integer] snippet The ID of a snippet.
249
- # @param [Integer] id The ID of a note.
250
- # @param [String] body The content of a note.
251
- # @return [Gitlab::ObjectifiedHash]
252
- def edit_snippet_note(project, snippet, id, body)
253
- put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: note_content(body))
254
- end
229
+ # Modifies an issue note.
230
+ #
231
+ # @example
232
+ # Gitlab.edit_issue_note(5, 10, 1, 'This is an edited issue note')
233
+ #
234
+ # @param [Integer] project The ID of a project.
235
+ # @param [Integer] issue The ID of an issue.
236
+ # @param [Integer] id The ID of a note.
237
+ # @param [String] body The content of a note.
238
+ # @return [Gitlab::ObjectifiedHash]
239
+ def edit_issue_note(project, issue, id, body)
240
+ put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: note_content(body))
241
+ end
255
242
 
256
- # Modifies a merge_request note.
257
- #
258
- # @example
259
- # Gitlab.edit_merge_request_note(5, 11, 3, 'This is an edited merge request note')
260
- #
261
- # @param [Integer] project The ID of a project.
262
- # @param [Integer] merge_request The ID of a merge_request.
263
- # @param [Integer] id The ID of a note.
264
- # @param [String] body The content of a note.
265
- # @return [Gitlab::ObjectifiedHash]
266
- def edit_merge_request_note(project, merge_request, id, body)
267
- put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: note_content(body))
268
- end
269
- alias_method :edit_merge_request_comment, :edit_merge_request_note
243
+ # Modifies a snippet note.
244
+ #
245
+ # @example
246
+ # Gitlab.edit_snippet_note(5, 11, 3, 'This is an edited snippet note')
247
+ #
248
+ # @param [Integer] project The ID of a project.
249
+ # @param [Integer] snippet The ID of a snippet.
250
+ # @param [Integer] id The ID of a note.
251
+ # @param [String] body The content of a note.
252
+ # @return [Gitlab::ObjectifiedHash]
253
+ def edit_snippet_note(project, snippet, id, body)
254
+ put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: note_content(body))
255
+ end
256
+
257
+ # Modifies a merge_request note.
258
+ #
259
+ # @example
260
+ # Gitlab.edit_merge_request_note(5, 11, 3, 'This is an edited merge request note')
261
+ #
262
+ # @param [Integer] project The ID of a project.
263
+ # @param [Integer] merge_request The ID of a merge_request.
264
+ # @param [Integer] id The ID of a note.
265
+ # @param [String] body The content of a note.
266
+ # @return [Gitlab::ObjectifiedHash]
267
+ def edit_merge_request_note(project, merge_request, id, body)
268
+ put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: note_content(body))
269
+ end
270
+ alias edit_merge_request_comment edit_merge_request_note
270
271
 
271
- private
272
+ private
272
273
 
273
- # TODO: Remove this method after a couple deprecation cycles. Replace calls with the code
274
- # in the 'else'.
275
- def note_content(body)
276
- if body.is_a?(Hash)
277
- STDERR.puts "Passing the note body as a Hash is deprecated. You should just pass the String."
278
- body
279
- else
280
- { body: body }
281
- end
274
+ # TODO: Remove this method after a couple deprecation cycles. Replace calls with the code
275
+ # in the 'else'.
276
+ def note_content(body)
277
+ if body.is_a?(Hash)
278
+ STDERR.puts 'Passing the note body as a Hash is deprecated. You should just pass the String.'
279
+ body
280
+ else
281
+ { body: body }
282
282
  end
283
283
  end
284
284
  end