gitlab 4.14.0 → 4.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c77e29621138a7c5468d44f3753d6bb7e6ead353b384d2e10ed7230999323651
4
- data.tar.gz: 44831812bcb2d53fb7adad0762a7822ba00f0a0dc064afa0ae7a3cc53d9b3eb4
3
+ metadata.gz: 3265eea0b2b8d118d2a8dc9e135a1e5eac505072d2291afeab157902c4d7d50c
4
+ data.tar.gz: a99c3230eb2d20f4c6f8ff198351944698a7a554632b5252646962371cc6885c
5
5
  SHA512:
6
- metadata.gz: bfb8f5b817ce9e73c35de24e28a9d5f98fdcdf2a1071f06cefaa238aec71f7e33eff9b5611f1d7cb0eac33a70baa87410a37536c1015a1d4663392dafb1fcca2
7
- data.tar.gz: 937c02a461ec9c6b472542ce4576296afe660c3797533fd6ad0d3dc93b5f78b44809bbdc2acfe1ba800125cb8e26d063a56bceca3b4f62d4bd2bacb95be09fcb
6
+ metadata.gz: c115e9436d6214665e17c66e74e80730180bfb92e41b33dbc63c91c7de4d80883e7b0f0c8e27d806ac55c816640463219f12ff53ed4278cce7141b0e5ec72399
7
+ data.tar.gz: 3297df4d90a5de774d532c8ebf349a9b60907c110810bb4a258ae326376cbb4810231dbc1203e3743ddf9e81b97d869bed1952f59235c1d8ccf01bb9c3ea8be1
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Gitlab
2
2
 
