gitlab 4.5.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +0 -267
  3. data/LICENSE.txt +1 -1
  4. data/README.md +40 -30
  5. data/exe/gitlab +5 -1
  6. data/lib/gitlab/api.rb +7 -3
  7. data/lib/gitlab/cli.rb +13 -9
  8. data/lib/gitlab/cli_helpers.rb +49 -45
  9. data/lib/gitlab/client/access_requests.rb +10 -1
  10. data/lib/gitlab/client/application_settings.rb +172 -0
  11. data/lib/gitlab/client/avatar.rb +21 -0
  12. data/lib/gitlab/client/award_emojis.rb +5 -3
  13. data/lib/gitlab/client/boards.rb +62 -4
  14. data/lib/gitlab/client/branches.rb +47 -8
  15. data/lib/gitlab/client/broadcast_messages.rb +75 -0
  16. data/lib/gitlab/client/build_variables.rb +19 -12
  17. data/lib/gitlab/client/builds.rb +13 -11
  18. data/lib/gitlab/client/commits.rb +73 -21
  19. data/lib/gitlab/client/container_registry.rb +85 -0
  20. data/lib/gitlab/client/deployments.rb +3 -1
  21. data/lib/gitlab/client/environments.rb +5 -3
  22. data/lib/gitlab/client/epic_issues.rb +23 -0
  23. data/lib/gitlab/client/epics.rb +73 -0
  24. data/lib/gitlab/client/events.rb +6 -4
  25. data/lib/gitlab/client/features.rb +48 -0
  26. data/lib/gitlab/client/group_badges.rb +88 -0
  27. data/lib/gitlab/client/group_boards.rb +141 -0
  28. data/lib/gitlab/client/group_labels.rb +88 -0
  29. data/lib/gitlab/client/group_milestones.rb +7 -6
  30. data/lib/gitlab/client/groups.rb +326 -12
  31. data/lib/gitlab/client/issue_links.rb +48 -0
  32. data/lib/gitlab/client/issues.rb +47 -13
  33. data/lib/gitlab/client/jobs.rb +96 -8
  34. data/lib/gitlab/client/keys.rb +13 -0
  35. data/lib/gitlab/client/labels.rb +6 -4
  36. data/lib/gitlab/client/lint.rb +19 -0
  37. data/lib/gitlab/client/markdown.rb +23 -0
  38. data/lib/gitlab/client/merge_request_approvals.rb +164 -9
  39. data/lib/gitlab/client/merge_requests.rb +148 -11
  40. data/lib/gitlab/client/merge_trains.rb +55 -0
  41. data/lib/gitlab/client/milestones.rb +19 -5
  42. data/lib/gitlab/client/namespaces.rb +4 -2
  43. data/lib/gitlab/client/notes.rb +38 -9
  44. data/lib/gitlab/client/packages.rb +95 -0
  45. data/lib/gitlab/client/pipeline_schedules.rb +36 -10
  46. data/lib/gitlab/client/pipeline_triggers.rb +10 -8
  47. data/lib/gitlab/client/pipelines.rb +65 -3
  48. data/lib/gitlab/client/project_badges.rb +85 -0
  49. data/lib/gitlab/client/project_clusters.rb +83 -0
  50. data/lib/gitlab/client/project_exports.rb +54 -0
  51. data/lib/gitlab/client/project_release_links.rb +76 -0
  52. data/lib/gitlab/client/project_releases.rb +90 -0
  53. data/lib/gitlab/client/projects.rb +307 -26
  54. data/lib/gitlab/client/protected_tags.rb +59 -0
  55. data/lib/gitlab/client/remote_mirrors.rb +51 -0
  56. data/lib/gitlab/client/repositories.rb +77 -6
  57. data/lib/gitlab/client/repository_files.rb +21 -3
  58. data/lib/gitlab/client/repository_submodules.rb +27 -0
  59. data/lib/gitlab/client/resource_label_events.rb +82 -0
  60. data/lib/gitlab/client/resource_state_events.rb +57 -0
  61. data/lib/gitlab/client/runners.rb +170 -18
  62. data/lib/gitlab/client/search.rb +66 -0
  63. data/lib/gitlab/client/services.rb +4 -1
  64. data/lib/gitlab/client/sidekiq.rb +2 -0
  65. data/lib/gitlab/client/snippets.rb +5 -3
  66. data/lib/gitlab/client/system_hooks.rb +9 -7
  67. data/lib/gitlab/client/tags.rb +10 -9
  68. data/lib/gitlab/client/templates.rb +100 -0
  69. data/lib/gitlab/client/todos.rb +7 -5
  70. data/lib/gitlab/client/user_snippets.rb +114 -0
  71. data/lib/gitlab/client/users.rb +302 -31
  72. data/lib/gitlab/client/versions.rb +18 -0
  73. data/lib/gitlab/client/wikis.rb +79 -0
  74. data/lib/gitlab/client.rb +48 -9
  75. data/lib/gitlab/configuration.rb +9 -6
  76. data/lib/gitlab/error.rb +73 -3
  77. data/lib/gitlab/file_response.rb +4 -2
  78. data/lib/gitlab/headers/page_links.rb +37 -0
  79. data/lib/gitlab/headers/total.rb +29 -0
  80. data/lib/gitlab/help.rb +16 -16
  81. data/lib/gitlab/objectified_hash.rb +27 -10
  82. data/lib/gitlab/paginated_response.rb +43 -25
  83. data/lib/gitlab/request.rb +51 -37
  84. data/lib/gitlab/shell.rb +6 -4
  85. data/lib/gitlab/shell_history.rb +11 -13
  86. data/lib/gitlab/version.rb +3 -1
  87. data/lib/gitlab.rb +23 -9
  88. metadata +59 -45
  89. data/.gitignore +0 -22
  90. data/CONTRIBUTING.md +0 -195
  91. data/Gemfile +0 -4
  92. data/Rakefile +0 -17
  93. data/bin/console +0 -10
  94. data/bin/setup +0 -6
  95. data/gitlab.gemspec +0 -33
  96. data/lib/gitlab/page_links.rb +0 -33
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to repositories.
3
5
  # @see https://docs.gitlab.com/ce/api/repositories.html
