gitlab 4.18.0 → 4.19.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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +14 -11
- data/lib/gitlab/client/groups.rb +34 -0
- data/lib/gitlab/client/merge_requests.rb +12 -0
- data/lib/gitlab/client/packages.rb +95 -0
- data/lib/gitlab/client/repositories.rb +17 -0
- data/lib/gitlab/client/users.rb +11 -0
- data/lib/gitlab/client.rb +2 -1
- data/lib/gitlab/error.rb +17 -1
- data/lib/gitlab/request.rb +1 -1
- data/lib/gitlab/version.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 020a259d1d6822f810e1dc2c112d59bf46d453b7cf1840299c0f4d7208f4ac97
|
4
|
+
data.tar.gz: 791cce56832e0089a9dc1c25efedf2d5fe1569e43b40f820ab4c935dede9222b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cebd397716351c091a448af4305e81f9ca188df3c966291d1d55e5b9cc01a0ba534c65716acd5f121017e09a87209bffcf688976e36deffe1385b81360d29dd0
|
7
|
+
data.tar.gz: b972182f6edb9d0418f850172652585397d1601713e8c5e171342f382f73a1169c0c79fd068b48cecf21deddc5be933daeb20b75d1b31329e9eb82e94c3c1965
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Gitlab
|
2
2
|
|
3
|
-
[](https://github.com/NARKOZ/gitlab/actions
|
4
|
-
[](https://inch-ci.org/github/NARKOZ/gitlab)
|
3
|
+
[](https://github.com/NARKOZ/gitlab/actions/workflows/ci.yml)
|
5
4
|
[](https://rubygems.org/gems/gitlab)
|
6
5
|
[](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt)
|
7
6
|
|
@@ -9,8 +8,7 @@
|
|
9
8
|
[documentation](https://www.rubydoc.info/gems/gitlab/frames) |
|
10
9
|
[gitlab-live](https://github.com/NARKOZ/gitlab-live)
|
11
10
|
|
12
|
-
Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/
|
13
|
-
As of version `4.0.0` this gem only supports GitLab API v4.
|
11
|
+
Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ee/api/index.html).
|
14
12
|
|
15
13
|
## Installation
|
16
14
|
|
@@ -97,6 +95,10 @@ Gitlab.sudo = 'other_user'
|
|
97
95
|
Gitlab.sudo = nil
|
98
96
|
# => nil
|
99
97
|
|
98
|
+
# set the private token to an empty string to make unauthenticated API requests
|
99
|
+
Gitlab.private_token = ''
|
100
|
+
# => ""
|
101
|
+
|
100
102
|
# a paginated response
|
101
103
|
projects = Gitlab.projects(per_page: 5)
|
102
104
|
|
@@ -121,8 +123,9 @@ For more information, refer to [documentation](https://www.rubydoc.info/gems/git
|
|
121
123
|
|
122
124
|
It is possible to use this gem as a command line interface to GitLab. In order to make that work you need to set a few environment variables:
|
123
125
|
```sh
|
124
|
-
export GITLAB_API_ENDPOINT=https://gitlab.
|
125
|
-
export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/
|
126
|
+
export GITLAB_API_ENDPOINT=https://gitlab.example.com/api/v4
|
127
|
+
export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/personal_access_tokens>
|
128
|
+
|
126
129
|
# This one is optional and can be used to set any HTTParty option you may need
|
127
130
|
# using YAML hash syntax. For example, this is how you would disable SSL
|
128
131
|
# verification (useful if using a self-signed cert).
|
@@ -131,21 +134,21 @@ export GITLAB_API_HTTPARTY_OPTIONS="{verify: false}"
|
|
131
134
|
|
132
135
|
Usage:
|
133
136
|
|
134
|
-
When you want to know which CLI commands are supported, take a look at the client [commands implemented in this gem](https://www.rubydoc.info/gems/gitlab/4.
|
137
|
+
When you want to know which CLI commands are supported, take a look at the client [commands implemented in this gem](https://www.rubydoc.info/gems/gitlab/4.18.0/Gitlab/Client). Any of those methods can be called as a command by passing the parameters of the commands as parameters of the CLI.
|
135
138
|
|
136
139
|
Usage examples:
|
137
140
|
|
138
141
|
```sh
|
139
142
|
# list users
|
140
|
-
# see: https://www.rubydoc.info/gems/gitlab/
|
143
|
+
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/Users#users-instance_method
|
141
144
|
gitlab users
|
142
145
|
|
143
146
|
# get current user
|
144
|
-
# see: https://www.rubydoc.info/gems/gitlab/
|
147
|
+
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/Users#user-instance_method
|
145
148
|
gitlab user
|
146
149
|
|
147
150
|
# get a user
|
148
|
-
# see: https://www.rubydoc.info/gems/gitlab/
|
151
|
+
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/Users#user-instance_method
|
149
152
|
gitlab user 2
|
150
153
|
|
151
154
|
# filter output
|
@@ -157,7 +160,7 @@ gitlab user --except=email,bio
|
|
157
160
|
gitlab user 2 --json
|
158
161
|
|
159
162
|
# passing options hash to a command (use YAML)
|
160
|
-
# see: https://www.rubydoc.info/gems/gitlab/
|
163
|
+
# see: https://www.rubydoc.info/gems/gitlab/Gitlab/Client/MergeRequests#create_merge_request-instance_method
|
161
164
|
gitlab create_merge_request 4 "New merge request" "{source_branch: 'new_branch', target_branch: 'master', assignee_id: 42}"
|
162
165
|
|
163
166
|
```
|
data/lib/gitlab/client/groups.rb
CHANGED
@@ -71,6 +71,40 @@ class Gitlab::Client
|
|
71
71
|
get("/groups/#{url_encode id}/members", query: options)
|
72
72
|
end
|
73
73
|
|
74
|
+
# Gets a list of all group members including inherited members.
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Gitlab.all_group_members(1)
|
78
|
+
# Gitlab.all_group_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 all_group_members(id, options = {})
|
86
|
+
get("/groups/#{url_encode id}/members/all", query: options)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Get a list of descendant groups of a group.
|
90
|
+
#
|
91
|
+
# @example
|
92
|
+
# Gitlab.group_descendants(42)
|
93
|
+
#
|
94
|
+
# @param [Integer] id the ID of a group
|
95
|
+
# @param [Hash] options A customizable set of options.
|
96
|
+
# @option options [String] :skip_groups Skip the group IDs passed.
|
97
|
+
# @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
|
98
|
+
# @option options [String] :search Return the list of authorized groups matching the search criteria.
|
99
|
+
# @option options [String] :order_by Order groups by name or path. Default is name.
|
100
|
+
# @option options [String] :sort Order groups in asc or desc order. Default is asc.
|
101
|
+
# @option options [String] :statistics Include group statistics (admins only).
|
102
|
+
# @option options [String] :owned Limit to groups owned by the current user.
|
103
|
+
# @return [Array<Gitlab::ObjectifiedHash>] List of all subgroups under a group
|
104
|
+
def group_descendants(id, options = {})
|
105
|
+
get("/groups/#{url_encode id}/descendant_groups", query: options)
|
106
|
+
end
|
107
|
+
|
74
108
|
# Get a list of group members that are billable.
|
75
109
|
#
|
76
110
|
# @example
|
@@ -332,6 +332,18 @@ class Gitlab::Client
|
|
332
332
|
delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}")
|
333
333
|
end
|
334
334
|
|
335
|
+
# Delete a merge request
|
336
|
+
#
|
337
|
+
# @example
|
338
|
+
# Gitlab.delete_merge_request(5, 1)
|
339
|
+
# Gitlab.delete_merge_request('gitlab', 1)
|
340
|
+
# @param [Integer, String] project The ID or name of a project.
|
341
|
+
# @param [Integer] id The ID of a merge request.
|
342
|
+
# @return [Gitlab::ObjectifiedHash] An empty response.
|
343
|
+
def delete_merge_request(project, merge_request_id)
|
344
|
+
delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}")
|
345
|
+
end
|
346
|
+
|
335
347
|
# Gets a list of merge request diff versions
|
336
348
|
#
|
337
349
|
# @example
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Gitlab::Client
|
4
|
+
# Defines methods related to GitLab Packages.
|
5
|
+
# @see https://docs.gitlab.com/ee/api/packages.html
|
6
|
+
module Packages
|
7
|
+
# Gets a list of project packages.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Gitlab.project_packages(5)
|
11
|
+
# Gitlab.project_packages(5, { package_type: 'npm', sort: 'desc' })
|
12
|
+
#
|
13
|
+
# @param [Integer, String] :project the ID or name of a project.
|
14
|
+
# @param [Hash] options A customizable set of options.
|
15
|
+
# @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
|
16
|
+
# @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
|
17
|
+
# @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
|
18
|
+
# @options options [String] :package_name Filter the project packages with a fuzzy search by name.
|
19
|
+
# @options options [String] :include_versionless When set to true, versionless packages are included in the response.
|
20
|
+
# @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
|
21
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
22
|
+
def project_packages(project, options = {})
|
23
|
+
get("/projects/#{url_encode project}/packages", query: options)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Gets a list of project packages.
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# Gitlab.group_packages(5)
|
30
|
+
# Gitlab.group_packages(5, { package_type: 'npm', sort: 'desc' })
|
31
|
+
#
|
32
|
+
# @param [Integer, String] project the ID or name of a project.
|
33
|
+
# @param [Hash] options A customizable set of options.
|
34
|
+
# @options options [String] :exclude_subgroups If the parameter is included as true, packages from projects from subgroups are not listed. Default is false.
|
35
|
+
# @options options [String] :order_by The field to use as order. One of created_at (default), name, version, or type.
|
36
|
+
# @options options [String] :sort The direction of the order, either asc (default) for ascending order or desc for descending order.
|
37
|
+
# @options options [String] :package_type Filter the returned packages by type. One of conan, maven, npm, pypi, composer, nuget, helm, terraform_module, or golang.
|
38
|
+
# @options options [String] :package_name Filter the project packages with a fuzzy search by name.
|
39
|
+
# @options options [String] :include_versionless When set to true, versionless packages are included in the response.
|
40
|
+
# @options options [String] :status Filter the returned packages by status. One of default (default), hidden, processing, error, or pending_destruction.
|
41
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
42
|
+
def group_packages(group, options = {})
|
43
|
+
get("/groups/#{url_encode group}/packages", query: options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get a single project package.
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# Gitlab.project_package(5, 3)
|
50
|
+
#
|
51
|
+
# @param [Integer, String] project The ID or name of a project.
|
52
|
+
# @param [Integer] id ID of a package.
|
53
|
+
# @return [Gitlab::ObjectifiedHash]
|
54
|
+
def project_package(project, id)
|
55
|
+
get("/projects/#{url_encode project}/packages/#{id}")
|
56
|
+
end
|
57
|
+
|
58
|
+
# Get a list of package files of a single package.
|
59
|
+
#
|
60
|
+
# @example
|
61
|
+
# Gitlab.project_package_files(5, 3)
|
62
|
+
#
|
63
|
+
# @param [Integer, String] project The ID or name of a project.
|
64
|
+
# @param [Integer] id ID of a package.
|
65
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
66
|
+
def project_package_files(project, id)
|
67
|
+
get("/projects/#{url_encode project}/packages/#{id}/package_files")
|
68
|
+
end
|
69
|
+
|
70
|
+
# Deletes a project package.
|
71
|
+
#
|
72
|
+
# @example
|
73
|
+
# Gitlab.delete_project_package(5, 3)
|
74
|
+
#
|
75
|
+
# @param [Integer, String] project The ID or name of a project.
|
76
|
+
# @param [Integer] id ID of a package.
|
77
|
+
# @return [void] This API call returns an empty response body.
|
78
|
+
def delete_project_package(project, id)
|
79
|
+
delete("/projects/#{url_encode project}/packages/#{id}")
|
80
|
+
end
|
81
|
+
|
82
|
+
# Delete a package file.
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
# Gitlab.delete_project_file(5, 3, 1)
|
86
|
+
#
|
87
|
+
# @param [Integer, String] project The ID or name of a project.
|
88
|
+
# @param [Integer] package_id ID of a package.
|
89
|
+
# @param [Integer] file_id ID of a package file.
|
90
|
+
# @return [void] This API call returns an empty response body.
|
91
|
+
def delete_project_package_file(project, package_id, file_id)
|
92
|
+
delete("/projects/#{url_encode project}/packages/#{package_id}/package_files/#{file_id}")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -109,5 +109,22 @@ class Gitlab::Client
|
|
109
109
|
def generate_changelog(project, version, options = {})
|
110
110
|
post("/projects/#{url_encode project}/repository/changelog", body: options.merge(version: version))
|
111
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
|
112
129
|
end
|
113
130
|
end
|
data/lib/gitlab/client/users.rb
CHANGED
@@ -110,6 +110,17 @@ class Gitlab::Client
|
|
110
110
|
post("/users/#{user_id}/unblock")
|
111
111
|
end
|
112
112
|
|
113
|
+
# Approves the specified user. Available only for admin.
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# Gitlab.approve_user(15)
|
117
|
+
#
|
118
|
+
# @param [Integer] user_id The Id of user
|
119
|
+
# @return [Boolean] success or not
|
120
|
+
def approve_user(user_id)
|
121
|
+
post("/users/#{user_id}/approve")
|
122
|
+
end
|
123
|
+
|
113
124
|
# Creates a new user session.
|
114
125
|
#
|
115
126
|
# @example
|
data/lib/gitlab/client.rb
CHANGED
@@ -40,6 +40,7 @@ module Gitlab
|
|
40
40
|
include Milestones
|
41
41
|
include Namespaces
|
42
42
|
include Notes
|
43
|
+
include Packages
|
43
44
|
include PipelineSchedules
|
44
45
|
include PipelineTriggers
|
45
46
|
include Pipelines
|
@@ -89,7 +90,7 @@ module Gitlab
|
|
89
90
|
private
|
90
91
|
|
91
92
|
def only_show_last_four_chars(token)
|
92
|
-
"#{'*' * (token.size - 4)}#{token[-4
|
93
|
+
"#{'*' * (token.size - 4)}#{token[-4..]}"
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
data/lib/gitlab/error.rb
CHANGED
@@ -135,6 +135,9 @@ module Gitlab
|
|
135
135
|
# Raised when API endpoint returns the HTTP status code 503.
|
136
136
|
class ServiceUnavailable < ResponseError; end
|
137
137
|
|
138
|
+
# Raised when API endpoint returns the HTTP status code 522.
|
139
|
+
class ConnectionTimedOut < ResponseError; end
|
140
|
+
|
138
141
|
# HTTP status codes mapped to error classes.
|
139
142
|
STATUS_MAPPINGS = {
|
140
143
|
400 => BadRequest,
|
@@ -148,7 +151,20 @@ module Gitlab
|
|
148
151
|
429 => TooManyRequests,
|
149
152
|
500 => InternalServerError,
|
150
153
|
502 => BadGateway,
|
151
|
-
503 => ServiceUnavailable
|
154
|
+
503 => ServiceUnavailable,
|
155
|
+
522 => ConnectionTimedOut
|
152
156
|
}.freeze
|
157
|
+
|
158
|
+
# Returns error class that should be raised for this response. Returns nil
|
159
|
+
# if the response status code is not 4xx or 5xx.
|
160
|
+
#
|
161
|
+
# @param [HTTParty::Response] response The response object.
|
162
|
+
# @return [Class<Error::ResponseError>, nil]
|
163
|
+
def self.klass(response)
|
164
|
+
error_klass = STATUS_MAPPINGS[response.code]
|
165
|
+
return error_klass if error_klass
|
166
|
+
|
167
|
+
ResponseError if response.server_error? || response.client_error?
|
168
|
+
end
|
153
169
|
end
|
154
170
|
end
|
data/lib/gitlab/request.rb
CHANGED
@@ -67,7 +67,7 @@ module Gitlab
|
|
67
67
|
# Checks the response code for common errors.
|
68
68
|
# Returns parsed response for successful requests.
|
69
69
|
def validate(response)
|
70
|
-
error_klass = Error
|
70
|
+
error_klass = Error.klass(response)
|
71
71
|
raise error_klass, response if error_klass
|
72
72
|
|
73
73
|
parsed = response.parsed_response
|
data/lib/gitlab/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nihad Abbasov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0.
|
20
|
+
version: '0.20'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0.
|
27
|
+
version: '0.20'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: terminal-table
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/gitlab/client/milestones.rb
|
134
134
|
- lib/gitlab/client/namespaces.rb
|
135
135
|
- lib/gitlab/client/notes.rb
|
136
|
+
- lib/gitlab/client/packages.rb
|
136
137
|
- lib/gitlab/client/pipeline_schedules.rb
|
137
138
|
- lib/gitlab/client/pipeline_triggers.rb
|
138
139
|
- lib/gitlab/client/pipelines.rb
|
@@ -175,7 +176,12 @@ files:
|
|
175
176
|
homepage: https://github.com/NARKOZ/gitlab
|
176
177
|
licenses:
|
177
178
|
- BSD-2-Clause
|
178
|
-
metadata:
|
179
|
+
metadata:
|
180
|
+
homepage_uri: https://github.com/NARKOZ/gitlab
|
181
|
+
source_code_uri: https://github.com/NARKOZ/gitlab
|
182
|
+
bug_tracker_uri: https://github.com/NARKOZ/gitlab/issues
|
183
|
+
changelog_uri: https://github.com/NARKOZ/gitlab/releases
|
184
|
+
funding_uri: https://github.com/NARKOZ/SponsorMe
|
179
185
|
post_install_message:
|
180
186
|
rdoc_options: []
|
181
187
|
require_paths:
|
@@ -184,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
190
|
requirements:
|
185
191
|
- - ">="
|
186
192
|
- !ruby/object:Gem::Version
|
187
|
-
version: '2.
|
193
|
+
version: '2.6'
|
188
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
195
|
requirements:
|
190
196
|
- - ">="
|