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
@@ -1,7 +1,9 @@
|
|
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/ce/api/projects.html
|
4
|
-
module Projects
|
6
|
+
module Projects # rubocop:disable Metrics/ModuleLength
|
5
7
|
# Gets a list of projects owned by the authenticated user.
|
6
8
|
#
|
7
9
|
# @example
|
@@ -13,8 +15,8 @@ class Gitlab::Client
|
|
13
15
|
# (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#list-all-projects Gitlab docs} for all valid options)
|
14
16
|
#
|
15
17
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
16
|
-
def projects(options={})
|
17
|
-
get(
|
18
|
+
def projects(options = {})
|
19
|
+
get('/projects', query: options)
|
18
20
|
end
|
19
21
|
|
20
22
|
# Search for projects by name.
|
@@ -30,10 +32,10 @@ class Gitlab::Client
|
|
30
32
|
# @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
|
31
33
|
# @option options [String] :sort Return requests sorted in asc or desc order
|
32
34
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
33
|
-
def project_search(query, options={})
|
34
|
-
get(
|
35
|
+
def project_search(query, options = {})
|
36
|
+
get('/projects', query: options.merge(search: query))
|
35
37
|
end
|
36
|
-
|
38
|
+
alias search_projects project_search
|
37
39
|
|
38
40
|
# Gets information about a project.
|
39
41
|
#
|
@@ -42,9 +44,12 @@ class Gitlab::Client
|
|
42
44
|
# Gitlab.project('gitlab')
|
43
45
|
#
|
44
46
|
# @param [Integer, String] id The ID or path of a project.
|
47
|
+
# @param options [string] :license Include project license data
|
48
|
+
# @param options [string] :statistics Include project statistics.
|
49
|
+
# @param options [string] :with_custom_attributes Include custom attributes in response. (admins only)
|
45
50
|
# @return [Gitlab::ObjectifiedHash]
|
46
|
-
def project(id)
|
47
|
-
get("/projects/#{url_encode id}")
|
51
|
+
def project(id, options = {})
|
52
|
+
get("/projects/#{url_encode id}", query: options)
|
48
53
|
end
|
49
54
|
|
50
55
|
# Creates a new project.
|
@@ -65,11 +70,11 @@ class Gitlab::Client
|
|
65
70
|
# @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
|
66
71
|
# @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
|
67
72
|
# @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
|
68
|
-
# @option options [
|
73
|
+
# @option options [String] :visibility The setting for making a project public ('private', 'internal', 'public').
|
69
74
|
# @option options [Integer] :user_id The user/owner id of a project.
|
70
75
|
# @return [Gitlab::ObjectifiedHash] Information about created project.
|
71
|
-
def create_project(name, options={})
|
72
|
-
url = options[:user_id] ? "/projects/user/#{options[:user_id]}" :
|
76
|
+
def create_project(name, options = {})
|
77
|
+
url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : '/projects'
|
73
78
|
post(url, body: { name: name }.merge(options))
|
74
79
|
end
|
75
80
|
|
@@ -96,10 +101,26 @@ class Gitlab::Client
|
|
96
101
|
# @option options [Integer] :page The page number.
|
97
102
|
# @option options [Integer] :per_page The number of results per page.
|
98
103
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
99
|
-
def team_members(project, options={})
|
104
|
+
def team_members(project, options = {})
|
100
105
|
get("/projects/#{url_encode project}/members", query: options)
|
101
106
|
end
|
102
107
|
|
108
|
+
# Gets a list of all project team members including inherited members.
|
109
|
+
#
|
110
|
+
# @example
|
111
|
+
# Gitlab.all_members(42)
|
112
|
+
# Gitlab.all_members('gitlab')
|
113
|
+
#
|
114
|
+
# @param [Integer, String] project The ID or path of a project.
|
115
|
+
# @param [Hash] options A customizable set of options.
|
116
|
+
# @option options [String] :query The search query.
|
117
|
+
# @option options [Integer] :page The page number.
|
118
|
+
# @option options [Integer] :per_page The number of results per page.
|
119
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
120
|
+
def all_members(project, options = {})
|
121
|
+
get("/projects/#{url_encode project}/members/all", query: options)
|
122
|
+
end
|
123
|
+
|
103
124
|
# Gets a project team member.
|
104
125
|
#
|
105
126
|
# @example
|
@@ -116,28 +137,34 @@ class Gitlab::Client
|
|
116
137
|
#
|
117
138
|
# @example
|
118
139
|
# Gitlab.add_team_member('gitlab', 2, 40)
|
140
|
+
# Gitlab.add_team_member('gitlab', 2, 40, { expires_at: "2018-12-31"})
|
119
141
|
#
|
120
142
|
# @param [Integer, String] project The ID or path of a project.
|
121
143
|
# @param [Integer] id The ID of a user.
|
122
144
|
# @param [Integer] access_level The access level to project.
|
123
145
|
# @param [Hash] options A customizable set of options.
|
146
|
+
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
124
147
|
# @return [Gitlab::ObjectifiedHash] Information about added team member.
|
125
|
-
def add_team_member(project, id, access_level)
|
126
|
-
|
148
|
+
def add_team_member(project, id, access_level, options = {})
|
149
|
+
body = { user_id: id, access_level: access_level }.merge(options)
|
150
|
+
post("/projects/#{url_encode project}/members", body: body)
|
127
151
|
end
|
128
152
|
|
129
153
|
# Updates a team member's project access level.
|
130
154
|
#
|
131
155
|
# @example
|
132
156
|
# Gitlab.edit_team_member('gitlab', 3, 20)
|
157
|
+
# Gitlab.edit_team_member('gitlab', 3, 20, { expires_at: "2018-12-31"})
|
133
158
|
#
|
134
159
|
# @param [Integer, String] project The ID or path of a project.
|
135
160
|
# @param [Integer] id The ID of a user.
|
136
161
|
# @param [Integer] access_level The access level to project.
|
137
162
|
# @param [Hash] options A customizable set of options.
|
163
|
+
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
138
164
|
# @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member.
|
139
|
-
def edit_team_member(project, id, access_level)
|
140
|
-
|
165
|
+
def edit_team_member(project, id, access_level, options = {})
|
166
|
+
body = { access_level: access_level }.merge(options)
|
167
|
+
put("/projects/#{url_encode project}/members/#{id}", body: body)
|
141
168
|
end
|
142
169
|
|
143
170
|
# Removes a user from project team.
|
@@ -164,7 +191,7 @@ class Gitlab::Client
|
|
164
191
|
# @option options [Integer] :page The page number.
|
165
192
|
# @option options [Integer] :per_page The number of results per page.
|
166
193
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
167
|
-
def project_hooks(project, options={})
|
194
|
+
def project_hooks(project, options = {})
|
168
195
|
get("/projects/#{url_encode project}/hooks", query: options)
|
169
196
|
end
|
170
197
|
|
@@ -194,7 +221,7 @@ class Gitlab::Client
|
|
194
221
|
# @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
|
195
222
|
# @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
|
196
223
|
# @return [Gitlab::ObjectifiedHash] Information about added hook.
|
197
|
-
def add_project_hook(project, url, options={})
|
224
|
+
def add_project_hook(project, url, options = {})
|
198
225
|
body = { url: url }.merge(options)
|
199
226
|
post("/projects/#{url_encode project}/hooks", body: body)
|
200
227
|
end
|
@@ -213,7 +240,7 @@ class Gitlab::Client
|
|
213
240
|
# @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true)
|
214
241
|
# @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true)
|
215
242
|
# @return [Gitlab::ObjectifiedHash] Information about updated hook.
|
216
|
-
def edit_project_hook(project, id, url, options={})
|
243
|
+
def edit_project_hook(project, id, url, options = {})
|
217
244
|
body = { url: url }.merge(options)
|
218
245
|
put("/projects/#{url_encode project}/hooks/#{id}", body: body)
|
219
246
|
end
|
@@ -253,7 +280,7 @@ class Gitlab::Client
|
|
253
280
|
# @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
|
254
281
|
# @param option [String] :commit_message_regex Commit message regex
|
255
282
|
# @return [Gitlab::ObjectifiedHash] Information about added push rule.
|
256
|
-
def add_push_rule(id, options={})
|
283
|
+
def add_push_rule(id, options = {})
|
257
284
|
post("/projects/#{url_encode id}/push_rule", body: options)
|
258
285
|
end
|
259
286
|
|
@@ -268,7 +295,7 @@ class Gitlab::Client
|
|
268
295
|
# @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true)
|
269
296
|
# @param option [String] :commit_message_regex Commit message regex
|
270
297
|
# @return [Gitlab::ObjectifiedHash] Information about updated push rule.
|
271
|
-
def edit_push_rule(id, options={})
|
298
|
+
def edit_push_rule(id, options = {})
|
272
299
|
put("/projects/#{url_encode id}/push_rule", body: options)
|
273
300
|
end
|
274
301
|
|
@@ -318,7 +345,7 @@ class Gitlab::Client
|
|
318
345
|
# @option options [Integer] :page The page number.
|
319
346
|
# @option options [Integer] :per_page The number of results per page.
|
320
347
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
321
|
-
def deploy_keys(project, options={})
|
348
|
+
def deploy_keys(project, options = {})
|
322
349
|
get("/projects/#{url_encode project}/deploy_keys", query: options)
|
323
350
|
end
|
324
351
|
|
@@ -372,6 +399,20 @@ class Gitlab::Client
|
|
372
399
|
post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
|
373
400
|
end
|
374
401
|
|
402
|
+
# Updates an existing deploy key.
|
403
|
+
#
|
404
|
+
# @example
|
405
|
+
# Gitlab.edit_deploy_key(42, 66, 'New key name', can_push: false)
|
406
|
+
#
|
407
|
+
# @param [Integer, String] project The ID or path of a project.
|
408
|
+
# @param [Integer] id The ID of a deploy key.
|
409
|
+
# @param [String] title The title of a deploy key.
|
410
|
+
# @param [Hash] options A customizable set of options.
|
411
|
+
# @return [Gitlab::ObjectifiedHash] Information about created deploy key.
|
412
|
+
def edit_deploy_key(project, id, title, options = {})
|
413
|
+
put("/projects/#{url_encode project}/deploy_keys/#{id}", body: { title: title }.merge(options))
|
414
|
+
end
|
415
|
+
|
375
416
|
# Deletes a deploy key from project.
|
376
417
|
#
|
377
418
|
# @example
|
@@ -394,7 +435,7 @@ class Gitlab::Client
|
|
394
435
|
# @param [Hash] options A customizable set of options.
|
395
436
|
# @option options [String] :sudo The username the project will be forked for
|
396
437
|
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
|
397
|
-
def create_fork(id, options={})
|
438
|
+
def create_fork(id, options = {})
|
398
439
|
post("/projects/#{url_encode id}/fork", body: options)
|
399
440
|
end
|
400
441
|
|
@@ -412,7 +453,7 @@ class Gitlab::Client
|
|
412
453
|
# @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields
|
413
454
|
# @option options [String] :sort Return requests sorted in asc or desc order
|
414
455
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
415
|
-
def project_forks(id, options={})
|
456
|
+
def project_forks(id, options = {})
|
416
457
|
get("/projects/#{url_encode id}/forks", query: options)
|
417
458
|
end
|
418
459
|
|
@@ -431,7 +472,7 @@ class Gitlab::Client
|
|
431
472
|
# (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#edit-project Gitlab docs} for all valid options)
|
432
473
|
#
|
433
474
|
# @return [Gitlab::ObjectifiedHash] Information about the edited project.
|
434
|
-
def edit_project(id, options={})
|
475
|
+
def edit_project(id, options = {})
|
435
476
|
put("/projects/#{url_encode id}", body: options)
|
436
477
|
end
|
437
478
|
|
@@ -459,6 +500,18 @@ class Gitlab::Client
|
|
459
500
|
delete("/projects/#{url_encode project}/share/#{id}")
|
460
501
|
end
|
461
502
|
|
503
|
+
# Transfer a project to a new namespace.
|
504
|
+
#
|
505
|
+
# @example
|
506
|
+
# Gitlab.transfer_project(42, 'yolo')
|
507
|
+
#
|
508
|
+
# @param [Integer, String] project The ID or path of a project
|
509
|
+
# @param [Integer, String] namespace The ID or path of the namespace to transfer to project to
|
510
|
+
# @return [Gitlab::ObjectifiedHash] Information about transfered project.
|
511
|
+
def transfer_project(project, namespace)
|
512
|
+
put("/projects/#{url_encode project}/transfer", body: { namespace: namespace })
|
513
|
+
end
|
514
|
+
|
462
515
|
# Stars a project.
|
463
516
|
# @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
|
464
517
|
#
|
@@ -485,6 +538,25 @@ class Gitlab::Client
|
|
485
538
|
delete("/projects/#{url_encode id}/star")
|
486
539
|
end
|
487
540
|
|
541
|
+
# Get a list of visible projects that the given user has starred.
|
542
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user
|
543
|
+
#
|
544
|
+
# @example
|
545
|
+
# Gitlab.user_starred_projects(1)
|
546
|
+
# Gitlab.user_starred_projects(1, { order_by: 'last_activity_at' })
|
547
|
+
# Gitlab.user_starred_projects('username', { order_by: 'name', sort: 'asc' })
|
548
|
+
#
|
549
|
+
# @param [Integer, String] user_id The ID or username of the user.
|
550
|
+
# @param [Hash] options A customizable set of options.
|
551
|
+
# @option options [String] :per_page Number of projects to return per page
|
552
|
+
# @option options [String] :page The page to retrieve
|
553
|
+
# @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
|
554
|
+
# @option options [String] :sort Return projects sorted in asc or desc order.
|
555
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
556
|
+
def user_starred_projects(user_id, options = {})
|
557
|
+
get("/users/#{url_encode user_id}/starred_projects", query: options)
|
558
|
+
end
|
559
|
+
|
488
560
|
# Get a list of visible projects for the given user.
|
489
561
|
# @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
|
490
562
|
#
|
@@ -500,8 +572,217 @@ class Gitlab::Client
|
|
500
572
|
# @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields.
|
501
573
|
# @option options [String] :sort Return projects sorted in asc or desc order.
|
502
574
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
503
|
-
def user_projects(user_id, options={})
|
575
|
+
def user_projects(user_id, options = {})
|
504
576
|
get("/users/#{url_encode user_id}/projects", query: options)
|
505
577
|
end
|
578
|
+
|
579
|
+
# Uploads a file to the specified project to be used in an issue or
|
580
|
+
# merge request description, or a comment.
|
581
|
+
# @see https://docs.gitlab.com/ee/api/projects.html#upload-a-file
|
582
|
+
#
|
583
|
+
# @example
|
584
|
+
# Gitlab.upload_file(1, '/full/path/to/avatar.jpg')
|
585
|
+
#
|
586
|
+
# @param [Integer, String] id The ID or path of a project.
|
587
|
+
# @param [String] file_fullpath The fullpath of the file you are interested to upload.
|
588
|
+
# @return [Gitlab::ObjectifiedHash]
|
589
|
+
def upload_file(id, file_fullpath)
|
590
|
+
post("/projects/#{url_encode id}/uploads", body: { file: File.open(file_fullpath, 'r') })
|
591
|
+
end
|
592
|
+
|
593
|
+
# Get all project templates of a particular type
|
594
|
+
# @see https://docs.gitlab.com/ce/api/project_templates.html
|
595
|
+
#
|
596
|
+
# @example
|
597
|
+
# Gitlab.project_templates(1, 'dockerfiles')
|
598
|
+
# Gitlab.project_templates(1, 'licenses')
|
599
|
+
#
|
600
|
+
# @param [Integer, String] id The ID or URL-encoded path of the project.
|
601
|
+
# @param [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
|
602
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
603
|
+
def project_templates(project, type)
|
604
|
+
get("/projects/#{url_encode project}/templates/#{type}")
|
605
|
+
end
|
606
|
+
|
607
|
+
# Get one project template of a particular type
|
608
|
+
# @see https://docs.gitlab.com/ce/api/project_templates.html
|
609
|
+
#
|
610
|
+
# @example
|
611
|
+
# Gitlab.project_template(1, 'dockerfiles', 'dockey')
|
612
|
+
# Gitlab.project_template(1, 'licenses', 'gpl', { project: 'some project', fullname: 'Holder Holding' })
|
613
|
+
#
|
614
|
+
# @param [Integer, String] project The ID or URL-encoded path of the project.
|
615
|
+
# @param [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template
|
616
|
+
# @param [String] key The key of the template, as obtained from the collection endpoint
|
617
|
+
# @param [Hash] options A customizable set of options.
|
618
|
+
# @option options [String] project(optional) The project name to use when expanding placeholders in the template. Only affects licenses
|
619
|
+
# @option options [String] fullname(optional) The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses
|
620
|
+
# @return [Gitlab::ObjectifiedHash]
|
621
|
+
def project_template(project, type, key, options = {})
|
622
|
+
get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options)
|
623
|
+
end
|
624
|
+
|
625
|
+
# Archives a project.
|
626
|
+
#
|
627
|
+
# @example
|
628
|
+
# Gitlab.archive_project(4)
|
629
|
+
#
|
630
|
+
# @param [Integer, String] id The ID or path of a project.
|
631
|
+
# @return [Gitlab::ObjectifiedHash] Information about archived project.
|
632
|
+
def archive_project(id)
|
633
|
+
post("/projects/#{url_encode id}/archive")
|
634
|
+
end
|
635
|
+
|
636
|
+
# Unarchives a project.
|
637
|
+
#
|
638
|
+
# @example
|
639
|
+
# Gitlab.unarchive_project(4)
|
640
|
+
#
|
641
|
+
# @param [Integer, String] id The ID or path of a project.
|
642
|
+
# @return [Gitlab::ObjectifiedHash] Information about unarchived project.
|
643
|
+
def unarchive_project(id)
|
644
|
+
post("/projects/#{url_encode id}/unarchive")
|
645
|
+
end
|
646
|
+
|
647
|
+
# Gets project custom_attributes.
|
648
|
+
#
|
649
|
+
# @example
|
650
|
+
# Gitlab.project_custom_attributes(2)
|
651
|
+
#
|
652
|
+
# @param [Integer] project_id The ID of a project.
|
653
|
+
# @return [Gitlab::ObjectifiedHash]
|
654
|
+
def project_custom_attributes(project_id)
|
655
|
+
get("/projects/#{project_id}/custom_attributes")
|
656
|
+
end
|
657
|
+
|
658
|
+
# Gets single project custom_attribute.
|
659
|
+
#
|
660
|
+
# @example
|
661
|
+
# Gitlab.project_custom_attribute(key, 2)
|
662
|
+
#
|
663
|
+
# @param [String] key The custom_attributes key
|
664
|
+
# @param [Integer] project_id The ID of a project.
|
665
|
+
# @return [Gitlab::ObjectifiedHash]
|
666
|
+
def project_custom_attribute(key, project_id)
|
667
|
+
get("/projects/#{project_id}/custom_attributes/#{key}")
|
668
|
+
end
|
669
|
+
|
670
|
+
# Creates a new custom_attribute
|
671
|
+
#
|
672
|
+
# @example
|
673
|
+
# Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)
|
674
|
+
#
|
675
|
+
# @param [String] key The custom_attributes key
|
676
|
+
# @param [String] value The custom_attributes value
|
677
|
+
# @param [Integer] project_id The ID of a project.
|
678
|
+
# @return [Gitlab::ObjectifiedHash]
|
679
|
+
def add_project_custom_attribute(key, value, project_id)
|
680
|
+
url = "/projects/#{project_id}/custom_attributes/#{key}"
|
681
|
+
put(url, body: { value: value })
|
682
|
+
end
|
683
|
+
|
684
|
+
# Delete custom_attribute
|
685
|
+
# Will delete a custom_attribute
|
686
|
+
#
|
687
|
+
# @example
|
688
|
+
# Gitlab.delete_project_custom_attribute('somekey', 2)
|
689
|
+
#
|
690
|
+
# @param [String] key The custom_attribute key to delete
|
691
|
+
# @param [Integer] project_id The ID of a project.
|
692
|
+
# @return [Boolean]
|
693
|
+
def delete_project_custom_attribute(key, project_id = nil)
|
694
|
+
delete("/projects/#{project_id}/custom_attributes/#{key}")
|
695
|
+
end
|
696
|
+
|
697
|
+
# List project deploy tokens
|
698
|
+
#
|
699
|
+
# @example
|
700
|
+
# Gitlab.project_deploy_tokens(42)
|
701
|
+
#
|
702
|
+
# @param [Integer, String] id The ID or path of a project.
|
703
|
+
# @option options [Boolean] :active Limit by active status. Optional.
|
704
|
+
def project_deploy_tokens(project, options = {})
|
705
|
+
get("/projects/#{url_encode project}/deploy_tokens", query: options)
|
706
|
+
end
|
707
|
+
|
708
|
+
# Get languages used with percentage value
|
709
|
+
#
|
710
|
+
# @example
|
711
|
+
# Gitlab.project_languages(42)
|
712
|
+
#
|
713
|
+
# @param [Integer, String] id The ID or path of a project.
|
714
|
+
# @return [Gitlab::ObjectifiedHash]
|
715
|
+
def project_languages(project)
|
716
|
+
get("/projects/#{url_encode project}/languages")
|
717
|
+
end
|
718
|
+
|
719
|
+
# List all project access tokens.
|
720
|
+
#
|
721
|
+
# @example
|
722
|
+
# Gitlab.project_access_tokens(42)
|
723
|
+
#
|
724
|
+
# @param [Integer, String] project The ID or path of a project.
|
725
|
+
# @option options [String] :state Limit by active/inactive state. Optional.
|
726
|
+
#
|
727
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
728
|
+
def project_access_tokens(project, options = {})
|
729
|
+
get("/projects/#{url_encode project}/access_tokens", query: options)
|
730
|
+
end
|
731
|
+
|
732
|
+
# Get a specific project access token.
|
733
|
+
#
|
734
|
+
# @example
|
735
|
+
# Gitlab.project_access_token(42, 1234)
|
736
|
+
#
|
737
|
+
# @param [Integer, String] project The ID or path of a project.
|
738
|
+
# @param [Integer] token_id The ID of the project access token.
|
739
|
+
#
|
740
|
+
# @return [Gitlab::ObjectifiedHash] Information about the specified project access token.
|
741
|
+
def project_access_token(project, token_id)
|
742
|
+
get("/projects/#{url_encode project}/access_tokens/#{token_id}")
|
743
|
+
end
|
744
|
+
|
745
|
+
# Creates a new project access token.
|
746
|
+
#
|
747
|
+
# @example
|
748
|
+
# Gitlab.create_project_access_token(42, 'My Token', ['api'], '2024-12-12', access_level: 40)
|
749
|
+
#
|
750
|
+
# @param [Integer, String] project The ID or path of a project.
|
751
|
+
# @param [String] name The name of the project access token.
|
752
|
+
# @param [Array] scopes List of scopes of the project access token.
|
753
|
+
# @param [String] expires_at A date string in the format YYYY-MM-DD.
|
754
|
+
# @option options [Integer] :access_level Access level. Optional. Defaults to 40.
|
755
|
+
#
|
756
|
+
# @return [Gitlab::ObjectifiedHash] Information about the created project access token.
|
757
|
+
def create_project_access_token(project, name, scopes, expires_at, options = {})
|
758
|
+
post("/projects/#{url_encode project}/access_tokens", body: { name: name, scopes: scopes, expires_at: expires_at }.merge(options))
|
759
|
+
end
|
760
|
+
|
761
|
+
# Rotate a project access token.
|
762
|
+
#
|
763
|
+
# @example
|
764
|
+
# Gitlab.rotate_project_access_token(42, 1234)
|
765
|
+
#
|
766
|
+
# @param [Integer, String] project The ID or path of a project.
|
767
|
+
# @param [Integer] token_id The ID of the project access token.
|
768
|
+
# @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY.
|
769
|
+
#
|
770
|
+
# @return [Gitlab::ObjectifiedHash] Information about the specified project access token.
|
771
|
+
def rotate_project_access_token(project, token_id, options = {})
|
772
|
+
post("/projects/#{url_encode project}/access_tokens/#{token_id}/rotate", query: options)
|
773
|
+
end
|
774
|
+
|
775
|
+
# Revoke a project access token.
|
776
|
+
#
|
777
|
+
# @example
|
778
|
+
# Gitlab.revoke_project_access_token(42, 1234)
|
779
|
+
#
|
780
|
+
# @param [Integer, String] project The ID or path of a project.
|
781
|
+
# @param [Integer] token_id The ID of the project access token.
|
782
|
+
#
|
783
|
+
# @return [Gitlab::ObjectifiedHash]
|
784
|
+
def revoke_project_access_token(project, token_id)
|
785
|
+
delete("/projects/#{url_encode project}/access_tokens/#{token_id}")
|
786
|
+
end
|
506
787
|
end
|
507
788
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to Protected Tags.
|
5
|
+
# @see https://docs.gitlab.com/ce/api/protected_tags.html
|
6
|
+
module ProtectedTags
|
7
|
+
# Gets a list of protected tags from a project
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.protected_tags(1)
|
11
|
+
#
|
12
|
+
# @param [Integer, String] project(required) The ID or name of a project.
|
13
|
+
# @option options [Integer] :page The page number.
|
14
|
+
# @option options [Integer] :per_page The number of results per page.
|
15
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of all protected tags requested
|
16
|
+
def protected_tags(project, options = {})
|
17
|
+
get("/projects/#{url_encode project}/protected_tags", query: options)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Gets a single protected tag or wildcard protected tag.
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# Gitlab.protected_tag(1, 'release-1-0')
|
24
|
+
#
|
25
|
+
# @param [Integer, String] project(required) The ID or name of a project.
|
26
|
+
# @param [String] name(required) The name of the tag or wildcard
|
27
|
+
# @return <Gitlab::ObjectifiedHash] Information about the requested protected tag
|
28
|
+
def protected_tag(project, name)
|
29
|
+
get("/projects/#{url_encode project}/protected_tags/#{name}")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Protects a single repository tag or several project repository tags using a wildcard protected tag.
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# Gitlab.protect_repository_tag(1, 'release-1-0')
|
36
|
+
# Gitlab.protect_repository_tag(1, 'release-1-0', create_access_level: 30)
|
37
|
+
#
|
38
|
+
# @param [Integer, String] project(required) The ID or name of a project.
|
39
|
+
# @param [String] name(required) The name of the tag or wildcard
|
40
|
+
# @option options [Integer] :create_access_level Access levels allowed to create (defaults: 40, maintainer access level)
|
41
|
+
# @return <Gitlab::ObjectifiedHash] Information about the protected repository tag
|
42
|
+
def protect_repository_tag(project, name, options = {})
|
43
|
+
body = { name: name }.merge(options)
|
44
|
+
post("/projects/#{url_encode project}/protected_tags", body: body)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Unprotects the given protected tag or wildcard protected tag.
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# Gitlab.unprotect_repository_tag(1, 'release-1-0')
|
51
|
+
#
|
52
|
+
# @param [Integer, String] project(required) The ID or name of a project.
|
53
|
+
# @param [String] name(required) The name of the tag or wildcard
|
54
|
+
# @return [nil] This API call returns an empty response body.
|
55
|
+
def unprotect_repository_tag(project, name)
|
56
|
+
delete("/projects/#{url_encode project}/protected_tags/#{name}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to remote mirrors.
|
5
|
+
# @see https://docs.gitlab.com/ee/api/remote_mirrors.html
|
6
|
+
module RemoteMirrors
|
7
|
+
# List a project's remote mirrors
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.remote_mirrors(42)
|
11
|
+
# Gitlab.remote_mirrors('gitlab-org/gitlab')
|
12
|
+
#
|
13
|
+
# @param [Integer, String] project The ID or name of a project.
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
15
|
+
def remote_mirrors(project)
|
16
|
+
get("/projects/#{url_encode project}/remote_mirrors")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Create a remote mirror
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# Gitlab.create_remote_mirror(42, 'https://mirror-bot@gitlab.com/gitlab-org/gitlab.git', enabled: true)
|
23
|
+
#
|
24
|
+
# @param [Integer, String] project The ID or name of a project.
|
25
|
+
# @param [String] url The full URL of the remote repository.
|
26
|
+
# @param [Hash] options A customizable set of options.
|
27
|
+
# @option options [Boolean] :enabled Determines if the mirror is enabled.
|
28
|
+
# @option options [Boolean] :only_protected_branches Determines if only protected branches are mirrored.
|
29
|
+
# @option options [Boolean] :keep_divergent_refs Determines if divergent refs are skipped.
|
30
|
+
# @return [Gitlab::ObjectifiedHash]
|
31
|
+
def create_remote_mirror(project, url, options = {})
|
32
|
+
post("/projects/#{url_encode project}/remote_mirrors", body: options.merge(url: url))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Update a remote mirror's attributes
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# Gitlab.edit_remote_mirror(42, 66, only_protected_branches: true)
|
39
|
+
#
|
40
|
+
# @param [Integer, String] project The ID or name of a project.
|
41
|
+
# @param [Integer] id The ID of the remote mirror.
|
42
|
+
# @param [Hash] options A customizable set of options.
|
43
|
+
# @option options [Boolean] :enabled Determines if the mirror is enabled.
|
44
|
+
# @option options [Boolean] :only_protected_branches Determines if only protected branches are mirrored.
|
45
|
+
# @option options [Boolean] :keep_divergent_refs Determines if divergent refs are skipped.
|
46
|
+
# @return [Gitlab::ObjectifiedHash]
|
47
|
+
def edit_remote_mirror(project, id, options = {})
|
48
|
+
put("/projects/#{url_encode project}/remote_mirrors/#{id}", body: options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|