gitlab 4.12.0 → 4.20.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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +24 -16
- data/lib/gitlab/api.rb +2 -0
- data/lib/gitlab/cli.rb +6 -5
- data/lib/gitlab/cli_helpers.rb +10 -16
- data/lib/gitlab/client/build_variables.rb +17 -12
- data/lib/gitlab/client/commits.rb +42 -5
- data/lib/gitlab/client/container_registry.rb +1 -1
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/epics.rb +73 -0
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_labels.rb +1 -1
- data/lib/gitlab/client/groups.rb +247 -2
- data/lib/gitlab/client/issue_links.rb +48 -0
- data/lib/gitlab/client/issues.rb +12 -1
- data/lib/gitlab/client/jobs.rb +91 -8
- data/lib/gitlab/client/keys.rb +11 -0
- data/lib/gitlab/client/labels.rb +1 -1
- data/lib/gitlab/client/merge_request_approvals.rb +155 -2
- data/lib/gitlab/client/merge_requests.rb +76 -4
- data/lib/gitlab/client/merge_trains.rb +55 -0
- data/lib/gitlab/client/notes.rb +27 -0
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/pipeline_schedules.rb +16 -4
- data/lib/gitlab/client/pipelines.rb +37 -0
- data/lib/gitlab/client/project_exports.rb +54 -0
- data/lib/gitlab/client/project_releases.rb +11 -0
- data/lib/gitlab/client/projects.rb +119 -7
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +56 -1
- data/lib/gitlab/client/repository_files.rb +16 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +126 -21
- data/lib/gitlab/client/search.rb +5 -1
- data/lib/gitlab/client/user_snippets.rb +114 -0
- data/lib/gitlab/client/users.rb +267 -12
- data/lib/gitlab/client.rb +16 -2
- data/lib/gitlab/configuration.rb +1 -1
- data/lib/gitlab/error.rb +36 -1
- data/lib/gitlab/headers/page_links.rb +37 -0
- data/lib/gitlab/headers/total.rb +29 -0
- data/lib/gitlab/help.rb +8 -8
- data/lib/gitlab/objectified_hash.rb +23 -7
- data/lib/gitlab/paginated_response.rb +29 -40
- data/lib/gitlab/request.rb +35 -21
- data/lib/gitlab/shell_history.rb +2 -2
- data/lib/gitlab/version.rb +1 -1
- data/lib/gitlab.rb +17 -6
- metadata +24 -48
- data/lib/gitlab/page_links.rb +0 -35
|
@@ -75,5 +75,16 @@ class Gitlab::Client
|
|
|
75
75
|
def delete_project_release(project, tag_name)
|
|
76
76
|
delete("/projects/#{url_encode project}/releases/#{tag_name}")
|
|
77
77
|
end
|
|
78
|
+
|
|
79
|
+
# Gets Latest Release
|
|
80
|
+
#
|
|
81
|
+
# @example
|
|
82
|
+
# Gitlab.project_latest_release(5)
|
|
83
|
+
#
|
|
84
|
+
# @param [Integer, String] project The ID or name of a project
|
|
85
|
+
# @return [Gitlab::ObjectifiedHash] Information about the release
|
|
86
|
+
def project_latest_release(project)
|
|
87
|
+
get("/projects/#{url_encode project}/releases/permalink/latest")
|
|
88
|
+
end
|
|
78
89
|
end
|
|
79
90
|
end
|
|
@@ -44,9 +44,12 @@ class Gitlab::Client
|
|
|
44
44
|
# Gitlab.project('gitlab')
|
|
45
45
|
#
|
|
46
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)
|
|
47
50
|
# @return [Gitlab::ObjectifiedHash]
|
|
48
|
-
def project(id)
|
|
49
|
-
get("/projects/#{url_encode id}")
|
|
51
|
+
def project(id, options = {})
|
|
52
|
+
get("/projects/#{url_encode id}", query: options)
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
# Creates a new project.
|
|
@@ -102,6 +105,22 @@ class Gitlab::Client
|
|
|
102
105
|
get("/projects/#{url_encode project}/members", query: options)
|
|
103
106
|
end
|
|
104
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
|
+
|
|
105
124
|
# Gets a project team member.
|
|
106
125
|
#
|
|
107
126
|
# @example
|
|
@@ -380,6 +399,20 @@ class Gitlab::Client
|
|
|
380
399
|
post("/projects/#{url_encode project}/deploy_keys/#{key}/disable", body: { id: project, key_id: key })
|
|
381
400
|
end
|
|
382
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
|
+
|
|
383
416
|
# Deletes a deploy key from project.
|
|
384
417
|
#
|
|
385
418
|
# @example
|
|
@@ -505,6 +538,25 @@ class Gitlab::Client
|
|
|
505
538
|
delete("/projects/#{url_encode id}/star")
|
|
506
539
|
end
|
|
507
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
|
+
|
|
508
560
|
# Get a list of visible projects for the given user.
|
|
509
561
|
# @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
|
|
510
562
|
#
|
|
@@ -529,14 +581,13 @@ class Gitlab::Client
|
|
|
529
581
|
# @see https://docs.gitlab.com/ee/api/projects.html#upload-a-file
|
|
530
582
|
#
|
|
531
583
|
# @example
|
|
532
|
-
# Gitlab.upload_file(1,
|
|
533
|
-
# File.open('myfile') { |file| Gitlab.upload_file(1, file) }
|
|
584
|
+
# Gitlab.upload_file(1, '/full/path/to/avatar.jpg')
|
|
534
585
|
#
|
|
535
586
|
# @param [Integer, String] id The ID or path of a project.
|
|
536
|
-
# @param [
|
|
587
|
+
# @param [String] file_fullpath The fullpath of the file you are interested to upload.
|
|
537
588
|
# @return [Gitlab::ObjectifiedHash]
|
|
538
|
-
def upload_file(id,
|
|
539
|
-
post("/projects/#{url_encode id}/uploads", body: { file:
|
|
589
|
+
def upload_file(id, file_fullpath)
|
|
590
|
+
post("/projects/#{url_encode id}/uploads", body: { file: File.open(file_fullpath, 'r') })
|
|
540
591
|
end
|
|
541
592
|
|
|
542
593
|
# Get all project templates of a particular type
|
|
@@ -592,5 +643,66 @@ class Gitlab::Client
|
|
|
592
643
|
def unarchive_project(id)
|
|
593
644
|
post("/projects/#{url_encode id}/unarchive")
|
|
594
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
|
|
595
707
|
end
|
|
596
708
|
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
|
|
@@ -13,7 +13,8 @@ class Gitlab::Client
|
|
|
13
13
|
# @param [Integer, String] project The ID or name of a project.
|
|
14
14
|
# @param [Hash] options A customizable set of options.
|
|
15
15
|
# @option options [String] :path The path inside repository.
|
|
16
|
-
# @option options [String] :
|
|
16
|
+
# @option options [String] :ref The name of a repository branch or tag.
|
|
17
|
+
# @option options [Integer] :per_page Number of results to show per page (default = 20)
|
|
17
18
|
# @return [Gitlab::ObjectifiedHash]
|
|
18
19
|
def tree(project, options = {})
|
|
19
20
|
get("/projects/#{url_encode project}/repository/tree", query: options)
|
|
@@ -71,5 +72,59 @@ class Gitlab::Client
|
|
|
71
72
|
def merge_base(project, refs)
|
|
72
73
|
get("/projects/#{url_encode project}/repository/merge_base", query: { refs: refs })
|
|
73
74
|
end
|
|
75
|
+
|
|
76
|
+
# Get project repository contributors.
|
|
77
|
+
#
|
|
78
|
+
# @example
|
|
79
|
+
# Gitlab.contributors(42)
|
|
80
|
+
# Gitlab.contributors(42, { order: 'name' })
|
|
81
|
+
#
|
|
82
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
83
|
+
# @param [Hash] options A customizable set of options.
|
|
84
|
+
# @option options [String] :order_by Order by name, email or commits (default = commits).
|
|
85
|
+
# @option options [String] :sort Sort order asc or desc (default = asc).
|
|
86
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
87
|
+
def contributors(project, options = {})
|
|
88
|
+
get("/projects/#{url_encode project}/repository/contributors", query: options)
|
|
89
|
+
end
|
|
90
|
+
alias repo_contributors contributors
|
|
91
|
+
|
|
92
|
+
# Generate changelog data
|
|
93
|
+
#
|
|
94
|
+
# @example
|
|
95
|
+
# Gitlab.generate_changelog(42, 'v1.0.0')
|
|
96
|
+
# Gitlab.generate_changelog(42, 'v1.0.0', branch: 'main')
|
|
97
|
+
#
|
|
98
|
+
# @param [Integer, String] project The ID or name of a project
|
|
99
|
+
# @param [String] version The version to generate the changelog for
|
|
100
|
+
# @param [Hash] options A customizable set of options
|
|
101
|
+
# @option options [String] :from The start of the range of commits (SHA)
|
|
102
|
+
# @option options [String] :to The end of the range of commits (as a SHA) to use for the changelog
|
|
103
|
+
# @option options [String] :date The date and time of the release, defaults to the current time
|
|
104
|
+
# @option options [String] :branch The branch to commit the changelog changes to
|
|
105
|
+
# @option options [String] :trailer The Git trailer to use for including commits
|
|
106
|
+
# @option options [String] :file The file to commit the changes to
|
|
107
|
+
# @option options [String] :message The commit message to produce when committing the changes
|
|
108
|
+
# @return [bool]
|
|
109
|
+
def generate_changelog(project, version, options = {})
|
|
110
|
+
post("/projects/#{url_encode project}/repository/changelog", body: options.merge(version: version))
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Get changelog data
|
|
114
|
+
#
|
|
115
|
+
# @example
|
|
116
|
+
# Gitlab.get_changelog(42, 'v1.0.0')
|
|
117
|
+
#
|
|
118
|
+
# @param [Integer, String] project The ID or name of a project
|
|
119
|
+
# @param [String] version The version to generate the changelog for
|
|
120
|
+
# @param [Hash] options A customizable set of options
|
|
121
|
+
# @option options [String] :from The start of the range of commits (SHA)
|
|
122
|
+
# @option options [String] :to The end of the range of commits (as a SHA) to use for the changelog
|
|
123
|
+
# @option options [String] :date The date and time of the release, defaults to the current time
|
|
124
|
+
# @option options [String] :trailer The Git trailer to use for including commits
|
|
125
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
126
|
+
def get_changelog(project, version, options = {})
|
|
127
|
+
get("/projects/#{url_encode project}/repository/changelog", body: options.merge(version: version))
|
|
128
|
+
end
|
|
74
129
|
end
|
|
75
130
|
end
|
|
@@ -25,6 +25,22 @@ class Gitlab::Client
|
|
|
25
25
|
end
|
|
26
26
|
alias repo_file_contents file_contents
|
|
27
27
|
|
|
28
|
+
# Get file blame from repository
|
|
29
|
+
#
|
|
30
|
+
# @example
|
|
31
|
+
# Gitlab.get_file_blame(42, "README.md", "master")
|
|
32
|
+
#
|
|
33
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
34
|
+
# @param [String] file_path The full path of the file.
|
|
35
|
+
# @param [String] ref The name of branch, tag or commit.
|
|
36
|
+
# @return [Gitlab::ObjectifiedHash]
|
|
37
|
+
#
|
|
38
|
+
def get_file_blame(project, file_path, ref)
|
|
39
|
+
get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}/blame", query: {
|
|
40
|
+
ref: ref
|
|
41
|
+
})
|
|
42
|
+
end
|
|
43
|
+
|
|
28
44
|
# Gets a repository file.
|
|
29
45
|
#
|
|
30
46
|
# @example
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Gitlab::Client
|
|
4
|
+
# Defines methods related to resource state events.
|
|
5
|
+
# @see https://docs.gitlab.com/ee/api/resource_state_events.html
|
|
6
|
+
module ResourceStateEvents
|
|
7
|
+
# Gets a list of all state events for a single issue.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Gitlab.issue_state_events(5, 42)
|
|
11
|
+
#
|
|
12
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
13
|
+
# @param [Integer] issue_iid The IID of an issue.
|
|
14
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
15
|
+
def issue_state_events(project, issue_iid)
|
|
16
|
+
get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_state_events")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns a single state event for a specific project issue
|
|
20
|
+
#
|
|
21
|
+
# @example
|
|
22
|
+
# Gitlab.issue_state_event(5, 42, 1)
|
|
23
|
+
#
|
|
24
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
25
|
+
# @param [Integer] issue_iid The IID of an issue.
|
|
26
|
+
# @param [Integer] id The ID of a resource event.
|
|
27
|
+
# @return Gitlab::ObjectifiedHash
|
|
28
|
+
def issue_state_event(project, issue_iid, id)
|
|
29
|
+
get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_state_events/#{id}")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Gets a list of all state events for a single merge request.
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# Gitlab.merge_request_state_events(5, 42)
|
|
36
|
+
#
|
|
37
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
38
|
+
# @param [Integer] merge_request_iid The IID of a merge request.
|
|
39
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
40
|
+
def merge_request_state_events(project, merge_request_iid)
|
|
41
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_state_events")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Returns a single state event for a specific project merge request
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# Gitlab.merge_request_state_event(5, 42, 1)
|
|
48
|
+
#
|
|
49
|
+
# @param [Integer, String] project The ID or name of a project.
|
|
50
|
+
# @param [Integer] merge_request_iid The IID of an merge request.
|
|
51
|
+
# @param [Integer] id The ID of a state event.
|
|
52
|
+
# @return Gitlab::ObjectifiedHash
|
|
53
|
+
def merge_request_state_event(project, merge_request_iid, id)
|
|
54
|
+
get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_state_events/#{id}")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -9,11 +9,13 @@ class Gitlab::Client
|
|
|
9
9
|
#
|
|
10
10
|
# @example
|
|
11
11
|
# Gitlab.runners
|
|
12
|
-
# Gitlab.runners(:active)
|
|
13
|
-
# Gitlab.runners(:
|
|
12
|
+
# Gitlab.runners(type: 'instance_type', status: 'active')
|
|
13
|
+
# Gitlab.runners(tag_list: 'tag1,tag2')
|
|
14
14
|
#
|
|
15
15
|
# @param [Hash] options A customizable set of options.
|
|
16
|
-
# @option options [String] :
|
|
16
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
|
17
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
|
18
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
|
17
19
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
18
20
|
def runners(options = {})
|
|
19
21
|
get('/runners', query: options)
|
|
@@ -24,9 +26,13 @@ class Gitlab::Client
|
|
|
24
26
|
#
|
|
25
27
|
# @example
|
|
26
28
|
# Gitlab.all_runners
|
|
29
|
+
# Gitlab.all_runners(type: 'instance_type', status: 'active')
|
|
30
|
+
# Gitlab.all_runners(tag_list: 'tag1,tag2')
|
|
27
31
|
#
|
|
28
32
|
# @param [Hash] options A customizable set of options.
|
|
29
|
-
# @option options [String] :
|
|
33
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
|
34
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
|
35
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
|
30
36
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
31
37
|
def all_runners(options = {})
|
|
32
38
|
get('/runners/all', query: options)
|
|
@@ -50,15 +56,19 @@ class Gitlab::Client
|
|
|
50
56
|
# @example
|
|
51
57
|
# Gitlab.update_runner(42, { description: 'Awesome runner' })
|
|
52
58
|
# Gitlab.update_runner(42, { active: false })
|
|
53
|
-
# Gitlab.update_runner(42, { tag_list: [ 'awesome', 'runner' ] })
|
|
54
59
|
#
|
|
55
60
|
# @param [Integer, String] id The ID of a runner
|
|
56
61
|
# @param [Hash] options A customizable set of options.
|
|
57
|
-
# @option options [String] :
|
|
58
|
-
# @option options [
|
|
62
|
+
# @option options [String] :description(optional) The description of a runner
|
|
63
|
+
# @option options [Boolean] :active(optional) The state of a runner; can be set to true or false
|
|
64
|
+
# @option options [String] :tag_list(optional) The list of tags for a runner; put array of tags, that should be finally assigned to a runner(separated by comma)
|
|
65
|
+
# @option options [Boolean] :run_untagged(optional) Flag indicating the runner can execute untagged jobs
|
|
66
|
+
# @option options [Boolean] :locked(optional) Flag indicating the runner is locked
|
|
67
|
+
# @option options [String] :access_level(optional) The access_level of the runner; not_protected or ref_protected
|
|
68
|
+
# @option options [Integer] :maximum_timeout(optional) Maximum timeout set when this runner will handle the job
|
|
59
69
|
# @return <Gitlab::ObjectifiedHash>
|
|
60
70
|
def update_runner(id, options = {})
|
|
61
|
-
put("/runners/#{id}",
|
|
71
|
+
put("/runners/#{id}", body: options)
|
|
62
72
|
end
|
|
63
73
|
|
|
64
74
|
# Remove a runner.
|
|
@@ -68,19 +78,23 @@ class Gitlab::Client
|
|
|
68
78
|
# Gitlab.delete_runner(42)
|
|
69
79
|
#
|
|
70
80
|
# @param [Integer, String] id The ID of a runner
|
|
71
|
-
# @return
|
|
81
|
+
# @return [nil] This API call returns an empty response body.
|
|
72
82
|
def delete_runner(id)
|
|
73
83
|
delete("/runners/#{id}")
|
|
74
84
|
end
|
|
75
85
|
|
|
76
|
-
#
|
|
86
|
+
# List jobs that are being processed or were processed by specified runner.
|
|
77
87
|
#
|
|
78
88
|
# @example
|
|
79
89
|
# Gitlab.runner_jobs(1)
|
|
90
|
+
# Gitlab.runner_jobs(1, status: 'success')
|
|
91
|
+
# Gitlab.runner_jobs(1, sort: 'desc')
|
|
80
92
|
#
|
|
81
93
|
# @param [Integer] id The ID of a runner.
|
|
82
94
|
# @param [Hash] options A customizable set of options.
|
|
83
|
-
# @option options [String] :status Status of the job; one of: running, success, failed, canceled
|
|
95
|
+
# @option options [String] :status(optional) Status of the job; one of: running, success, failed, canceled
|
|
96
|
+
# @option options [String] :order_by(optional) Order jobs by id.
|
|
97
|
+
# @option options [String] :sort(optional) Sort jobs in asc or desc order (default: desc)
|
|
84
98
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
85
99
|
def runner_jobs(runner_id, options = {})
|
|
86
100
|
get("/runners/#{url_encode runner_id}/jobs", query: options)
|
|
@@ -91,11 +105,17 @@ class Gitlab::Client
|
|
|
91
105
|
#
|
|
92
106
|
# @example
|
|
93
107
|
# Gitlab.project_runners(42)
|
|
108
|
+
# Gitlab.project_runners(42, type: 'instance_type', status: 'active')
|
|
109
|
+
# Gitlab.project_runners(42, tag_list: 'tag1,tag2')
|
|
94
110
|
#
|
|
95
111
|
# @param [Integer, String] id The ID or name of a project.
|
|
112
|
+
# @param [Hash] options A customizable set of options.
|
|
113
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
|
114
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
|
115
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
|
96
116
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
97
|
-
def project_runners(project_id)
|
|
98
|
-
get("/projects/#{url_encode project_id}/runners")
|
|
117
|
+
def project_runners(project_id, options = {})
|
|
118
|
+
get("/projects/#{url_encode project_id}/runners", query: options)
|
|
99
119
|
end
|
|
100
120
|
|
|
101
121
|
# Enable an available specific runner in the project.
|
|
@@ -125,21 +145,39 @@ class Gitlab::Client
|
|
|
125
145
|
delete("/projects/#{url_encode id}/runners/#{runner_id}")
|
|
126
146
|
end
|
|
127
147
|
|
|
148
|
+
# List all runners (specific and shared) available in the group as well its ancestor groups. Shared runners are listed if at least one shared runner is defined.
|
|
149
|
+
# @see https://docs.gitlab.com/ee/api/runners.html#list-groups-runners
|
|
150
|
+
#
|
|
151
|
+
# @example
|
|
152
|
+
# Gitlab.group_runners(9)
|
|
153
|
+
# Gitlab.group_runners(9, type: 'instance_type', status: 'active')
|
|
154
|
+
# Gitlab.group_runners(9, tag_list: 'tag1,tag2')
|
|
155
|
+
#
|
|
156
|
+
# @param [Integer, String] id The ID or name of a project.
|
|
157
|
+
# @param [Hash] options A customizable set of options.
|
|
158
|
+
# @option options [String] :type(optional) The type of runners to show, one of: instance_type, group_type, project_type
|
|
159
|
+
# @option options [String] :status(optional) The status of runners to show, one of: active, paused, online, offline
|
|
160
|
+
# @option options [String] :tag_list(optional) List of the runners tags (separated by comma)
|
|
161
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
|
162
|
+
def group_runners(group, options = {})
|
|
163
|
+
get("/groups/#{url_encode group}/runners", query: options)
|
|
164
|
+
end
|
|
165
|
+
|
|
128
166
|
# Register a new Runner for the instance.
|
|
129
167
|
#
|
|
130
168
|
# @example
|
|
131
169
|
# Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e')
|
|
132
170
|
# Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e', description: 'Some Description', active: true, locked: false)
|
|
133
171
|
#
|
|
134
|
-
# @param [String] token Registration token.
|
|
172
|
+
# @param [String] token(required) Registration token.
|
|
135
173
|
# @param [Hash] options A customizable set of options.
|
|
136
|
-
# @option options [String] :description Runner description.
|
|
137
|
-
# @option options [Hash] :info Runner metadata.
|
|
138
|
-
# @option options [Boolean] :active Whether the Runner is active.
|
|
139
|
-
# @option options [Boolean] :locked Whether the Runner should be locked for current project.
|
|
140
|
-
# @option options [Boolean] :run_untagged Whether the Runner should handle untagged jobs.
|
|
141
|
-
# @option options [Array<String>] :tag_list List of Runner tags.
|
|
142
|
-
# @option options [Integer] :maximum_timeout Maximum timeout set when this Runner will handle the job.
|
|
174
|
+
# @option options [String] :description(optional) Runner description.
|
|
175
|
+
# @option options [Hash] :info(optional) Runner metadata.
|
|
176
|
+
# @option options [Boolean] :active(optional) Whether the Runner is active.
|
|
177
|
+
# @option options [Boolean] :locked(optional) Whether the Runner should be locked for current project.
|
|
178
|
+
# @option options [Boolean] :run_untagged(optional) Whether the Runner should handle untagged jobs.
|
|
179
|
+
# @option options [Array<String>] :tag_list(optional) List of Runner tags.
|
|
180
|
+
# @option options [Integer] :maximum_timeout(optional) Maximum timeout set when this Runner will handle the job.
|
|
143
181
|
# @return <Gitlab::ObjectifiedHash> Response against runner registration
|
|
144
182
|
def register_runner(token, options = {})
|
|
145
183
|
body = { token: token }.merge(options)
|
|
@@ -169,5 +207,72 @@ class Gitlab::Client
|
|
|
169
207
|
body = { token: token }
|
|
170
208
|
post('/runners/verify', body: body)
|
|
171
209
|
end
|
|
210
|
+
|
|
211
|
+
# Creates a new group runner with the new Gitlab approach (v16.0+) and returns the id/token information
|
|
212
|
+
# https://docs.gitlab.com/ee/api/users.html#create-a-runner
|
|
213
|
+
# You must use an access token with the create_runner scope
|
|
214
|
+
#
|
|
215
|
+
# @example
|
|
216
|
+
# Gitlab.create_group_runner(9, tag_list: ['one', 'two'])
|
|
217
|
+
# Gitlab.create_group_runner(9, paused: false, description: 'A note', run_untagged: true)
|
|
218
|
+
#
|
|
219
|
+
# @param [String] group(required) Group ID.
|
|
220
|
+
# @param [Hash] options A customizable set of options.
|
|
221
|
+
# @return <Gitlab::ObjectifiedHash> Response against runner registration
|
|
222
|
+
def create_group_runner(group, options = {})
|
|
223
|
+
create_runner({ runner_type: 'group_type', group_id: group }.merge(options))
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Creates a new project runner with the new Gitlab approach (v16.0+) and returns the id/token information
|
|
227
|
+
# https://docs.gitlab.com/ee/api/users.html#create-a-runner
|
|
228
|
+
# You must use an access token with the create_runner scope
|
|
229
|
+
#
|
|
230
|
+
# @example
|
|
231
|
+
# Gitlab.create_project_runner(12, tag_list: ['one', 'two'])
|
|
232
|
+
# Gitlab.create_project_runner(12, paused: false, description: 'A note', run_untagged: true)
|
|
233
|
+
#
|
|
234
|
+
# @param [String] project(required) Project ID.
|
|
235
|
+
# @param [Hash] options A customizable set of options.
|
|
236
|
+
# @return <Gitlab::ObjectifiedHash> Response against runner registration
|
|
237
|
+
def create_project_runner(project, options = {})
|
|
238
|
+
create_runner({ runner_type: 'project_type', project_id: project }.merge(options))
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Creates a new instance runner with the new Gitlab approach (v16.0+) and returns the id/token information
|
|
242
|
+
# You must be an administrator of the GitLab instance
|
|
243
|
+
# You must use an access token with the create_runner scope
|
|
244
|
+
# https://docs.gitlab.com/ee/api/users.html#create-a-runner
|
|
245
|
+
#
|
|
246
|
+
# @example
|
|
247
|
+
# Gitlab.create_instance_runner(tag_list: ['one', 'two'])
|
|
248
|
+
# Gitlab.create_instance_runner(paused: false, description: 'A note', run_untagged: true)
|
|
249
|
+
#
|
|
250
|
+
# @param [String] group(required) Project ID.
|
|
251
|
+
# @param [Hash] options A customizable set of options.
|
|
252
|
+
# @return <Gitlab::ObjectifiedHash> Response against runner registration
|
|
253
|
+
def create_instance_runner(options = {})
|
|
254
|
+
create_runner({ runner_type: 'instance_type' }.merge(options))
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
private
|
|
258
|
+
|
|
259
|
+
# Creates a runner linked to the current user.
|
|
260
|
+
# You must use an access token with the create_runner scope
|
|
261
|
+
# https://docs.gitlab.com/ee/api/users.html#create-a-runner
|
|
262
|
+
#
|
|
263
|
+
# @param [Hash] options(required) A customizable set of options.
|
|
264
|
+
# @option options [String] :description(optional) Runner description.
|
|
265
|
+
# @option options [Hash] :info(optional) Runner metadata.
|
|
266
|
+
# @option options [Boolean] :paused(optional) Whether the Runner ignores new jobs.
|
|
267
|
+
# @option options [Boolean] :locked(optional) Whether the Runner should be locked for current project.
|
|
268
|
+
# @option options [Boolean] :run_untagged(optional) Whether the Runner should handle untagged jobs.
|
|
269
|
+
# @option options [Array<String>] :tag_list(optional) List of Runner tags.
|
|
270
|
+
# @option options [String] :access_level(optional) Access level of the runner; not_protected or ref_protected.
|
|
271
|
+
# @option options [Integer] :maximum_timeout(optional) Maximum timeout set when this Runner will handle the job.
|
|
272
|
+
# @option options [String] :maintenance_note(optional) Free-form maintenance notes for the runner (1024 characters).
|
|
273
|
+
# @return <Gitlab::ObjectifiedHash> Response against runner registration {"id": 1, "token": foo "token_expires_at": null}
|
|
274
|
+
def create_runner(options)
|
|
275
|
+
post('/user/runners', body: options)
|
|
276
|
+
end
|
|
172
277
|
end
|
|
173
278
|
end
|
data/lib/gitlab/client/search.rb
CHANGED
|
@@ -54,8 +54,12 @@ class Gitlab::Client
|
|
|
54
54
|
# @param [String] scope The scope to search in. Currently these scopes are supported: issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs.
|
|
55
55
|
# @param [String] search The search query.
|
|
56
56
|
# @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
|
|
57
|
-
def search_in_project(project, scope, search)
|
|
57
|
+
def search_in_project(project, scope, search, ref = nil)
|
|
58
58
|
options = { scope: scope, search: search }
|
|
59
|
+
|
|
60
|
+
# Add ref filter if provided - backward compatible with main project
|
|
61
|
+
options[:ref] = ref unless ref.nil?
|
|
62
|
+
|
|
59
63
|
get("/projects/#{url_encode project}/search", query: options)
|
|
60
64
|
end
|
|
61
65
|
end
|