3
- [![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg)](https://travis-ci.org/NARKOZ/gitlab)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/2e310b334b1b5db4a7e1/maintainability)](https://codeclimate.com/github/NARKOZ/gitlab)
3
+ [![Build Status](https://img.shields.io/github/workflow/status/NARKOZ/gitlab/CI/master)](https://github.com/NARKOZ/gitlab/actions?query=workflow%3ARuby)
5
4
  [![Inline docs](https://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab)
6
5
  [![Gem version](https://img.shields.io/gem/v/gitlab.svg)](https://rubygems.org/gems/gitlab)
7
6
  [![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
@@ -28,7 +27,7 @@ gem 'gitlab'
28
27
  # gem 'gitlab', github: 'NARKOZ/gitlab'
29
28
  ```
30
29
 
31
- Mac OS users can install using Homebrew:
30
+ Mac OS users can install using Homebrew (may not be the latest version):
32
31
 
33
32
  ```sh
34
33
  brew install gitlab-gem
@@ -42,7 +42,8 @@ module Gitlab
42
42
  #
43
43
  # @return [Array<Symbol>]
44
44
  def self.actions
45
- hidden = /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate|request_defaults|httparty/
45
+ hidden =
46
+ /endpoint|private_token|auth_token|user_agent|sudo|get|post|put|\Adelete\z|validate\z|request_defaults|httparty/
46
47
  (Gitlab::Client.instance_methods - Object.methods).reject { |e| e[hidden] }
47
48
  end
48
49
  end
@@ -10,6 +10,7 @@ module Gitlab
10
10
 
11
11
  # Creates a new API.
12
12
  # @raise [Error:MissingCredentials]
13
+ # rubocop:disable Lint/MissingSuper
13
14
  def initialize(options = {})
14
15
  options = Gitlab.options.merge(options)
15
16
  (Configuration::VALID_OPTIONS_KEYS + [:auth_token]).each do |key|
@@ -18,5 +19,6 @@ module Gitlab
18
19
  request_defaults(sudo)
19
20
  self.class.headers 'User-Agent' => user_agent
20
21
  end
22
+ # rubocop:enable Lint/MissingSuper
21
23
  end
22
24
  end
@@ -17,10 +17,10 @@ class Gitlab::CLI
17
17
  # @param [Array] args The command and it's optional arguments.
18
18
  def self.start(args)
19
19
  command = begin
20
- args.shift.strip
21
- rescue StandardError
22
- 'help'
23
- end
20
+ args.shift.strip
21
+ rescue StandardError
22
+ 'help'
23
+ end
24
24
  run(command, args)
25
25
  end
26
26
 
@@ -111,7 +111,7 @@ class Gitlab::CLI
111
111
  else
112
112
  hash_result = case data
113
113
  when Gitlab::ObjectifiedHash, Gitlab::FileResponse
114
- record_hash([data], cmd, args, true)
114
+ record_hash([data], cmd, args, single_value: true)
115
115
  when Gitlab::PaginatedResponse
116
116
  record_hash(data, cmd, args)
117
117
  else
@@ -162,7 +162,7 @@ class Gitlab::CLI
162
162
  # @param [Array] args Options passed to the API call
163
163
  # @param [bool] single_value If set to true, a single result should be returned
164
164
  # @return [Hash] Result hash
165
- def record_hash(data, cmd, args, single_value = false)
165
+ def record_hash(data, cmd, args, single_value: false)
166
166
  if data.empty?
167
167
  result = nil
168
168
  else
@@ -206,14 +206,10 @@ class Gitlab::CLI
206
206
 
207
207
  # Helper function to call Gitlab commands with args.
208
208
  def gitlab_helper(cmd, args = [])
209
- begin
210
- data = args.any? ? Gitlab.send(cmd, *args) : Gitlab.send(cmd)
211
- rescue StandardError => e
212
- puts e.message
213
- yield if block_given?
214
- end
215
-
216
- data
209
+ args.any? ? Gitlab.send(cmd, *args) : Gitlab.send(cmd)
210
+ rescue StandardError => e
211
+ puts e.message
212
+ yield if block_given?
217
213
  end
218
214
 
219
215
  # Convert a hash (recursively) to use symbol hash keys
@@ -221,11 +217,9 @@ class Gitlab::CLI
221
217
  def symbolize_keys(hash)
222
218
  if hash.is_a?(Hash)
223
219
  hash = hash.each_with_object({}) do |(key, value), new_hash|
224
- begin
225
- new_hash[key.to_sym] = symbolize_keys(value)
226
- rescue NoMethodError
227
- raise "Error: cannot convert hash key to symbol: #{key}"
228
- end
220
+ new_hash[key.to_sym] = symbolize_keys(value)
221
+ rescue NoMethodError
222
+ raise "Error: cannot convert hash key to symbol: #{key}"
229
223
  end
230
224
  end
231
225
 
@@ -19,9 +19,11 @@ module Gitlab
19
19
  include ContainerRegistry
20
20
  include Deployments
21
21
  include Environments
22
+ include EpicIssues
22
23
  include Epics
23
24
  include Events
24
25
  include Features
26
+ include GroupBadges
25
27
  include GroupBoards
26
28
  include GroupLabels
27
29
  include GroupMilestones
@@ -51,6 +53,7 @@ module Gitlab
51
53
  include RepositoryFiles
52
54
  include RepositorySubmodules
53
55
  include ResourceLabelEvents
56
+ include ResourceStateEvents
54
57
  include Runners
55
58
  include Search
56
59
  include Services
@@ -61,6 +64,7 @@ module Gitlab
61
64
  include Templates
62
65
  include Todos
63
66
  include Users
67
+ include UserSnippets
64
68
  include Versions
65
69
  include Wikis
66
70
 
@@ -78,7 +82,7 @@ module Gitlab
78
82
  #
79
83
  # @return [String]
80
84
  def url_encode(url)
81
- url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString, Style/FormatStringToken
85
+ url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString
82
86
  end
83
87
 
84
88
  private
@@ -59,9 +59,30 @@ class Gitlab::Client
59
59
  # @param [Integer, String] project The ID or name of a project.
60
60
  # @param [String] sha The commit hash or name of a repository branch or tag
61
61
  # @param [String] branch The name of the branch
62
+ # @param [Hash] options A customizable set of options.
63
+ # @option options [Boolean] :dry_run Don't commit any changes
62
64
  # @return [Gitlab::ObjectifiedHash]
63
- def cherry_pick_commit(project, sha, branch)
64
- post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: { branch: branch })
65
+ def cherry_pick_commit(project, sha, branch, options = {})
66
+ options[:branch] = branch
67
+
68
+ post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: options)
69
+ end
70
+
71
+ # Reverts a commit in a given branch.
72
+ #
73
+ # @example
74
+ # Gitlab.revert_commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'master')
75
+ #
76
+ # @param [Integer, String] project The ID or name of a project.
77
+ # @param [String] sha The commit hash or name of a repository branch or tag
78
+ # @param [String] branch The name of the branch
79
+ # @param [Hash] options A customizable set of options.
80
+ # @option options [Boolean] :dry_run Don't commit any changes
81
+ # @return [Gitlab::ObjectifiedHash]
82
+ def revert_commit(project, sha, branch, options = {})
83
+ options[:branch] = branch
84
+
85
+ post("/projects/#{url_encode project}/repository/commits/#{sha}/revert", body: options)
65
86
  end
66
87
 
67
88
  # Get the diff of a commit in a project.
@@ -145,7 +166,7 @@ class Gitlab::Client
145
166
  # @option options [String] :name Filter by status name, eg. jenkins
146
167
  # @option options [String] :target_url The target URL to associate with this status
147
168
  def update_commit_status(project, sha, state, options = {})
148
- post("/projects/#{url_encode project}/statuses/#{sha}", query: options.merge(state: state))
169
+ post("/projects/#{url_encode project}/statuses/#{sha}", body: options.merge(state: state))
149
170
  end
150
171
  alias repo_update_commit_status update_commit_status
151
172
 
@@ -79,7 +79,7 @@ class Gitlab::Client
79
79
  # @option options [String] :older_than(required) Tags to delete that are older than the given time, written in human readable form 1h, 1d, 1month.
80
80
  # @return [void] This API call returns an empty response body.
81
81
  def bulk_delete_registry_repository_tags(project, repository_id, options = {})
82
- delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags", query: options)
82
+ delete("/projects/#{url_encode project}/registry/repositories/#{repository_id}/tags", body: options)
83
83
  end
84
84
  end
85
85
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to issues.
5
+ # @see https://docs.gitlab.com/ee/api/epic_issues.html
6
+ module EpicIssues
7
+ # List issues for an epic.
8
+ # Gets all issues that are assigned to an epic and the authenticated user has access to..
9
+ # @example
10
+ # Gitlab.epic_issues(5, 7)
11
+ # Gitlab.epic_issues(5, 7, { per_page: 40 })
12
+ #
13
+ # @param [Integer, String] group The ID or name of a group.
14
+ # @param [Integer] epic The iid of an epic.
15
+ # @param [Hash] options A customizable set of options.
16
+ # @option options [Integer] :page The page number.
17
+ # @option options [Integer] :per_page The number of results per page.
18
+ # @return [Array<Gitlab::ObjectifiedHash>]
19
+ def epic_issues(group, epic, options = {})
20
+ get("/groups/#{url_encode group}/epics/#{epic}/issues", query: options)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Gitlab::Client
4
+ # Defines methods related to group badges.
5
+ # @see https://docs.gitlab.com/ee/api/group_badges.html
6
+ module GroupBadges
7
+ # Gets a list of a groups badges.
8
+ #
9
+ # @example
10
+ # Gitlab.group_badges(5)
11
+ # Gitlab.group_badges(5, 'Coverage')
12
+ #
13
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
14
+ # @param [String] name(optional) Name of the badges to return (case-sensitive).
15
+ # @return [Array<Gitlab::ObjectifiedHash>] List of all badges of a group
16
+ def group_badges(group, name = nil)
17
+ query = { name: name } if name
18
+ get("/groups/#{url_encode group}/badges", query: query)
19
+ end
20
+
21
+ # Gets a badge of a group.
22
+ #
23
+ # @example
24
+ # Gitlab.group_badge(5, 42)
25
+ #
26
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
27
+ # @param [Integer] badge_id(required) The badge ID.
28
+ # @return [Gitlab::ObjectifiedHash] Information about the requested badge
29
+ def group_badge(group, badge_id)
30
+ get("/groups/#{url_encode group}/badges/#{badge_id}")
31
+ end
32
+
33
+ # Adds a badge to a group.
34
+ #
35
+ # @example
36
+ # Gitlab.add_group_badge(5, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
37
+ #
38
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
39
+ # @param [Hash] options A customizable set of options.
40
+ # @option options [String] :link_url(required) URL of the badge link
41
+ # @option options [String] :image_url(required) URL of the badge image
42
+ # @return [Gitlab::ObjectifiedHash] Information about the added group badge.
43
+ def add_group_badge(group, options = {})
44
+ post("/groups/#{url_encode group}/badges", body: options)
45
+ end
46
+
47
+ # Updates a badge of a group.
48
+ #
49
+ # @example
50
+ # Gitlab.edit_group_badge(5, 1, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' })
51
+ #
52
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
53
+ # @param [Integer] badge_id(required) The badge ID.
54
+ # @param [Hash] options A customizable set of options.
55
+ # @option options [String] :link_url(optional) URL of the badge link
56
+ # @option options [String] :image_url(optional) URL of the badge image
57
+ # @return [Gitlab::ObjectifiedHash] Information about the updated group badge.
58
+ def edit_group_badge(group, badge_id, options = {})
59
+ put("/groups/#{url_encode group}/badges/#{badge_id}", body: options)
60
+ end
61
+
62
+ # Removes a badge from a group.
63
+ #
64
+ # @example
65
+ # Gitlab.remove_group_badge(5, 42)
66
+ #
67
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
68
+ # @param [Integer] badge_id(required) The badge ID.
69
+ # @return [nil] This API call returns an empty response body.
70
+ def remove_group_badge(group, badge_id)
71
+ delete("/groups/#{url_encode group}/badges/#{badge_id}")
72
+ end
73
+
74
+ # Preview a badge from a group.
75
+ #
76
+ # @example
77
+ # Gitlab.preview_group_badge(3, 'https://abc.com/gitlab/gitlab-ce/commits/master', 'https://shields.io/my/badge1')
78
+ #
79
+ # @param [Integer, String] group(required) The ID or URL-encoded path of the group owned by the authenticated user.
80
+ # @param [String] :link_url(required) URL of the badge link
81
+ # @param [String] :image_url(required) URL of the badge image
82
+ # @return [Gitlab::ObjectifiedHash] Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation.
83
+ def preview_group_badge(group, link_url, image_url)
84
+ query = { link_url: link_url, image_url: image_url }
85
+ get("/groups/#{url_encode group}/badges/render", query: query)
86
+ end
87
+ end
88
+ end
@@ -58,7 +58,7 @@ class Gitlab::Client
58
58
  # @param [String] name The name of a label.
59
59
  # @return [Gitlab::ObjectifiedHash] Information about deleted label.
60
60
  def delete_group_label(group, name)
61
- delete("/groups/#{url_encode group}/labels", body: { name: name })
61
+ delete("/groups/#{url_encode group}/labels/#{name}")
62
62
  end
63
63
 
64
64
  # Subscribes the user to a group label to receive notifications
@@ -71,6 +71,21 @@ class Gitlab::Client
71
71
  get("/groups/#{url_encode id}/members", query: options)
72
72
  end
73
73
 
74
+ # Get a list of group members that are billable.
75
+ #
76
+ # @example
77
+ # Gitlab.group_billable_members(1)
78
+ # Gitlab.group_billable_members(1, { per_page: 40 })
79
+ #
80
+ # @param [Integer] id The ID of a group.
81
+ # @param [Hash] options A customizable set of options.
82
+ # @option options [Integer] :page The page number.
83
+ # @option options [Integer] :per_page The number of results per page.
84
+ # @return [Array<Gitlab::ObjectifiedHash>]
85
+ def group_billable_members(id, options = {})
86
+ get("/groups/#{url_encode id}/billable_members", query: options)
87
+ end
88
+
74
89
  # Get details of a single group member.
75
90
  #
76
91
  # @example
@@ -36,6 +36,21 @@ class Gitlab::Client
36
36
  get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
37
37
  end
38
38
 
39
+ # Gets a list of Bridge Jobs from a pipeline
40
+ #
41
+ # @example
42
+ # Gitlab.pipeline_bridges(1, 2)
43
+ # Gitlab.pipeline_bridges("project", 2)
44
+ #
45
+ # @param [Integer, String] The ID or name of a project.
46
+ # @param [Integer] the id of the pipeline
47
+ # @param [Hash] options A customizable set of options.
48
+ # @option options [Array] :scope The scope of bridge jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all bridge jobs if none provided.
49
+ # @return [Array<Gitlab::ObjectifiedHash>]
50
+ def pipeline_bridges(project_id, pipeline_id, options = {})
51
+ get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/bridges", query: options)
52
+ end
53
+
39
54
  # Gets a single job
40
55
  #
41
56
  # @example
@@ -70,16 +85,70 @@ class Gitlab::Client
70
85
  # Gitlab.job_artifacts_download(1, "master", "release")
71
86
  # Gitlab.job_artifacts_download("project", "master", "release")
72
87
  #
73
- # @param [Integer, String] id, The ID or name of a project.
74
- # @param [String] ref, Ref Name
75
- # @param [String] job, jobname
76
- # @return [Array<Gitlab::ObjectifiedHash>]
88
+ # @param [Integer, String] project_id The ID or name of a project.
89
+ # @param [String] ref Ref Name
90
+ # @param [String] job jobname
91
+ # @return [Gitlab::FileResponse]
77
92
  def job_artifacts_download(project_id, ref_name, job_name)
78
- get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download", query: { job: job_name },
79
- format: nil,
80
- headers: { Accept: 'text/plain' },
81
- parser: ::Gitlab::Request::Parser)
93
+ get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download",
94
+ query: { job: job_name },
95
+ format: nil,
96
+ headers: { Accept: 'application/octet-stream' },
97
+ parser: proc { |body, _|
98
+ if body.encoding == Encoding::ASCII_8BIT # binary response
99
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
100
+ else # error with json response
101
+ ::Gitlab::Request.parse(body)
102
+ end
103
+ })
104
+ end
105
+
106
+ # Download a single artifact file by job ID
107
+ #
108
+ # @example
109
+ # Gitlab.download_job_artifact_file(1, 5, "some/release/file.pdf")
110
+ #
111
+ # @param [Integer, String] project_id(required) The ID or name of a project.
112
+ # @param [String] job_id(required) The unique job identifier.
113
+ # @param [String] artifact_path(required) Path to a file inside the artifacts archive.
114
+ # @return [Gitlab::FileResponse]
115
+ def download_job_artifact_file(project_id, job_id, artifact_path)
116
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/#{artifact_path}",
117
+ format: nil,
118
+ headers: { Accept: 'application/octet-stream' },
119
+ parser: proc { |body, _|
120
+ if body.encoding == Encoding::ASCII_8BIT # binary response
121
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
122
+ else # error with json response
123
+ ::Gitlab::Request.parse(body)
124
+ end
125
+ })
126
+ end
127
+
128
+ # Download a single artifact file from specific tag or branch
129
+ #
130
+ # @example
131
+ # Gitlab.download_branch_artifact_file(1, "master", "some/release/file.pdf", 'pdf')
132
+ #
133
+ # @param [Integer, String] project_id(required) The ID or name of a project.
134
+ # @param [String] ref_name(required) Branch or tag name in repository. HEAD or SHA references are not supported.
135
+ # @param [String] artifact_path(required) Path to a file inside the artifacts archive.
136
+ # @param [String] job(required) The name of the job.
137
+ # @return [Gitlab::FileResponse]
138
+ def download_branch_artifact_file(project_id, ref_name, artifact_path, job)
139
+ get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/raw/#{artifact_path}",
140
+ query: { job: job },
141
+ format: nil,
142
+ headers: { Accept: 'application/octet-stream' },
143
+ parser: proc { |body, _|
144
+ if body.encoding == Encoding::ASCII_8BIT # binary response
145
+ ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
146
+ else # error with json response
147
+ ::Gitlab::Request.parse(body)
148
+ end
149
+ })
82
150
  end
151
+ alias download_tag_artifact_file download_branch_artifact_file
83
152
 
84
153
  # Get Job Trace
85
154
  #