@@ -11,12 +13,13 @@ class Gitlab::Client
11
13
  # @param [Integer, String] project The ID or name of a project.
12
14
  # @param [Hash] options A customizable set of options.
13
15
  # @option options [String] :path The path inside repository.
14
- # @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)
15
18
  # @return [Gitlab::ObjectifiedHash]
16
- def tree(project, options={})
19
+ def tree(project, options = {})
17
20
  get("/projects/#{url_encode project}/repository/tree", query: options)
18
21
  end
19
- alias_method :repo_tree, :tree
22
+ alias repo_tree tree
20
23
 
21
24
  # Get project repository archive
22
25
  #
@@ -26,9 +29,10 @@ class Gitlab::Client
26
29
  #
27
30
  # @param [Integer, String] project The ID or name of a project.
28
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
29
33
  # @return [Gitlab::FileResponse]
30
- def repo_archive(project, ref = 'master')
31
- 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}",
32
36
  format: nil,
33
37
  headers: { Accept: 'application/octet-stream' },
34
38
  query: { sha: ref },
@@ -54,6 +58,73 @@ class Gitlab::Client
54
58
  def compare(project, from, to)
55
59
  get("/projects/#{url_encode project}/repository/compare", query: { from: from, to: to })
56
60
  end
57
- alias_method :repo_compare, :compare
61
+ alias repo_compare compare
62
+
63
+ # Get the common ancestor for 2 refs (commit SHAs, branch names or tags).
64
+ #
65
+ # @example
66
+ # Gitlab.merge_base(42, ['master', 'feature/branch'])
67
+ # Gitlab.merge_base(42, ['master', 'feature/branch'])
68
+ #
69
+ # @param [Integer, String] project The ID or URL-encoded path of the project.
70
+ # @param [Array] refs Array containing 2 commit SHAs, branch names, or tags.
71
+ # @return [Gitlab::ObjectifiedHash]
72
+ def merge_base(project, refs)
73
+ get("/projects/#{url_encode project}/repository/merge_base", query: { refs: refs })
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
58
129
  end
59
130
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'base64'
2
4
 
3
5
  class Gitlab::Client
@@ -14,14 +16,30 @@ class Gitlab::Client
14
16
  # @param [String] filepath The relative path of the file in the repository
