gitlab 4.10.0 → 4.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +26 -18
  4. data/lib/gitlab/api.rb +2 -0
  5. data/lib/gitlab/cli.rb +6 -8
  6. data/lib/gitlab/cli_helpers.rb +20 -25
  7. data/lib/gitlab/client/application_settings.rb +172 -0
  8. data/lib/gitlab/client/build_variables.rb +17 -12
  9. data/lib/gitlab/client/commits.rb +42 -5
  10. data/lib/gitlab/client/container_registry.rb +85 -0
  11. data/lib/gitlab/client/epic_issues.rb +23 -0
  12. data/lib/gitlab/client/epics.rb +73 -0
  13. data/lib/gitlab/client/group_badges.rb +88 -0
  14. data/lib/gitlab/client/group_labels.rb +1 -1
  15. data/lib/gitlab/client/groups.rb +153 -2
  16. data/lib/gitlab/client/issue_links.rb +48 -0
  17. data/lib/gitlab/client/issues.rb +1 -1
  18. data/lib/gitlab/client/jobs.rb +91 -8
  19. data/lib/gitlab/client/keys.rb +11 -0
  20. data/lib/gitlab/client/labels.rb +1 -1
  21. data/lib/gitlab/client/lint.rb +19 -0
  22. data/lib/gitlab/client/markdown.rb +23 -0
  23. data/lib/gitlab/client/merge_request_approvals.rb +160 -7
  24. data/lib/gitlab/client/merge_requests.rb +64 -4
  25. data/lib/gitlab/client/notes.rb +28 -1
  26. data/lib/gitlab/client/packages.rb +95 -0
  27. data/lib/gitlab/client/pipeline_schedules.rb +16 -4
  28. data/lib/gitlab/client/pipelines.rb +12 -0
  29. data/lib/gitlab/client/projects.rb +142 -8
  30. data/lib/gitlab/client/remote_mirrors.rb +51 -0
  31. data/lib/gitlab/client/repositories.rb +59 -3
  32. data/lib/gitlab/client/repository_files.rb +16 -0
  33. data/lib/gitlab/client/resource_state_events.rb +57 -0
  34. data/lib/gitlab/client/runners.rb +99 -14
  35. data/lib/gitlab/client/search.rb +5 -1
  36. data/lib/gitlab/client/user_snippets.rb +114 -0
  37. data/lib/gitlab/client/users.rb +142 -11
  38. data/lib/gitlab/client.rb +18 -2
  39. data/lib/gitlab/configuration.rb +1 -1
  40. data/lib/gitlab/error.rb +54 -0
  41. data/lib/gitlab/help.rb +8 -8
  42. data/lib/gitlab/objectified_hash.rb +23 -7
  43. data/lib/gitlab/page_links.rb +1 -1
  44. data/lib/gitlab/paginated_response.rb +23 -20
  45. data/lib/gitlab/request.rb +34 -33
  46. data/lib/gitlab/shell_history.rb +6 -10
  47. data/lib/gitlab/version.rb +1 -1
  48. data/lib/gitlab.rb +14 -6
  49. metadata +24 -47
@@ -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.
@@ -67,7 +70,7 @@ class Gitlab::Client
67
70
  # @option options [Boolean] :issues_enabled The issues integration for a project (0 = false, 1 = true).
68
71
  # @option options [Boolean] :snippets_enabled The snippets integration for a project (0 = false, 1 = true).
69
72
  # @option options [Boolean] :merge_requests_enabled The merge requests functionality for a project (0 = false, 1 = true).
70
- # @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true).
73
+ # @option options [String] :visibility The setting for making a project public ('private', 'internal', 'public').
71
74
  # @option options [Integer] :user_id The user/owner id of a project.
72
75
  # @return [Gitlab::ObjectifiedHash] Information about created project.
73
76
  def create_project(name, options = {})
@@ -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, File.open(File::NULL, 'r'))
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 [File] The file you are interested to upload.
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, file)
539
- post("/projects/#{url_encode id}/uploads", body: { file: 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
@@ -570,5 +621,88 @@ class Gitlab::Client
570
621
  def project_template(project, type, key, options = {})
571
622
  get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options)
572
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
573
707
  end
574
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] :ref_name The name of a repository branch or tag.
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)
@@ -28,9 +29,10 @@ class Gitlab::Client
28
29
  #
29
30
  # @param [Integer, String] project The ID or name of a project.
30
31
  # @param [String] ref The commit sha, branch, or tag to download.
32
+ # @param [String] format The archive format. Options are: tar.gz (default), tar.bz2, tbz, tbz2, tb2, bz2, tar, and zip
31
33
  # @return [Gitlab::FileResponse]
