gitlab-faraday 5.1.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 (79) hide show
  1. checksums.yaml +7 -0
  2. data/lib/gitlab/api.rb +16 -0
  3. data/lib/gitlab/client/access_requests.rb +103 -0
  4. data/lib/gitlab/client/application_settings.rb +172 -0
  5. data/lib/gitlab/client/avatar.rb +21 -0
  6. data/lib/gitlab/client/award_emojis.rb +137 -0
  7. data/lib/gitlab/client/boards.rb +146 -0
  8. data/lib/gitlab/client/branches.rb +135 -0
  9. data/lib/gitlab/client/broadcast_messages.rb +75 -0
  10. data/lib/gitlab/client/build_variables.rb +135 -0
  11. data/lib/gitlab/client/builds.rb +108 -0
  12. data/lib/gitlab/client/commits.rb +216 -0
  13. data/lib/gitlab/client/container_registry.rb +90 -0
  14. data/lib/gitlab/client/deployments.rb +34 -0
  15. data/lib/gitlab/client/environments.rb +89 -0
  16. data/lib/gitlab/client/epic_issues.rb +23 -0
  17. data/lib/gitlab/client/epics.rb +73 -0
  18. data/lib/gitlab/client/events.rb +60 -0
  19. data/lib/gitlab/client/features.rb +48 -0
  20. data/lib/gitlab/client/group_badges.rb +88 -0
  21. data/lib/gitlab/client/group_boards.rb +141 -0
  22. data/lib/gitlab/client/group_labels.rb +88 -0
  23. data/lib/gitlab/client/group_milestones.rb +94 -0
  24. data/lib/gitlab/client/groups.rb +526 -0
  25. data/lib/gitlab/client/issue_links.rb +48 -0
  26. data/lib/gitlab/client/issues.rb +242 -0
  27. data/lib/gitlab/client/jobs.rb +250 -0
  28. data/lib/gitlab/client/keys.rb +29 -0
  29. data/lib/gitlab/client/labels.rb +88 -0
  30. data/lib/gitlab/client/lint.rb +19 -0
  31. data/lib/gitlab/client/markdown.rb +23 -0
  32. data/lib/gitlab/client/merge_request_approvals.rb +265 -0
  33. data/lib/gitlab/client/merge_requests.rb +415 -0
  34. data/lib/gitlab/client/merge_trains.rb +55 -0
  35. data/lib/gitlab/client/milestones.rb +106 -0
  36. data/lib/gitlab/client/namespaces.rb +22 -0
  37. data/lib/gitlab/client/notes.rb +313 -0
  38. data/lib/gitlab/client/packages.rb +95 -0
  39. data/lib/gitlab/client/pipeline_schedules.rb +159 -0
  40. data/lib/gitlab/client/pipeline_triggers.rb +103 -0
  41. data/lib/gitlab/client/pipelines.rb +130 -0
  42. data/lib/gitlab/client/project_badges.rb +85 -0
  43. data/lib/gitlab/client/project_clusters.rb +83 -0
  44. data/lib/gitlab/client/project_exports.rb +54 -0
  45. data/lib/gitlab/client/project_release_links.rb +76 -0
  46. data/lib/gitlab/client/project_releases.rb +90 -0
  47. data/lib/gitlab/client/projects.rb +792 -0
  48. data/lib/gitlab/client/protected_tags.rb +59 -0
  49. data/lib/gitlab/client/remote_mirrors.rb +90 -0
  50. data/lib/gitlab/client/repositories.rb +130 -0
  51. data/lib/gitlab/client/repository_files.rb +131 -0
  52. data/lib/gitlab/client/repository_submodules.rb +27 -0
  53. data/lib/gitlab/client/resource_label_events.rb +82 -0
  54. data/lib/gitlab/client/resource_state_events.rb +57 -0
  55. data/lib/gitlab/client/runners.rb +278 -0
  56. data/lib/gitlab/client/search.rb +66 -0
  57. data/lib/gitlab/client/services.rb +53 -0
  58. data/lib/gitlab/client/sidekiq.rb +39 -0
  59. data/lib/gitlab/client/snippets.rb +95 -0
  60. data/lib/gitlab/client/system_hooks.rb +64 -0
  61. data/lib/gitlab/client/tags.rb +97 -0
  62. data/lib/gitlab/client/templates.rb +100 -0
  63. data/lib/gitlab/client/todos.rb +46 -0
  64. data/lib/gitlab/client/user_snippets.rb +114 -0
  65. data/lib/gitlab/client/users.rb +521 -0
  66. data/lib/gitlab/client/versions.rb +18 -0
  67. data/lib/gitlab/client/wikis.rb +79 -0
  68. data/lib/gitlab/client.rb +96 -0
  69. data/lib/gitlab/configuration.rb +36 -0
  70. data/lib/gitlab/error.rb +114 -0
  71. data/lib/gitlab/file_response.rb +43 -0
  72. data/lib/gitlab/headers/page_links.rb +32 -0
  73. data/lib/gitlab/headers/total.rb +24 -0
  74. data/lib/gitlab/objectified_hash.rb +44 -0
  75. data/lib/gitlab/paginated_response.rb +114 -0
  76. data/lib/gitlab/request.rb +144 -0
  77. data/lib/gitlab/version.rb +5 -0
  78. data/lib/gitlab.rb +36 -0
  79. metadata +156 -0