15
17
  # @param [String] ref The name of a repository branch or tag or if not given the default branch.
16
18
  # @return [String]
17
- def file_contents(project, filepath, ref='master')
19
+ def file_contents(project, filepath, ref = 'master')
18
20
  get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw",
19
- query: { ref: ref},
21
+ query: { ref: ref },
20
22
  format: nil,
21
23
  headers: { Accept: 'text/plain' },
22
24
  parser: ::Gitlab::Request::Parser
23
25
  end
24
- alias_method :repo_file_contents, :file_contents
26
+ alias repo_file_contents file_contents
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
25
43
 
26
44
  # Gets a repository file.
27
45
  #
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to repository submodules.
5
+ # @see https://docs.gitlab.com/ce/api/repository_submodules.html
6
+ module RepositorySubmodules
7
+ # Edits an existing repository submodule.
8
+ #
9
+ # @example
10
+ # Gitlab.edit_file(42, "submodule", {
11
+ # branch: "branch",
12
+ # commit_sha: "3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88",
13
+ # commit_message: "commit message"
14
+ # })
15
+ #
16
+ # @param [Integer, String] project The ID or name of a project.
17
+ # @param [String] submodule full path of submodule to update.
18
+ # @param [Hash] options A customizable set of options.
19
+ # @param options [String] :branch the name of the branch to commit changes to.
20
+ # @param options [String] :commit_sha commit SHA to update the submodule to.
21
+ # @param options [String] :commit_message commit message text.
22
+ # @return [Gitlab::ObjectifiedHash]
23
+ def edit_submodule(project, submodule, options = {})
24
+ put("/projects/#{url_encode project}/repository/submodules/#{url_encode submodule}", body: options)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to resource label events.
5
+ # @see https://docs.gitlab.com/ee/api/resource_label_events.html
6
+ module ResourceLabelEvents
7
+ # Gets a list of all label events for a single issue.
8
+ #
9
+ # @example
10
+ # Gitlab.issue_label_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_label_events(project, issue_iid)
16
+ get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_label_events")
17
+ end
18
+
19
+ # Returns a single label event for a specific project issue
20
+ #
21
+ # @example
22
+ # Gitlab.issue_label_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 label event.
27
+ # @return Gitlab::ObjectifiedHash
28
+ def issue_label_event(project, issue_iid, id)
29
+ get("/projects/#{url_encode project}/issues/#{issue_iid}/resource_label_events/#{id}")
30
+ end
31
+
32
+ # Gets a list of all label events for a single epic.
33
+ #
34
+ # @example
35
+ # Gitlab.epic_label_events(5, 42)
36
+ #
37
+ # @param [Integer, String] group The ID or name of a group.
38
+ # @param [Integer] epic_id The ID of an epic.
39
+ # @return [Array<Gitlab::ObjectifiedHash>]
40
+ def epic_label_events(group, epic_id)
41
+ get("/groups/#{url_encode group}/epics/#{epic_id}/resource_label_events")
42
+ end
43
+
44
+ # Returns a single label event for a specific group epic
45
+ #
46
+ # @example
47
+ # Gitlab.epic_label_event(5, 42, 1)
48
+ #
49
+ # @param [Integer, String] group The ID or name of a group.
50
+ # @param [Integer] epic_id The ID of an epic.
51
+ # @param [Integer] id The ID of a label event.
52
+ # @return Gitlab::ObjectifiedHash
53
+ def epic_label_event(group, epic_id, id)
54
+ get("/groups/#{url_encode group}/epics/#{epic_id}/resource_label_events/#{id}")
55
+ end
56
+
57
+ # Gets a list of all label events for a single merge request.
58
+ #
59
+ # @example
60
+ # Gitlab.merge_request_label_events(5, 42)
61
+ #
62
+ # @param [Integer, String] project The ID or name of a project.
63
+ # @param [Integer] merge_request_iid The IID of a merge request.
64
+ # @return [Array<Gitlab::ObjectifiedHash>]
65
+ def merge_request_label_events(project, merge_request_iid)
66
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_label_events")
67
+ end
68
+
69
+ # Returns a single label event for a specific project merge request
70
+ #
71
+ # @example
72
+ # Gitlab.merge_request_label_event(5, 42, 1)
73
+ #
74
+ # @param [Integer, String] project The ID or name of a project.
75
+ # @param [Integer] merge_request_iid The IID of an merge request.
76
+ # @param [Integer] id The ID of a label event.
77
+ # @return Gitlab::ObjectifiedHash
78
+ def merge_request_label_event(project, merge_request_iid, id)
79
+ get("/projects/#{url_encode project}/merge_requests/#{merge_request_iid}/resource_label_events/#{id}")
80
+ end
81
+ end
82
+ 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
@@ -1,21 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to runners.
3
5
  # @see https://docs.gitlab.com/ce/api/runners.html