32
- def repo_archive(project, ref = 'master')
33
- get("/projects/#{url_encode project}/repository/archive",
34
+ def repo_archive(project, ref = 'master', format = 'tar.gz')
35
+ get("/projects/#{url_encode project}/repository/archive.#{format}",
34
36
  format: nil,
35
37
  headers: { Accept: 'application/octet-stream' },
36
38
  query: { sha: ref },
@@ -70,5 +72,59 @@ class Gitlab::Client
70
72
  def merge_base(project, refs)
71
73
  get("/projects/#{url_encode project}/repository/merge_base", query: { refs: refs })
72
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
73
129
  end
74
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(:paused)
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] :scope The scope of specific runners to show, one of: active, paused, online; showing all runners if none provided
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] :scope The scope of runners to show, one of: specific, shared, active, paused, online; showing all runners if none provided
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] :active The state of a runner; can be set to true or false.
58
- # @option options [String] :tag_list The list of tags for a runner; put array of tags, that should be finally assigned to a runner
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}", query: options)
71
+ put("/runners/#{id}", body: options)
62
72
  end
63
73
 
64
74
  # Remove a runner.
@@ -68,20 +78,26 @@ class Gitlab::Client
68
78
  # Gitlab.delete_runner(42)
69
79
  #
70
80
  # @param [Integer, String] id The ID of a runner
71
- # @return <Gitlab::ObjectifiedHash>
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
- # Gets a list of Jobs for a Runner
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.
94
+ # @param [Hash] options A customizable set of options.
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)
82
98
  # @return [Array<Gitlab::ObjectifiedHash>]
83
- def runner_jobs(runner_id)
84
- get("/runners/#{url_encode runner_id}/jobs")
99
+ def runner_jobs(runner_id, options = {})
100
+ get("/runners/#{url_encode runner_id}/jobs", query: options)
85
101
  end
86
102
 
87
103
  # List all runners (specific and shared) available in the project. Shared runners are listed if at least one shared runner is defined and shared runners usage is enabled in the project's settings.
@@ -89,11 +105,17 @@ class Gitlab::Client
89
105
  #
90
106
  # @example
91
107
  # Gitlab.project_runners(42)
108
+ # Gitlab.project_runners(42, type: 'instance_type', status: 'active')
109
+ # Gitlab.project_runners(42, tag_list: 'tag1,tag2')
92
110
  #
93
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)
94
116
  # @return [Array<Gitlab::ObjectifiedHash>]
95
- def project_runners(project_id)
96
- get("/projects/#{url_encode project_id}/runners")
117
+ def project_runners(project_id, options = {})
118
+ get("/projects/#{url_encode project_id}/runners", query: options)
97
119
  end
98
120
 
99
121
  # Enable an available specific runner in the project.
@@ -122,5 +144,68 @@ class Gitlab::Client
122
144
  def project_disable_runner(id, runner_id)
123
145
  delete("/projects/#{url_encode id}/runners/#{runner_id}")
124
146
  end
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
+
166
+ # Register a new Runner for the instance.
167
+ #
168
+ # @example
169
+ # Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e')
170
+ # Gitlab.register_runner('9142c16ea169eaaea3d752313a434a6e', description: 'Some Description', active: true, locked: false)
171
+ #
172
+ # @param [String] token(required) Registration token.
173
+ # @param [Hash] options A customizable set of options.
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.
181
+ # @return <Gitlab::ObjectifiedHash> Response against runner registration
182
+ def register_runner(token, options = {})
183
+ body = { token: token }.merge(options)
184
+ post('/runners', body: body)
185
+ end
186
+
187
+ # Deletes a registed Runner.
188
+ #
189
+ # @example
190
+ # Gitlab.delete_registered_runner('9142c16ea169eaaea3d752313a434a6e')
191
+ #
192
+ # @param [String] token Runner authentication token.
193
+ # @return [nil] This API call returns an empty response body.
194
+ def delete_registered_runner(token)
195
+ body = { token: token }
196
+ delete('/runners', body: body)
197
+ end
198
+
199
+ # Validates authentication credentials for a registered Runner.
200
+ #
201
+ # @example
202
+ # Gitlab.verify_auth_registered_runner('9142c16ea169eaaea3d752313a434a6e')
203
+ #
204
+ # @param [String] token Runner authentication token.
205
+ # @return [nil] This API call returns an empty response body.
206
+ def verify_auth_registered_runner(token)
207
+ body = { token: token }
208
+ post('/runners/verify', body: body)
209
+ end
125
210
  end
126
211
  end
@@ -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