fs-gitlab 4.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +270 -0
- data/LICENSE.txt +24 -0
- data/README.md +260 -0
- data/exe/gitlab +11 -0
- data/lib/gitlab/api.rb +24 -0
- data/lib/gitlab/cli.rb +89 -0
- data/lib/gitlab/cli_helpers.rb +243 -0
- data/lib/gitlab/client/access_requests.rb +103 -0
- data/lib/gitlab/client/application_settings.rb +172 -0
- data/lib/gitlab/client/avatar.rb +21 -0
- data/lib/gitlab/client/award_emojis.rb +137 -0
- data/lib/gitlab/client/boards.rb +146 -0
- data/lib/gitlab/client/branches.rb +135 -0
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +135 -0
- data/lib/gitlab/client/builds.rb +108 -0
- data/lib/gitlab/client/commits.rb +216 -0
- data/lib/gitlab/client/container_registry.rb +85 -0
- data/lib/gitlab/client/deployments.rb +34 -0
- data/lib/gitlab/client/environments.rb +89 -0
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/events.rb +60 -0
- data/lib/gitlab/client/features.rb +48 -0
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_boards.rb +141 -0
- data/lib/gitlab/client/group_labels.rb +88 -0
- data/lib/gitlab/client/group_milestones.rb +94 -0
- data/lib/gitlab/client/groups.rb +358 -0
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +231 -0
- data/lib/gitlab/client/jobs.rb +250 -0
- data/lib/gitlab/client/keys.rb +29 -0
- data/lib/gitlab/client/labels.rb +88 -0
- data/lib/gitlab/client/lint.rb +19 -0
- data/lib/gitlab/client/markdown.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +265 -0
- data/lib/gitlab/client/merge_requests.rb +386 -0
- data/lib/gitlab/client/milestones.rb +106 -0
- data/lib/gitlab/client/namespaces.rb +22 -0
- data/lib/gitlab/client/notes.rb +313 -0
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +147 -0
- data/lib/gitlab/client/pipeline_triggers.rb +103 -0
- data/lib/gitlab/client/pipelines.rb +105 -0
- data/lib/gitlab/client/project_badges.rb +85 -0
- data/lib/gitlab/client/project_clusters.rb +83 -0
- data/lib/gitlab/client/project_release_links.rb +76 -0
- data/lib/gitlab/client/project_releases.rb +79 -0
- data/lib/gitlab/client/projects.rb +708 -0
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +113 -0
- data/lib/gitlab/client/repository_files.rb +131 -0
- data/lib/gitlab/client/repository_submodules.rb +27 -0
- data/lib/gitlab/client/resource_label_events.rb +82 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +211 -0
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +53 -0
- data/lib/gitlab/client/sidekiq.rb +39 -0
- data/lib/gitlab/client/snippets.rb +95 -0
- data/lib/gitlab/client/system_hooks.rb +64 -0
- data/lib/gitlab/client/tags.rb +97 -0
- data/lib/gitlab/client/templates.rb +100 -0
- data/lib/gitlab/client/todos.rb +46 -0
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +397 -0
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +95 -0
- data/lib/gitlab/configuration.rb +57 -0
- data/lib/gitlab/error.rb +170 -0
- data/lib/gitlab/file_response.rb +48 -0
- data/lib/gitlab/help.rb +94 -0
- data/lib/gitlab/objectified_hash.rb +51 -0
- data/lib/gitlab/page_links.rb +35 -0
- data/lib/gitlab/paginated_response.rb +110 -0
- data/lib/gitlab/request.rb +109 -0
- data/lib/gitlab/shell.rb +83 -0
- data/lib/gitlab/shell_history.rb +57 -0
- data/lib/gitlab/version.rb +5 -0
- data/lib/gitlab.rb +56 -0
- metadata +204 -0
@@ -0,0 +1,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
|
@@ -0,0 +1,265 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to MR Approvals.
|
5
|
+
# @see https://docs.gitlab.com/ee/api/merge_request_approvals.html
|
6
|
+
module MergeRequestApprovals
|
7
|
+
# Gets MR Approval Configuration for a project
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.project_merge_request_approvals(1)
|
11
|
+
#
|
12
|
+
# @param [Integer] project The ID of a project.
|
13
|
+
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
|
14
|
+
def project_merge_request_approvals(project)
|
15
|
+
get("/projects/#{url_encode project}/approvals")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Change MR Approval Configuration for a project
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3})
|
22
|
+
# Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, reset_approvals_on_push: true})
|
23
|
+
# Gitlab.edit_project_merge_request_approvals(1, {approvals_before_merge: 3, disable_overriding_approvers_per_merge_request: false})
|
24
|
+
#
|
25
|
+
# @param [Integer] project(required) The ID of a project.
|
26
|
+
# @option options [Integer] :approvals_before_merge(optional) How many approvals are required before an MR can be merged
|
27
|
+
# @option options [Boolean] :reset_approvals_on_push(optional) Reset approvals on a new push
|
28
|
+
# @option options [Boolean] :disable_overriding_approvers_per_merge_request(optional) Allow/Disallow overriding approvers per MR
|
29
|
+
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
|
30
|
+
def edit_project_merge_request_approvals(project, options = {})
|
31
|
+
post("/projects/#{url_encode project}/approvals", body: options)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Gets MR Approval Rules for a project
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# Gitlab.project_merge_request_approval_rules(1)
|
38
|
+
#
|
39
|
+
# @param [Integer] project The ID of a project.
|
40
|
+
# @return [Gitlab::ObjectifiedHash] MR approval rules for the project
|
41
|
+
def project_merge_request_approval_rules(project)
|
42
|
+
get("/projects/#{url_encode project}/approval_rules")
|
43
|
+
end
|
44
|
+
|
45
|
+
# Create MR Approval Rule for a project
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# Gitlab.create_project_merge_request_approval_rule(1, {name: "security", approvals_required: 1})
|
49
|
+
#
|
50
|
+
# @param [Integer] project(required) The ID of a project.
|
51
|
+
# @option options [String] :name(required) The name of the approval rule
|
52
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
53
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
54
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
55
|
+
# @option options [Array] :protected_branch_ids(optional) The ids of protected branches to scope the rule by
|
56
|
+
# @return [Gitlab::ObjectifiedHash] New MR approval rule
|
57
|
+
def create_project_merge_request_approval_rule(project, options = {})
|
58
|
+
post("/projects/#{url_encode project}/approval_rules", body: options)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Update MR Approval Rule for a project
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# Gitlab.update_project_merge_request_approval_rule(1, {name: "security", approvals_required: 2})
|
65
|
+
#
|
66
|
+
# @param [Integer] project(required) The ID of a project.
|
67
|
+
# @param [Integer] approval_rule_id(required) The ID of a project Approval Rule
|
68
|
+
# @option options [String] :name(required) The name of the approval rule
|
69
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
70
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
71
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
72
|
+
# @option options [Array] :protected_branch_ids(optional) The ids of protected branches to scope the rule by
|
73
|
+
# @return [Gitlab::ObjectifiedHash] Updated MR approval rule
|
74
|
+
def update_project_merge_request_approval_rule(project, approval_rule_id, options = {})
|
75
|
+
put("/projects/#{url_encode project}/approval_rules/#{approval_rule_id}", body: options)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Delete MR Approval Rule for a project
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Gitlab.delete_project_merge_request_approval_rule(1, 1)
|
82
|
+
#
|
83
|
+
# @param [Integer] project(required) The ID of a project.
|
84
|
+
# @param [Integer] approval_rule_id(required) The ID of a approval rule
|
85
|
+
# @return [void] This API call returns an empty response body
|
86
|
+
def delete_project_merge_request_approval_rule(project, approval_rule_id)
|
87
|
+
delete("/projects/#{url_encode project}/approval_rules/#{approval_rule_id}")
|
88
|
+
end
|
89
|
+
|
90
|
+
# Change allowed approvers and approver groups for a project
|
91
|
+
# @deprecated Since Gitlab 13.12 /approvers endpoints are removed!!!
|
92
|
+
# See Gitlab.create_project_merge_request_approval_rule
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
|
96
|
+
#
|
97
|
+
# @param [Integer] project(required) The ID of a project.
|
98
|
+
# @option options [Array] :approver_ids(required, nil if none) An array of User IDs that can approve MRs
|
99
|
+
# @option options [Array] :approver_group_ids(required, nil if none) An array of Group IDs whose members can approve MRs
|
100
|
+
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
|
101
|
+
def edit_project_approvers(project, options = {})
|
102
|
+
put("/projects/#{url_encode project}/approvers", body: options)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Get Configuration for approvals on a specific Merge Request.
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# Gitlab.merge_request_approvals(1, 5)
|
109
|
+
#
|
110
|
+
# @param [Integer] project(required) The ID of a project.
|
111
|
+
# @param [Integer] merge_request(required) The IID of a merge_request.
|
112
|
+
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the merge request
|
113
|
+
def merge_request_approvals(project, merge_request)
|
114
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals")
|
115
|
+
end
|
116
|
+
|
117
|
+
# Change configuration for approvals on a specific merge request.
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# Gitlab.edit_merge_request_approvals(1, 5, approvals_required: 2)
|
121
|
+
#
|
122
|
+
# @param [Integer] project(required) The ID of a project.
|
123
|
+
# @param [Integer] merge_request(required) The IID of a merge_request.
|
124
|
+
# @option options [Integer] :approvals_required(required) Approvals required before MR can be merged
|
125
|
+
# @return [Gitlab::ObjectifiedHash] Updated MR approval configuration information about the merge request
|
126
|
+
def edit_merge_request_approvals(project, merge_request, options = {})
|
127
|
+
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvals", body: options)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Change allowed approvers and approver groups for a merge request
|
131
|
+
# @deprecated Since Gitlab 13.12 /approvers endpoints are removed!!!
|
132
|
+
# See Gitlab.create_merge_request_level_rule
|
133
|
+
#
|
134
|
+
# @example
|
135
|
+
# Gitlab.edit_merge_request_approvers(1, 5, {approver_ids: [5], approver_groups: [1]})
|
136
|
+
#
|
137
|
+
# @param [Integer] project(required) The ID of a project.
|
138
|
+
# @param [Integer] merge_request(required) The IID of a merge_request.
|
139
|
+
# @option options [Array] :approver_ids(required, nil if none) An array of User IDs that can approve MRs
|
140
|
+
# @option options [Array] :approver_group_ids(required, nil if none) An array of Group IDs whose members can approve MRs
|
141
|
+
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
|
142
|
+
def edit_merge_request_approvers(project, merge_request, options = {})
|
143
|
+
put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approvers", body: options)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Create merge request level rule
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# Gitlab.create_merge_request_level_rule(1, 2, {
|
150
|
+
# name: "devs",
|
151
|
+
# approvals_required: 2,
|
152
|
+
# approval_project_rule_id: 99,
|
153
|
+
# user_ids: [3, 4],
|
154
|
+
# group_ids: [5, 6],
|
155
|
+
# })
|
156
|
+
#
|
157
|
+
# Important: When approval_project_rule_id is set, the name, users and groups of project-level rule are copied.
|
158
|
+
# The approvals_required specified is used.
|
159
|
+
#
|
160
|
+
# @param [Integer] project(required) The ID of a project.
|
161
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
162
|
+
# @option options [String] :name(required) The name of the approval rule
|
163
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
164
|
+
# @option options [Integer] :approval_project_rule_id(optional) The ID of a project-level approval rule
|
165
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
166
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
167
|
+
# @return [Gitlab::ObjectifiedHash] New MR level approval rule
|
168
|
+
def create_merge_request_level_rule(project, merge_request, options = {})
|
169
|
+
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules", body: options)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Get merge request level rule
|
173
|
+
#
|
174
|
+
# @example
|
175
|
+
# Gitlab.merge_request_level_rule(1, 2)
|
176
|
+
#
|
177
|
+
# @param [Integer] project(required) The ID of a project.
|
178
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
179
|
+
# @return [Gitlab::ObjectifiedHash] New MR level approval rule
|
180
|
+
def merge_request_level_rule(project, merge_request)
|
181
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules")
|
182
|
+
end
|
183
|
+
|
184
|
+
# Update merge request level rule
|
185
|
+
#
|
186
|
+
# @example
|
187
|
+
# Gitlab.update_merge_request_level_rule(1, 2, 69, {
|
188
|
+
# name: "devs",
|
189
|
+
# approvals_required: 2,
|
190
|
+
# user_ids: [3, 4],
|
191
|
+
# group_ids: [5, 6],
|
192
|
+
# })
|
193
|
+
#
|
194
|
+
# Important: Approvers and groups not in the users/groups parameters are removed
|
195
|
+
# Important: Updating a report_approver or code_owner rule is not allowed.
|
196
|
+
# These are system generated rules.
|
197
|
+
#
|
198
|
+
# @param [Integer] project(required) The ID of a project.
|
199
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
200
|
+
# @param [Integer] appr_rule_id(required) The ID of a approval rule
|
201
|
+
# @option options [String] :name(required) The name of the approval rule
|
202
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
203
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
204
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
205
|
+
# @return [Gitlab::ObjectifiedHash] Updated MR level approval rule
|
206
|
+
def update_merge_request_level_rule(project, merge_request, appr_rule_id, options = {})
|
207
|
+
put("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules/#{appr_rule_id}", body: options)
|
208
|
+
end
|
209
|
+
|
210
|
+
# Delete merge request level rule
|
211
|
+
#
|
212
|
+
# @example
|
213
|
+
# Gitlab.delete_merge_request_level_rule(1, 2, 69)
|
214
|
+
#
|
215
|
+
# Important: Deleting a report_approver or code_owner rule is not allowed.
|
216
|
+
# These are system generated rules.
|
217
|
+
#
|
218
|
+
# @param [Integer] project(required) The ID of a project.
|
219
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
220
|
+
# @param [Integer] appr_rule_id(required) The ID of a approval rule
|
221
|
+
# @return [void] This API call returns an empty response body
|
222
|
+
def delete_merge_request_level_rule(project, merge_request, appr_rule_id)
|
223
|
+
delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/approval_rules/#{appr_rule_id}")
|
224
|
+
end
|
225
|
+
|
226
|
+
# Approve a merge request
|
227
|
+
#
|
228
|
+
# @example
|
229
|
+
# Gitlab.approve_merge_request(1, 5)
|
230
|
+
# Gitlab.approve_merge_request(1, 5, sha: 'fe678da')
|
231
|
+
#
|
232
|
+
# @param [Integer] project(required) The ID of a project.
|
233
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
234
|
+
# @option options [String] :sha(optional) The HEAD of the MR
|
235
|
+
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
|
236
|
+
def approve_merge_request(project, merge_request, options = {})
|
237
|
+
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/approve", body: options)
|
238
|
+
end
|
239
|
+
|
240
|
+
# Unapprove a merge request
|
241
|
+
#
|
242
|
+
# @example
|
243
|
+
# Gitlab.unapprove_merge_request(1, 5)
|
244
|
+
#
|
245
|
+
# @param [Integer] project(required) The ID of a project.
|
246
|
+
# @param [Integer] merge_request(required) The IID of a merge request.
|
247
|
+
# @option options [String] :sudo(optional) The username of the user you want to remove the approval for
|
248
|
+
# @return [void] This API call returns an empty response body.
|
249
|
+
def unapprove_merge_request(project, merge_request, options = {})
|
250
|
+
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove", body: options)
|
251
|
+
end
|
252
|
+
|
253
|
+
# Get the approval state of merge requests
|
254
|
+
#
|
255
|
+
# @example
|
256
|
+
# Gitlab.merge_request_approval_state(5, 36)
|
257
|
+
#
|
258
|
+
# @param [Integer, String] project The ID or name of a project.
|
259
|
+
# @param [Integer] id The ID of a merge request.
|
260
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
261
|
+
def merge_request_approval_state(project, id)
|
262
|
+
get("/projects/#{url_encode project}/merge_requests/#{id}/approval_state")
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|