4
6
  module Runners
5
-
6
7
  # Get a list of specific runners available to the user.
7
8
  # @see https://docs.gitlab.com/ce/api/runners.html#list-owned-runners
8
9
  #
9
10
  # @example
10
11
  # Gitlab.runners
11
- # Gitlab.runners(:active)
12
- # Gitlab.runners(:paused)
12
+ # Gitlab.runners(type: 'instance_type', status: 'active')
13
+ # Gitlab.runners(tag_list: 'tag1,tag2')
13
14
  #
14
15
  # @param [Hash] options A customizable set of options.
15
- # @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)
16
19
  # @return [Array<Gitlab::ObjectifiedHash>]
17
20
  def runners(options = {})
18
- get("/runners", query: options)
21
+ get('/runners', query: options)
19
22
  end
20
23
 
21
24
  # Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
@@ -23,12 +26,16 @@ class Gitlab::Client
23
26
  #
24
27
  # @example
25
28
  # Gitlab.all_runners
29
+ # Gitlab.all_runners(type: 'instance_type', status: 'active')
30
+ # Gitlab.all_runners(tag_list: 'tag1,tag2')
26
31
  #
27
32
  # @param [Hash] options A customizable set of options.
28
- # @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)
29
36
  # @return [Array<Gitlab::ObjectifiedHash>]
30
37
  def all_runners(options = {})
31
- get("/runners/all", query: options)
38
+ get('/runners/all', query: options)
32
39
  end
33
40
 
34
41
  # Get details of a runner..
@@ -49,15 +56,19 @@ class Gitlab::Client
49
56
  # @example
50
57
  # Gitlab.update_runner(42, { description: 'Awesome runner' })
51
58
  # Gitlab.update_runner(42, { active: false })
52
- # Gitlab.update_runner(42, { tag_list: [ 'awesome', 'runner' ] })
53
59
  #
54
60
  # @param [Integer, String] id The ID of a runner
55
61
  # @param [Hash] options A customizable set of options.
56
- # @option options [String] :active The state of a runner; can be set to true or false.
57
- # @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
58
69
  # @return <Gitlab::ObjectifiedHash>
59
- def update_runner(id, options={})
60
- put("/runners/#{id}", query: options)
70
+ def update_runner(id, options = {})
71
+ put("/runners/#{id}", body: options)
61
72
  end
62
73
 
63
74
  # Remove a runner.
@@ -67,20 +78,26 @@ class Gitlab::Client
67
78
  # Gitlab.delete_runner(42)
68
79
  #
69
80
  # @param [Integer, String] id The ID of a runner
70
- # @return <Gitlab::ObjectifiedHash>
81
+ # @return [nil] This API call returns an empty response body.
71
82
  def delete_runner(id)
72
83
  delete("/runners/#{id}")
73
84
  end
74
85
 
75
- # Gets a list of Jobs for a Runner
86
+ # List jobs that are being processed or were processed by specified runner.
76
87
  #
77
88
  # @example
78
89
  # Gitlab.runner_jobs(1)
90
+ # Gitlab.runner_jobs(1, status: 'success')
91
+ # Gitlab.runner_jobs(1, sort: 'desc')
79
92
  #
80
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)
81
98
  # @return [Array<Gitlab::ObjectifiedHash>]
82
- def runner_jobs(runner_id)
83
- get("/runners/#{url_encode runner_id}/jobs")
99
+ def runner_jobs(runner_id, options = {})
100
+ get("/runners/#{url_encode runner_id}/jobs", query: options)
84
101
  end
85
102
 
86
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.
@@ -88,11 +105,17 @@ class Gitlab::Client
88
105
  #
89
106
  # @example
90
107
  # Gitlab.project_runners(42)