@@ -0,0 +1,242 @@
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
+
231
+ # List related merge requests
232
+ #
233
+ # @example
234
+ # Gitlab.related_merge_requests(3, 42)
235
+ #
236
+ # @param [Integer, String] project The ID or name of a project.
237
+ # @param [Integer] id The ID of an issue.
238
+ def related_merge_requests(project, id)
239
+ get("/projects/#{url_encode project}/issues/#{id}/related_merge_requests")
240
+ end
241
+ end
242
+ end
@@ -0,0 +1,250 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to projects.
5
+ # @see https://docs.gitlab.com/ee/api/jobs.html
6
+ module Jobs
7
+ # Gets a list of Jobs for a Project
8
+ #
9
+ # @example
10
+ # Gitlab.jobs(1)
11
+ # Gitlab.jobs("project")
12
+ # Gitlab.jobs("project", {scope: ["manual", "success"], per_page: 100 })
13
+ #
14
+ # @param [Integer, String] id The ID or name of a project.
15
+ # @param [Hash] options A customizable set of options.
16
+ # @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.
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 jobs(project_id, options = {})
21
+ get("/projects/#{url_encode project_id}/jobs", query: options)
22
+ end
23
+
24
+ # Gets a list of Jobs from a pipeline
25
+ #
26
+ # @example
27
+ # Gitlab.pipeline_jobs(1, 2)
28
+ # Gitlab.pipeline_jobs("project", 2)
29
+ #
30
+ # @param [Integer, String] The ID or name of a project.
31
+ # @param [Integer] the id of the pipeline
32
+ # @param [Hash] options A customizable set of options.
33
+ # @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.
34
+ # @return [Array<Gitlab::ObjectifiedHash>]
35
+ def pipeline_jobs(project_id, pipeline_id, options = {})
36
+ get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
37
+ end
38
+
39
+ # Gets a list of Bridge Jobs from a pipeline
40
+ #
41
+ # @example
42
+ # Gitlab.pipeline_bridges(1, 2)
43
+ # Gitlab.pipeline_bridges("project", 2)
44
+ #
45
+ # @param [Integer, String] The ID or name of a project.
46
+ # @param [Integer] the id of the pipeline
47
+ # @param [Hash] options A customizable set of options.
48
+ # @option options [Array] :scope The scope of bridge jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all bridge jobs if none provided.
49
+ # @return [Array<Gitlab::ObjectifiedHash>]
50
+ def pipeline_bridges(project_id, pipeline_id, options = {})
51
+ get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/bridges", query: options)
52
+ end
53
+
54
+ # Gets a single job
55
+ #
56
+ # @example
57
+ # Gitlab.job(1, 2)
58
+ # Gitlab.job("project", 2)
59
+ #
60
+ # @param [Integer, String] The ID or name of a project.
61
+ # @param [Integer] the id of the job
62
+ def job(project_id, job_id)
63
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}")
64
+ end
65
+
66
+ # Gets artifacts from a job
67
+ #
68
+ # @example
69
+ # Gitlab.job_artifacts(1, 2)
70
+ # Gitlab.job_artifacts("project", 2)
71
+ #
72
+ # @param [Integer, String] The ID or name of a project.
73
+ # @param [Integer] the id of the job
74
+ # @return [Array<Gitlab::ObjectifiedHash>]
75
+ def job_artifacts(project_id, job_id)
76
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts",
77
+ format: nil,
78
+ headers: { Accept: 'text/plain' },
79
+ parser: ::Gitlab::Request::Parser)
80
+ end
81
+
82
+ # Download Job Artifact
83
+ #
84
+ # @example
85
+ # Gitlab.job_artifacts_download(1, "master", "release")
86
+ # Gitlab.job_artifacts_download("project", "master", "release")
87
+ #
88
+ # @param [Integer, String] project_id The ID or name of a project.
89
+ # @param [String] ref Ref Name
90
+ # @param [String] job jobname
91
+ # @return [Gitlab::FileResponse]
92
+ def job_artifacts_download(project_id, ref_name, job_name)
93
+ get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
94
+ query: { job: job_name },
95
+ format: nil,
96
+ headers: { Accept: 'application/octet-stream' },
97
+ parser: proc { |body, _|
98
+ if body.encoding == Encoding::ASCII_8BIT # binary response
99
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
100
+ else # error with json response
101
+ ::Gitlab::Request.parse(body)
102
+ end
103
+ })
104
+ end
105
+
106
+ # Download a single artifact file by job ID
107
+ #
108
+ # @example
109
+ # Gitlab.download_job_artifact_file(1, 5, "some/release/file.pdf")
110
+ #
111
+ # @param [Integer, String] project_id(required) The ID or name of a project.
112
+ # @param [String] job_id(required) The unique job identifier.
113
+ # @param [String] artifact_path(required) Path to a file inside the artifacts archive.
114
+ # @return [Gitlab::FileResponse]
115
+ def download_job_artifact_file(project_id, job_id, artifact_path)
116
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/#{artifact_path}",
117
+ format: nil,
118
+ headers: { Accept: 'application/octet-stream' },
119
+ parser: proc { |body, _|
120
+ if body.encoding == Encoding::ASCII_8BIT # binary response
121
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
122
+ else # error with json response
123
+ ::Gitlab::Request.parse(body)
124
+ end
125
+ })
126
+ end
127
+
128
+ # Download a single artifact file from specific tag or branch
129
+ #
130
+ # @example
131
+ # Gitlab.download_branch_artifact_file(1, "master", "some/release/file.pdf", 'pdf')
132
+ #
133
+ # @param [Integer, String] project_id(required) The ID or name of a project.
134
+ # @param [String] ref_name(required) Branch or tag name in repository. HEAD or SHA references are not supported.
135
+ # @param [String] artifact_path(required) Path to a file inside the artifacts archive.
136
+ # @param [String] job(required) The name of the job.
137
+ # @return [Gitlab::FileResponse]
138
+ def download_branch_artifact_file(project_id, ref_name, artifact_path, job)
139
+ get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/raw/#{artifact_path}",
140
+ query: { job: job },
141
+ format: nil,
142
+ headers: { Accept: 'application/octet-stream' },
143
+ parser: proc { |body, _|
144
+ if body.encoding == Encoding::ASCII_8BIT # binary response
145
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
146
+ else # error with json response
147
+ ::Gitlab::Request.parse(body)
148
+ end
149
+ })
150
+ end
151
+ alias download_tag_artifact_file download_branch_artifact_file
152
+
153
+ # Get Job Trace
154
+ #
155
+ # @example
156
+ # Gitlab.job_trace(1,1)
157
+ # Gitlab.job_trace("project", 1)
158
+ #
159
+ # @param [Integer, String] The ID or name of a project.
160
+ # @param [Integer] the id of the job
161
+ # @return [Array<Gitlab::ObjectifiedHash>]
162
+ def job_trace(project_id, job_id)
163
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}/trace",
164
+ format: nil,
165
+ headers: { Accept: 'text/plain' },
166
+ parser: ::Gitlab::Request::Parser)
167
+ end
168
+
169
+ # Cancel a job
170
+ #
171
+ # @example
172
+ # Gitlab.job_cancel(1,1)
173
+ # Gitlab.job_cancel("project", 1)
174
+ #
175
+ # @param [Integer, String] The ID or name of a project.
176
+ # @param [Integer] the id of the job
177
+ # @return [Array<Gitlab::ObjectifiedHash>]
178
+ def job_cancel(project_id, job_id)
179
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/cancel")
180
+ end
181
+
182
+ # Retry a job
183
+ #
184
+ # @example
185
+ # Gitlab.job_retry(1,1)
186
+ # Gitlab.job_retry("project", 1)
187
+ #
188
+ # @param [Integer, String] The ID or name of a project.
189
+ # @param [Integer] the id of the job
190
+ # @return [Array<Gitlab::ObjectifiedHash>]
191
+ def job_retry(project_id, job_id)
192
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/retry")
193
+ end
194
+
195
+ # Erase Job
196
+ #
197
+ # @example
198
+ # Gitlab.job_erase(1,1)
199
+ # Gitlab.job_erase("project", 1)
200
+ #
201
+ # @param [Integer, String] The ID or name of a project.
202
+ # @param [Integer] the id of the job
203
+ # @return [Array<Gitlab::ObjectifiedHash>]
204
+ def job_erase(project_id, job_id)
205
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/erase")
206
+ end
207
+
208
+ # Play a Job
209
+ # Triggers a manual action to start a job.
210
+ #
211
+ # @example
212
+ # Gitlab.job_play(1,1)
213
+ # Gitlab.job_play("project", 1)
214
+ #
215
+ # @param [Integer, String] The ID or name of a project.
216
+ # @param [Integer] the id of the job
217
+ # @return [Array<Gitlab::ObjectifiedHash>]
218
+ def job_play(project_id, job_id)
219
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/play")
220
+ end
221
+
222
+ # Keep Artifacts
223
+ # Prevents artifacts from being deleted when expiration is set.
224
+ #
225
+ # @example
226
+ # Gitlab.job_artifacts_keep(1,1)
227
+ # Gitlab.job_artifacts_keep("project", 1)
228
+ #
229
+ # @param [Integer, String] The ID or name of a project.
230
+ # @param [Integer] the id of the job
231
+ # @return [Array<Gitlab::ObjectifiedHash>]
232
+ def job_artifacts_keep(project_id, job_id)
233
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep")
234
+ end
235
+
236
+ # Delete Artifacts
237
+ # Deletes the artifacts associated with a job.
238
+ #
239
+ # @example
240
+ # Gitlab.job_artifacts_delete(1,1)
241
+ # Gitlab.job_artifacts_delete("project", 1)
242
+ #
243
+ # @param [Integer, String] The ID or name of a project.
244
+ # @param [Integer] the id of the job
245
+ # @return [Array<Gitlab::ObjectifiedHash>]
246
+ def job_artifacts_delete(project_id, job_id)
247
+ delete("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts")
248
+ end
249
+ end
250
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to keys.
5
+ # @see https://docs.gitlab.com/ce/api/keys.html
6
+ module Keys
7
+ # Gets information about a key.
8
+ #
9
+ # @example
10
+ # Gitlab.key(1)
11
+ #
12
+ # @param [Integer] id The ID of a key.
13
+ # @return [Gitlab::ObjectifiedHash]
14
+ def key(id)
15
+ get("/keys/#{id}")
16
+ end
17
+
18
+ # Gets information about a key by key fingerprint.
19
+ #
20
+ # @example
21
+ # Gitlab.key_by_fingerprint("9f:70:33:b3:50:4d:9a:a3:ef:ea:13:9b:87:0f:7f:7e")
22
+ #
23
+ # @param [String] fingerprint The Fingerprint of a key.
24
+ # @return [Gitlab::ObjectifiedHash]
25
+ def key_by_fingerprint(fingerprint)
26
+ get('/keys', query: { fingerprint: fingerprint })
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to project labels.
5
+ # @see https://docs.gitlab.com/ce/api/labels.html
6
+ module Labels
7
+ # Gets a list of project's labels.
8
+ #
9
+ # @example
10
+ # Gitlab.labels(5)
11
+ #
12
+ # @param [Integer, String] project The ID or name of a project.
13
+ # @return [Array<Gitlab::ObjectifiedHash>]
14
+ def labels(project, options = {})
15
+ get("/projects/#{url_encode project}/labels", query: options)
16
+ end
17
+
18
+ # Creates a new label.
19
+ #
20
+ # @example
21
+ # Gitlab.create_label(42, "Backlog", '#DD10AA')
22
+ #
23
+ # @param [Integer, String] project The ID or name of a project.
24
+ # @param [String] name The name of a label.
25
+ # @param [String] color The color of a label.
26
+ # @param [Hash] options A customizable set of options.
27
+ # @option options [String] :description The description of the label.
28
+ # @option options [String] :priority The priority of the label. Must be greater or equal than zero or null to remove the priority.
29
+ # @return [Gitlab::ObjectifiedHash] Information about created label.
30
+ def create_label(project, name, color, options = {})
31
+ post("/projects/#{url_encode project}/labels", body: options.merge(name: name, color: color))
32
+ end
33
+
34
+ # Updates a label.
35
+ #
36
+ # @example
37
+ # Gitlab.edit_label(42, "Backlog", { new_name: 'TODO' })
38
+ # Gitlab.edit_label(42, "Backlog", { new_name: 'TODO', color: '#DD10AA' })
39
+ #
40
+ # @param [Integer, String] project The ID or name of a project.
41
+ # @param [String] name The name of a label.
42
+ # @param [Hash] options A customizable set of options.
43
+ # @option options [String] :new_name The new name of a label.
44
+ # @option options [String] :color The color of a label.
45
+ # @option options [String] :description The description of the label.
46
+ # @option options [String] :priority The priority of the label. Must be greater or equal than zero or null to remove the priority.
47
+ # @return [Gitlab::ObjectifiedHash] Information about updated label.
48
+ def edit_label(project, name, options = {})
49
+ put("/projects/#{url_encode project}/labels", body: options.merge(name: name))
50
+ end
51
+
52
+ # Deletes a label.
53
+ #
54
+ # @example
55
+ # Gitlab.delete_label(2, 'Backlog')
56
+ #
57
+ # @param [Integer, String] project The ID or name of a project.
58
+ # @param [String] name The name of a label.
59
+ # @return [Gitlab::ObjectifiedHash] Information about deleted label.
60
+ def delete_label(project, name)
61
+ delete("/projects/#{url_encode project}/labels/#{name}")
62
+ end
63
+
64
+ # Subscribes the user to a label to receive notifications
65
+ #
66
+ # @example
67
+ # Gitlab.subscribe_to_label(2, 'Backlog')
68
+ #
69
+ # @param [Integer, String] project The ID or name of a project.
70
+ # @param [String] name The name of a label.
71
+ # @return [Gitlab::ObjectifiedHash] Information about the label subscribed to.
72
+ def subscribe_to_label(project, name)
73
+ post("/projects/#{url_encode project}/labels/#{url_encode name}/subscribe")
74
+ end
75
+
76
+ # Unsubscribes the user from a label to not receive notifications from it
77
+ #
78
+ # @example
79
+ # Gitlab.unsubscribe_from_label(2, 'Backlog')
80
+ #
81
+ # @param [Integer, String] project The ID or name of a project.
82
+ # @param [String] name The name of a label.
83
+ # @return [Gitlab::ObjectifiedHash] Information about the label unsubscribed from.
84
+ def unsubscribe_from_label(project, name)
85
+ post("/projects/#{url_encode project}/labels/#{url_encode name}/unsubscribe")
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to lint/validations.
5
+ # @see https://docs.gitlab.com/ce/api/lint.html
6
+ module Lint
7
+ # Checks if your .gitlab-ci.yml file is valid.
8
+ #
9
+ # @example
10
+ # Gitlab.validate_gitlab_ci_yml("{ \"image\": \"ruby:2.6\", \"services\": [\"postgres\"], \"before_script\": [\"bundle install\", \"bundle exec rake db:create\"], \"variables\": {\"DB_NAME\": \"postgres\"}, \"types\": [\"test\", \"deploy\", \"notify\"], \"rspec\": { \"script\": \"rake spec\", \"tags\": [\"ruby\", \"postgres\"], \"only\": [\"branches\"]}}")
11
+ #
12
+ # @param [String] content the .gitlab-ci.yaml content.
13
+ # @return <Gitlab::ObjectifiedHash> Returns information about validity of the yml.
14
+ def validate_gitlab_ci_yml(content)
15
+ body = { content: content }
16
+ post('/lint', body: body)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to markdown.
5
+ # @see https://docs.gitlab.com/ce/api/markdown.html
6
+ module Markdown
7
+ # Render an arbitrary Markdown document
8
+ #
9
+ # @example
10
+ # Gitlab.markdown('Hello world! :tada:')
11
+ # Gitlab.markdown('Hello world! :tada:', gfm: true, project: 'group_example/project_example')
12
+ #
13
+ # @param [String] text The markdown text to render.
14
+ # @param [Hash] options A customizable set of options.
15
+ # @option options [Boolean] :gfm(optional) Render text using GitLab Flavored Markdown. Default is false.
16
+ # @option options [String] :project(optional) Use project as a context when creating references using GitLab Flavored Markdown. Authentication is required if a project is not public.
17
+ # @return <Gitlab::ObjectifiedHash> Returns the rendered markdown as response
18
+ def markdown(text, options = {})
19
+ body = { text: text }.merge(options)
20
+ post('/markdown', body: body)
21
+ end
22
+ end
23
+ end