gitlab 4.5.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -267
- data/LICENSE.txt +1 -1
- data/README.md +40 -30
- data/exe/gitlab +5 -1
- data/lib/gitlab/api.rb +7 -3
- data/lib/gitlab/cli.rb +13 -9
- data/lib/gitlab/cli_helpers.rb +49 -45
- data/lib/gitlab/client/access_requests.rb +10 -1
- data/lib/gitlab/client/application_settings.rb +172 -0
- data/lib/gitlab/client/avatar.rb +21 -0
- data/lib/gitlab/client/award_emojis.rb +5 -3
- data/lib/gitlab/client/boards.rb +62 -4
- data/lib/gitlab/client/branches.rb +47 -8
- data/lib/gitlab/client/broadcast_messages.rb +75 -0
- data/lib/gitlab/client/build_variables.rb +19 -12
- data/lib/gitlab/client/builds.rb +13 -11
- data/lib/gitlab/client/commits.rb +73 -21
- data/lib/gitlab/client/container_registry.rb +85 -0
- data/lib/gitlab/client/deployments.rb +3 -1
- data/lib/gitlab/client/environments.rb +5 -3
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/events.rb +6 -4
- 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 +7 -6
- data/lib/gitlab/client/groups.rb +326 -12
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +47 -13
- data/lib/gitlab/client/jobs.rb +96 -8
- data/lib/gitlab/client/keys.rb +13 -0
- data/lib/gitlab/client/labels.rb +6 -4
- data/lib/gitlab/client/lint.rb +19 -0
- data/lib/gitlab/client/markdown.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +164 -9
- data/lib/gitlab/client/merge_requests.rb +148 -11
- data/lib/gitlab/client/merge_trains.rb +55 -0
- data/lib/gitlab/client/milestones.rb +19 -5
- data/lib/gitlab/client/namespaces.rb +4 -2
- data/lib/gitlab/client/notes.rb +38 -9
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +36 -10
- data/lib/gitlab/client/pipeline_triggers.rb +10 -8
- data/lib/gitlab/client/pipelines.rb +65 -3
- data/lib/gitlab/client/project_badges.rb +85 -0
- data/lib/gitlab/client/project_clusters.rb +83 -0
- data/lib/gitlab/client/project_exports.rb +54 -0
- data/lib/gitlab/client/project_release_links.rb +76 -0
- data/lib/gitlab/client/project_releases.rb +90 -0
- data/lib/gitlab/client/projects.rb +307 -26
- data/lib/gitlab/client/protected_tags.rb +59 -0
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +77 -6
- data/lib/gitlab/client/repository_files.rb +21 -3
- 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 +170 -18
- data/lib/gitlab/client/search.rb +66 -0
- data/lib/gitlab/client/services.rb +4 -1
- data/lib/gitlab/client/sidekiq.rb +2 -0
- data/lib/gitlab/client/snippets.rb +5 -3
- data/lib/gitlab/client/system_hooks.rb +9 -7
- data/lib/gitlab/client/tags.rb +10 -9
- data/lib/gitlab/client/templates.rb +100 -0
- data/lib/gitlab/client/todos.rb +7 -5
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +302 -31
- data/lib/gitlab/client/versions.rb +18 -0
- data/lib/gitlab/client/wikis.rb +79 -0
- data/lib/gitlab/client.rb +48 -9
- data/lib/gitlab/configuration.rb +9 -6
- data/lib/gitlab/error.rb +73 -3
- data/lib/gitlab/file_response.rb +4 -2
- data/lib/gitlab/headers/page_links.rb +37 -0
- data/lib/gitlab/headers/total.rb +29 -0
- data/lib/gitlab/help.rb +16 -16
- data/lib/gitlab/objectified_hash.rb +27 -10
- data/lib/gitlab/paginated_response.rb +43 -25
- data/lib/gitlab/request.rb +51 -37
- data/lib/gitlab/shell.rb +6 -4
- data/lib/gitlab/shell_history.rb +11 -13
- data/lib/gitlab/version.rb +3 -1
- data/lib/gitlab.rb +23 -9
- metadata +59 -45
- data/.gitignore +0 -22
- data/CONTRIBUTING.md +0 -195
- data/Gemfile +0 -4
- data/Rakefile +0 -17
- data/bin/console +0 -10
- data/bin/setup +0 -6
- data/gitlab.gemspec +0 -33
- data/lib/gitlab/page_links.rb +0 -33
data/lib/gitlab/client/jobs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to projects.
|
3
5
|
# @see https://docs.gitlab.com/ee/api/jobs.html
|
@@ -7,10 +9,13 @@ class Gitlab::Client
|
|
7
9
|
# @example
|
8
10
|
# Gitlab.jobs(1)
|
9
11
|
# Gitlab.jobs("project")
|
12
|
+
# Gitlab.jobs("project", {scope: ["manual", "success"], per_page: 100 })
|
10
13
|
#
|
11
14
|
# @param [Integer, String] id The ID or name of a project.
|
12
15
|
# @param [Hash] options A customizable set of options.
|
13
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.
|
14
19
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
15
20
|
def jobs(project_id, options = {})
|
16
21
|
get("/projects/#{url_encode project_id}/jobs", query: options)
|
@@ -31,6 +36,21 @@ class Gitlab::Client
|
|
31
36
|
get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
|
32
37
|
end
|
33
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
|
+
|
34
54
|
# Gets a single job
|
35
55
|
#
|
36
56
|
# @example
|
@@ -65,16 +85,70 @@ class Gitlab::Client
|
|
65
85
|
# Gitlab.job_artifacts_download(1, "master", "release")
|
66
86
|
# Gitlab.job_artifacts_download("project", "master", "release")
|
67
87
|
#
|
68
|
-
# @param [Integer, String]
|
69
|
-
# @param [String] ref
|
70
|
-
# @param [String] job
|
71
|
-
# @return [
|
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]
|
72
92
|
def job_artifacts_download(project_id, ref_name, job_name)
|
73
|
-
get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
+
})
|
77
150
|
end
|
151
|
+
alias download_tag_artifact_file download_branch_artifact_file
|
78
152
|
|
79
153
|
# Get Job Trace
|
80
154
|
#
|
@@ -158,5 +232,19 @@ class Gitlab::Client
|
|
158
232
|
def job_artifacts_keep(project_id, job_id)
|
159
233
|
post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep")
|
160
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
|
161
249
|
end
|
162
250
|
end
|
data/lib/gitlab/client/keys.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to keys.
|
3
5
|
# @see https://docs.gitlab.com/ce/api/keys.html
|
@@ -12,5 +14,16 @@ class Gitlab::Client
|
|
12
14
|
def key(id)
|
13
15
|
get("/keys/#{id}")
|
14
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
|
15
28
|
end
|
16
29
|
end
|
data/lib/gitlab/client/labels.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
|
-
# Defines methods related to labels.
|
4
|
+
# Defines methods related to project labels.
|
3
5
|
# @see https://docs.gitlab.com/ce/api/labels.html
|
4
6
|
module Labels
|
5
7
|
# Gets a list of project's labels.
|
@@ -9,7 +11,7 @@ class Gitlab::Client
|
|
9
11
|
#
|
10
12
|
# @param [Integer, String] project The ID or name of a project.
|
11
13
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
12
|
-
def labels(project, options={})
|
14
|
+
def labels(project, options = {})
|
13
15
|
get("/projects/#{url_encode project}/labels", query: options)
|
14
16
|
end
|
15
17
|
|
@@ -43,7 +45,7 @@ class Gitlab::Client
|
|
43
45
|
# @option options [String] :description The description of the label.
|
44
46
|
# @option options [String] :priority The priority of the label. Must be greater or equal than zero or null to remove the priority.
|
45
47
|
# @return [Gitlab::ObjectifiedHash] Information about updated label.
|
46
|
-
def edit_label(project, name, options={})
|
48
|
+
def edit_label(project, name, options = {})
|
47
49
|
put("/projects/#{url_encode project}/labels", body: options.merge(name: name))
|
48
50
|
end
|
49
51
|
|
@@ -56,7 +58,7 @@ class Gitlab::Client
|
|
56
58
|
# @param [String] name The name of a label.
|
57
59
|
# @return [Gitlab::ObjectifiedHash] Information about deleted label.
|
58
60
|
def delete_label(project, name)
|
59
|
-
delete("/projects/#{url_encode project}/labels
|
61
|
+
delete("/projects/#{url_encode project}/labels/#{name}")
|
60
62
|
end
|
61
63
|
|
62
64
|
# Subscribes the user to a label to receive notifications
|
@@ -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
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Gitlab::Client
|
2
4
|
# Defines methods related to MR Approvals.
|
3
5
|
# @see https://docs.gitlab.com/ee/api/merge_request_approvals.html
|
@@ -29,17 +31,75 @@ class Gitlab::Client
|
|
29
31
|
post("/projects/#{url_encode project}/approvals", body: options)
|
30
32
|
end
|
31
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
|
+
|
32
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
|
33
93
|
#
|
34
94
|
# @example
|
35
95
|
# Gitlab.edit_project_approvers(1, {approver_ids: [5], approver_groups: [1]})
|
36
96
|
#
|
37
97
|
# @param [Integer] project(required) The ID of a project.
|
38
|
-
# @option options [Array] :approver_ids(
|
39
|
-
# @option options [Array] :approver_group_ids(
|
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
|
40
100
|
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
|
41
101
|
def edit_project_approvers(project, options = {})
|
42
|
-
put("/projects/#{url_encode project}/
|
102
|
+
put("/projects/#{url_encode project}/approvers", body: options)
|
43
103
|
end
|
44
104
|
|
45
105
|
# Get Configuration for approvals on a specific Merge Request.
|
@@ -68,17 +128,99 @@ class Gitlab::Client
|
|
68
128
|
end
|
69
129
|
|
70
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
|
71
133
|
#
|
72
134
|
# @example
|
73
135
|
# Gitlab.edit_merge_request_approvers(1, 5, {approver_ids: [5], approver_groups: [1]})
|
74
136
|
#
|
75
137
|
# @param [Integer] project(required) The ID of a project.
|
76
138
|
# @param [Integer] merge_request(required) The IID of a merge_request.
|
77
|
-
# @option options [Array] :approver_ids(
|
78
|
-
# @option options [Array] :approver_group_ids(
|
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
|
79
141
|
# @return [Gitlab::ObjectifiedHash] MR approval configuration information about the project
|
80
142
|
def edit_merge_request_approvers(project, merge_request, options = {})
|
81
|
-
put("/projects/#{url_encode project}/merge_requests/#{merge_request}/
|
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}")
|
82
224
|
end
|
83
225
|
|
84
226
|
# Approve a merge request
|
@@ -102,9 +244,22 @@ class Gitlab::Client
|
|
102
244
|
#
|
103
245
|
# @param [Integer] project(required) The ID of a project.
|
104
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
|
105
248
|
# @return [void] This API call returns an empty response body.
|
106
|
-
def unapprove_merge_request(project, merge_request)
|
107
|
-
post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove")
|
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")
|
108
263
|
end
|
109
264
|
end
|
110
|
-
end
|
265
|
+
end
|