108
+ # Gitlab.project_runners(42, type: 'instance_type', status: 'active')
109
+ # Gitlab.project_runners(42, tag_list: 'tag1,tag2')
91
110
  #
92
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)
93
116
  # @return [Array<Gitlab::ObjectifiedHash>]
94
- def project_runners(project_id)
95
- get("/projects/#{url_encode project_id}/runners")
117
+ def project_runners(project_id, options = {})
118
+ get("/projects/#{url_encode project_id}/runners", query: options)
96
119
  end
97
120
 
98
121
  # Enable an available specific runner in the project.
@@ -122,5 +145,134 @@ class Gitlab::Client
122
145
  delete("/projects/#{url_encode id}/runners/#{runner_id}")
123
146
  end
124
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
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
125
277
  end
126
278
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to global searches, searching in projects and searching in groups.
5
+ # @see https://docs.gitlab.com/ce/api/search.html
6
+ module Search
7
+ # Search globally across the GitLab instance.
8
+ #
9
+ # @example
10
+ # Gitlab.search_globally('projects', 'gitlab')
11
+ # Gitlab.search_globally('issues', 'gitlab')
12
+ # Gitlab.search_globally('merge_requests', 'gitlab')
13
+ # Gitlab.search_globally('milestones', 'gitlab')
14
+ # Gitlab.search_globally('snippet_titles', 'gitlab')
15
+ # Gitlab.search_globally('snippet_blobs', 'gitlab')
16
+ #
17
+ # @param [String] scope The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones, snippet_titles, snippet_blobs.
18
+ # @param [String] search The search query.
19
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
20
+ def search_globally(scope, search)
21
+ options = { scope: scope, search: search }
22
+ get('/search', query: options)
23
+ end
24
+
25
+ # Search within the specified group.
26
+ #
27
+ # @example
28
+ # Gitlab.search_in_group(1, 'projects', 'gitlab')
29
+ # Gitlab.search_in_group(1, 'issues', 'gitlab')
30
+ # Gitlab.search_in_group(1, 'merge_requests', 'gitlab')
31
+ # Gitlab.search_in_group(1, 'milestones', 'gitlab')
32
+ #
33
+ # @param [Integer, String] group The ID or name of a group.
34
+ # @param [String] scope The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones.
35
+ # @param [String] search The search query.
36
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
37
+ def search_in_group(group, scope, search)
38
+ options = { scope: scope, search: search }
39
+ get("/groups/#{url_encode group}/search", query: options)
40
+ end
41
+
42
+ # Search within the specified project.
43
+ #
44
+ # @example
45
+ # Gitlab.search_in_project(1, 'issues', 'gitlab')
46
+ # Gitlab.search_in_project(1, 'merge_requests', 'gitlab')
47
+ # Gitlab.search_in_project(1, 'milestones', 'gitlab')
48
+ # Gitlab.search_in_project(1, 'notes', 'gitlab')
49
+ # Gitlab.search_in_project(1, 'wiki_blobs', 'gitlab')
50
+ # Gitlab.search_in_project(1, 'commits', 'gitlab')
51
+ # Gitlab.search_in_project(1, 'blobs', 'gitlab')
52
+ #
53
+ # @param [Integer, String] project The ID or name of a project.
54
+ # @param [String] scope The scope to search in. Currently these scopes are supported: issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs.
55
+ # @param [String] search The search query.
56
+ # @return [Array<Gitlab::ObjectifiedHash>] Returns a list of responses depending on the requested scope.
57
+ def search_in_project(project, scope, search, ref = nil)
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
+
63
+ get("/projects/#{url_encode project}/search", query: options)
64
+ end
65
+ end
66
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Third party services connected to a project.
3
5
  # @see https://docs.gitlab.com/ce/api/services.html
@@ -43,8 +45,9 @@ class Gitlab::Client
43
45
  end
44
46
 
45
47
  private
48
+
46
49
  def correct_service_name(service)
47
- service.to_s.gsub('_', '-')
50
+ service.to_s.tr('_', '-')
48
51
  end
49
52
  end
50
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gitlab::Client
2
4
  # Defines methods related to sidekiq metrics.
3
5
  # @see https://docs.gitlab.com/ce/api/sidekiq_metrics.html