gitlab 4.16.1 → 4.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gitlab/api.rb +2 -0
- data/lib/gitlab/cli.rb +6 -5
- data/lib/gitlab/cli_helpers.rb +2 -2
- data/lib/gitlab/client/build_variables.rb +3 -2
- data/lib/gitlab/client/commits.rb +24 -3
- data/lib/gitlab/client/container_registry.rb +1 -1
- data/lib/gitlab/client/group_badges.rb +88 -0
- data/lib/gitlab/client/group_labels.rb +1 -1
- data/lib/gitlab/client/groups.rb +65 -0
- data/lib/gitlab/client/jobs.rb +77 -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 +84 -0
- data/lib/gitlab/client/merge_requests.rb +34 -1
- data/lib/gitlab/client/pipeline_schedules.rb +16 -4
- data/lib/gitlab/client/pipelines.rb +12 -0
- data/lib/gitlab/client/projects.rb +101 -2
- data/lib/gitlab/client/remote_mirrors.rb +51 -0
- data/lib/gitlab/client/repositories.rb +21 -0
- data/lib/gitlab/client/resource_state_events.rb +57 -0
- data/lib/gitlab/client/runners.rb +59 -21
- data/lib/gitlab/client/users.rb +103 -0
- data/lib/gitlab/client.rb +4 -1
- data/lib/gitlab/error.rb +11 -0
- data/lib/gitlab/help.rb +7 -8
- data/lib/gitlab/paginated_response.rb +2 -2
- data/lib/gitlab/request.rb +18 -8
- data/lib/gitlab/shell_history.rb +2 -2
- data/lib/gitlab/version.rb +1 -1
- data/lib/gitlab.rb +12 -5
- metadata +8 -17
@@ -44,7 +44,7 @@ class Gitlab::Client
|
|
44
44
|
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
45
45
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
46
46
|
def create_pipeline_schedule(project, options = {})
|
47
|
-
post("/projects/#{url_encode project}/pipeline_schedules",
|
47
|
+
post("/projects/#{url_encode project}/pipeline_schedules", body: options)
|
48
48
|
end
|
49
49
|
|
50
50
|
# Updates the pipeline schedule of a project.
|
@@ -62,7 +62,7 @@ class Gitlab::Client
|
|
62
62
|
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
|
63
63
|
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
|
64
64
|
def edit_pipeline_schedule(project, pipeline_schedule_id, options = {})
|
65
|
-
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}",
|
65
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", body: options)
|
66
66
|
end
|
67
67
|
|
68
68
|
# Take ownership of a pipeline schedule.
|
@@ -77,6 +77,18 @@ class Gitlab::Client
|
|
77
77
|
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
|
78
78
|
end
|
79
79
|
|
80
|
+
# Run a scheduled pipeline immediately.
|
81
|
+
#
|
82
|
+
# @example
|
83
|
+
# Gitlab.run_pipeline_schedule(5, 1)
|
84
|
+
#
|
85
|
+
# @param [Integer, String] project The ID or name of a project.
|
86
|
+
# @param [Integer] trigger_id The pipeline schedule ID.
|
87
|
+
# @return [Gitlab::ObjectifiedHash] Pipeline created message.
|
88
|
+
def run_pipeline_schedule(project, pipeline_schedule_id)
|
89
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/play")
|
90
|
+
end
|
91
|
+
|
80
92
|
# Delete a pipeline schedule.
|
81
93
|
#
|
82
94
|
# @example
|
@@ -101,7 +113,7 @@ class Gitlab::Client
|
|
101
113
|
# @option options [String] :value The value of a variable
|
102
114
|
# @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
|
103
115
|
def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {})
|
104
|
-
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables",
|
116
|
+
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", body: options)
|
105
117
|
end
|
106
118
|
|
107
119
|
# Updates the variable of a pipeline schedule.
|
@@ -116,7 +128,7 @@ class Gitlab::Client
|
|
116
128
|
# @option options [String] :value The value of a variable.
|
117
129
|
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
|
118
130
|
def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options = {})
|
119
|
-
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}",
|
131
|
+
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", body: options)
|
120
132
|
end
|
121
133
|
|
122
134
|
# Delete the variable of a pipeline schedule
|
@@ -31,6 +31,18 @@ class Gitlab::Client
|
|
31
31
|
get("/projects/#{url_encode project}/pipelines/#{id}")
|
32
32
|
end
|
33
33
|
|
34
|
+
# Gets a single pipeline's test report.
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# Gitlab.pipeline_test_report(5, 36)
|
38
|
+
#
|
39
|
+
# @param [Integer, String] project The ID or name of a project.
|
40
|
+
# @param [Integer] id The ID of a pipeline.
|
41
|
+
# @return [Gitlab::ObjectifiedHash]
|
42
|
+
def pipeline_test_report(project, id)
|
43
|
+
get("/projects/#{url_encode project}/pipelines/#{id}/test_report")
|
44
|
+
end
|
45
|
+
|
34
46
|
# Create a pipeline.
|
35
47
|
#
|
36
48
|
# @example
|
@@ -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
|
@@ -519,6 +538,25 @@ class Gitlab::Client
|
|
519
538
|
delete("/projects/#{url_encode id}/star")
|
520
539
|
end
|
521
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
|
+
|
522
560
|
# Get a list of visible projects for the given user.
|
523
561
|
# @see https://docs.gitlab.com/ee/api/projects.html#list-user-projects
|
524
562
|
#
|
@@ -605,5 +643,66 @@ class Gitlab::Client
|
|
605
643
|
def unarchive_project(id)
|
606
644
|
post("/projects/#{url_encode id}/unarchive")
|
607
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
|
608
707
|
end
|
609
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
|
@@ -88,5 +88,26 @@ class Gitlab::Client
|
|
88
88
|
get("/projects/#{url_encode project}/repository/contributors", query: options)
|
89
89
|
end
|
90
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
|
91
112
|
end
|
92
113
|
end
|
@@ -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)
|
data/lib/gitlab/client/users.rb
CHANGED
@@ -279,5 +279,108 @@ class Gitlab::Client
|
|
279
279
|
options[:search] = search
|
280
280
|
get('/users', query: options)
|
281
281
|
end
|
282
|
+
|
283
|
+
# Gets user custom_attributes.
|
284
|
+
#
|
285
|
+
# @example
|
286
|
+
# Gitlab.user_custom_attributes(2)
|
287
|
+
#
|
288
|
+
# @param [Integer] user_id The ID of a user.
|
289
|
+
# @return [Gitlab::ObjectifiedHash]
|
290
|
+
def user_custom_attributes(user_id)
|
291
|
+
get("/users/#{user_id}/custom_attributes")
|
292
|
+
end
|
293
|
+
|
294
|
+
# Gets single user custom_attribute.
|
295
|
+
#
|
296
|
+
# @example
|
297
|
+
# Gitlab.user_custom_attribute(key, 2)
|
298
|
+
#
|
299
|
+
# @param [String] key The custom_attributes key
|
300
|
+
# @param [Integer] user_id The ID of a user.
|
301
|
+
# @return [Gitlab::ObjectifiedHash]
|
302
|
+
def user_custom_attribute(key, user_id)
|
303
|
+
get("/users/#{user_id}/custom_attributes/#{key}")
|
304
|
+
end
|
305
|
+
|
306
|
+
# Creates a new custom_attribute
|
307
|
+
#
|
308
|
+
# @example
|
309
|
+
# Gitlab.add_custom_attribute('some_new_key', 'some_new_value', 2)
|
310
|
+
#
|
311
|
+
# @param [String] key The custom_attributes key
|
312
|
+
# @param [String] value The custom_attributes value
|
313
|
+
# @param [Integer] user_id The ID of a user.
|
314
|
+
# @return [Gitlab::ObjectifiedHash]
|
315
|
+
def add_user_custom_attribute(key, value, user_id)
|
316
|
+
url = "/users/#{user_id}/custom_attributes/#{key}"
|
317
|
+
put(url, body: { value: value })
|
318
|
+
end
|
319
|
+
|
320
|
+
# Delete custom_attribute
|
321
|
+
# Will delete a custom_attribute
|
322
|
+
#
|
323
|
+
# @example
|
324
|
+
# Gitlab.delete_user_custom_attribute('somekey', 2)
|
325
|
+
#
|
326
|
+
# @param [String] key The custom_attribute key to delete
|
327
|
+
# @param [Integer] user_id The ID of a user.
|
328
|
+
# @return [Boolean]
|
329
|
+
def delete_user_custom_attribute(key, user_id)
|
330
|
+
delete("/users/#{user_id}/custom_attributes/#{key}")
|
331
|
+
end
|
332
|
+
|
333
|
+
# Get all impersonation tokens for a user
|
334
|
+
#
|
335
|
+
# @example
|
336
|
+
# Gitlab.user_impersonation_tokens(1)
|
337
|
+
#
|
338
|
+
# @param [Integer] user_id The ID of the user.
|
339
|
+
# @param [String] state Filter impersonation tokens by state {}
|
340
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
341
|
+
def user_impersonation_tokens(user_id)
|
342
|
+
get("/users/#{user_id}/impersonation_tokens")
|
343
|
+
end
|
344
|
+
|
345
|
+
# Get impersonation token information
|
346
|
+
#
|
347
|
+
# @example
|
348
|
+
# Gitlab.user_impersonation_token(1, 1)
|
349
|
+
#
|
350
|
+
# @param [Integer] user_id The ID of the user.
|
351
|
+
# @param [Integer] impersonation_token_id ID of the impersonation token.
|
352
|
+
# @return [Gitlab::ObjectifiedHash]
|
353
|
+
def user_impersonation_token(user_id, impersonation_token_id)
|
354
|
+
get("/users/#{user_id}/impersonation_tokens/#{impersonation_token_id}")
|
355
|
+
end
|
356
|
+
|
357
|
+
# Create impersonation token
|
358
|
+
#
|
359
|
+
# @example
|
360
|
+
# Gitlab.create_user_impersonation_token(2, "token", ["api", "read_user"])
|
361
|
+
# Gitlab.create_user_impersonation_token(2, "token", ["api", "read_user"], "1970-01-01")
|
362
|
+
#
|
363
|
+
# @param [Integer] user_id The ID of the user.
|
364
|
+
# @param [String] name Name for impersonation token.
|
365
|
+
# @param [Array<String>] scopes Array of scopes for the impersonation token
|
366
|
+
# @param [String] expires_at Date for impersonation token expiration in ISO format.
|
367
|
+
# @return [Gitlab::ObjectifiedHash]
|
368
|
+
def create_user_impersonation_token(user_id, name, scopes, expires_at = nil)
|
369
|
+
body = { name: name, scopes: scopes }
|
370
|
+
body[:expires_at] = expires_at if expires_at
|
371
|
+
post("/users/#{user_id}/impersonation_tokens", body: body)
|
372
|
+
end
|
373
|
+
|
374
|
+
# Revoke an impersonation token
|
375
|
+
#
|
376
|
+
# @example
|
377
|
+
# Gitlab.revoke_user_impersonation_token(1, 1)
|
378
|
+
#
|
379
|
+
# @param [Integer] user_id The ID of the user.
|
380
|
+
# @param [Integer] impersonation_token_id ID of the impersonation token.
|
381
|
+
# @return [Gitlab::ObjectifiedHash]
|
382
|
+
def revoke_user_impersonation_token(user_id, impersonation_token_id)
|
383
|
+
delete("/users/#{user_id}/impersonation_tokens/#{impersonation_token_id}")
|
384
|
+
end
|
282
385
|
end
|
283
386
|
end
|
data/lib/gitlab/client.rb
CHANGED
@@ -23,6 +23,7 @@ module Gitlab
|
|
23
23
|
include Epics
|
24
24
|
include Events
|
25
25
|
include Features
|
26
|
+
include GroupBadges
|
26
27
|
include GroupBoards
|
27
28
|
include GroupLabels
|
28
29
|
include GroupMilestones
|
@@ -48,10 +49,12 @@ module Gitlab
|
|
48
49
|
include ProjectReleases
|
49
50
|
include Projects
|
50
51
|
include ProtectedTags
|
52
|
+
include RemoteMirrors
|
51
53
|
include Repositories
|
52
54
|
include RepositoryFiles
|
53
55
|
include RepositorySubmodules
|
54
56
|
include ResourceLabelEvents
|
57
|
+
include ResourceStateEvents
|
55
58
|
include Runners
|
56
59
|
include Search
|
57
60
|
include Services
|
@@ -80,7 +83,7 @@ module Gitlab
|
|
80
83
|
#
|
81
84
|
# @return [String]
|
82
85
|
def url_encode(url)
|
83
|
-
url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString
|
86
|
+
url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString
|
84
87
|
end
|
85
88
|
|
86
89
|
private
|
data/lib/gitlab/error.rb
CHANGED
@@ -34,6 +34,17 @@ module Gitlab
|
|
34
34
|
@response.parsed_response.message
|
35
35
|
end
|
36
36
|
|
37
|
+
# Additional error context returned by some API endpoints
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
def error_code
|
41
|
+
if @response.respond_to?(:error_code)
|
42
|
+
@response.error_code
|
43
|
+
else
|
44
|
+
''
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
37
48
|
private
|
38
49
|
|
39
50
|
# Human friendly message.
|