gitlab 4.14.1 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gitlab/client.rb +1 -0
- data/lib/gitlab/client/epic_issues.rb +23 -0
- data/lib/gitlab/client/merge_request_approvals.rb +56 -0
- data/lib/gitlab/client/notes.rb +27 -0
- data/lib/gitlab/client/users.rb +14 -0
- data/lib/gitlab/error.rb +8 -0
- data/lib/gitlab/paginated_response.rb +9 -8
- data/lib/gitlab/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f31547d74eb68a029e6ececac63595ce326ac6094976d95e05ab48f1d204af82
|
4
|
+
data.tar.gz: eb18b54380caf556ada2c54475e2a15b0c4fc6b4f88fab3910c15b0db707d949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d5f11f031804e7881179e148766674d9aaf403b3bc2675e17d64c82c404d44ed71187b0942ae181843ccc8b5273fc585f35e17427983fd1e6c856497fb919f2
|
7
|
+
data.tar.gz: d5dd62edc23d215fdd48d20af5c8d544ea7afc32418ea10764a27c231ca9a9060fedd3ee5bbc8d456eaa91120ecd43584f7baf819ecd67168a8dcefbd9b15f41
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Gitlab
|
2
2
|
|
3
|
-
[![Build Status](https://img.shields.io/github/workflow/status/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)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/2e310b334b1b5db4a7e1/maintainability)](https://codeclimate.com/github/NARKOZ/gitlab)
|
5
5
|
[![Inline docs](https://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab)
|
6
6
|
[![Gem version](https://img.shields.io/gem/v/gitlab.svg)](https://rubygems.org/gems/gitlab)
|
data/lib/gitlab/client.rb
CHANGED
@@ -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
|
@@ -31,6 +31,62 @@ class Gitlab::Client
|
|
31
31
|
post("/projects/#{url_encode project}/approvals", body: options)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Gets MR Approval Rules for a project
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# Gitlab.project_merge_request_approval_rules(1)
|
38
|
+
#
|
39
|
+
# @param [Integer] project The ID of a project.
|
40
|
+
# @return [Gitlab::ObjectifiedHash] MR approval rules for the project
|
41
|
+
def project_merge_request_approval_rules(project)
|
42
|
+
get("/projects/#{url_encode project}/approval_rules")
|
43
|
+
end
|
44
|
+
|
45
|
+
# Create MR Approval Rule for a project
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# Gitlab.create_project_merge_request_approval_rule(1, {name: "security", approvals_required: 1})
|
49
|
+
#
|
50
|
+
# @param [Integer] project(required) The ID of a project.
|
51
|
+
# @option options [String] :name(required) The name of the approval rule
|
52
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
53
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
54
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
55
|
+
# @option options [Array] :protected_branch_ids(optional) The ids of protected branches to scope the rule by
|
56
|
+
# @return [Gitlab::ObjectifiedHash] New MR approval rule
|
57
|
+
def create_project_merge_request_approval_rule(project, options = {})
|
58
|
+
post("/projects/#{url_encode project}/approval_rules", body: options)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Update MR Approval Rule for a project
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# Gitlab.update_project_merge_request_approval_rule(1, {name: "security", approvals_required: 2})
|
65
|
+
#
|
66
|
+
# @param [Integer] project(required) The ID of a project.
|
67
|
+
# @param [Integer] approval_rule_id(required) The ID of a project Approval Rule
|
68
|
+
# @option options [String] :name(required) The name of the approval rule
|
69
|
+
# @option options [Integer] :approvals_required(required) The number of required approvals for this rule
|
70
|
+
# @option options [Array] :user_ids(optional) The ids of users as approvers
|
71
|
+
# @option options [Array] :group_ids(optional) The ids of groups as approvers
|
72
|
+
# @option options [Array] :protected_branch_ids(optional) The ids of protected branches to scope the rule by
|
73
|
+
# @return [Gitlab::ObjectifiedHash] Updated MR approval rule
|
74
|
+
def update_project_merge_request_approval_rule(project, approval_rule_id, options = {})
|
75
|
+
put("/projects/#{url_encode project}/approval_rules/#{approval_rule_id}", body: options)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Delete MR Approval Rule for a project
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Gitlab.delete_project_merge_request_approval_rule(1, 1)
|
82
|
+
#
|
83
|
+
# @param [Integer] project(required) The ID of a project.
|
84
|
+
# @param [Integer] approval_rule_id(required) The ID of a approval rule
|
85
|
+
# @return [void] This API call returns an empty response body
|
86
|
+
def delete_project_merge_request_approval_rule(project, approval_rule_id)
|
87
|
+
delete("/projects/#{url_encode project}/approval_rules/#{approval_rule_id}")
|
88
|
+
end
|
89
|
+
|
34
90
|
# Change allowed approvers and approver groups for a project
|
35
91
|
#
|
36
92
|
# @example
|
data/lib/gitlab/client/notes.rb
CHANGED
@@ -60,6 +60,20 @@ class Gitlab::Client
|
|
60
60
|
end
|
61
61
|
alias merge_request_comments merge_request_notes
|
62
62
|
|
63
|
+
# Gets a list of notes for an epic.
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# Gitlab.epic_notes(5, 10)
|
67
|
+
#
|
68
|
+
# @param [Integer] project The ID of a group.
|
69
|
+
# @param [Integer] epic The ID of an epic.
|
70
|
+
# @option options [Integer] :page The page number.
|
71
|
+
# @option options [Integer] :per_page The number of results per page.
|
72
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
73
|
+
def epic_notes(group, epic, options = {})
|
74
|
+
get("/groups/#{url_encode group}/epics/#{epic}/notes", query: options)
|
75
|
+
end
|
76
|
+
|
63
77
|
# Gets a single wall note.
|
64
78
|
#
|
65
79
|
# @example
|
@@ -162,6 +176,19 @@ class Gitlab::Client
|
|
162
176
|
end
|
163
177
|
alias create_merge_request_comment create_merge_request_note
|
164
178
|
|
179
|
+
# Creates a new epic note.
|
180
|
+
#
|
181
|
+
# @example
|
182
|
+
# Gitlab.create_epic_note(6, 1, 'Adding a note to my epic.')
|
183
|
+
#
|
184
|
+
# @param [Integer, String] group The ID or name of a group.
|
185
|
+
# @param [Integer] epic The ID of an epic.
|
186
|
+
# @param [String] body The body of a note.
|
187
|
+
# @return [Gitlab::ObjectifiedHash] Information about created note.
|
188
|
+
def create_epic_note(group, epic, body)
|
189
|
+
post("/groups/#{url_encode group}/epics/#{epic}/notes", body: { body: body })
|
190
|
+
end
|
191
|
+
|
165
192
|
# Deletes a wall note.
|
166
193
|
#
|
167
194
|
# @example
|
data/lib/gitlab/client/users.rb
CHANGED
@@ -123,6 +123,20 @@ class Gitlab::Client
|
|
123
123
|
post('/session', body: { email: email, password: password }, unauthenticated: true)
|
124
124
|
end
|
125
125
|
|
126
|
+
# Gets a list of user activities (for admin access only).
|
127
|
+
#
|
128
|
+
# @example
|
129
|
+
# Gitlab.activities
|
130
|
+
#
|
131
|
+
# @param [Hash] options A customizable set of options.
|
132
|
+
# @option options [Integer] :page The page number.
|
133
|
+
# @option options [Integer] :per_page The number of results per page.
|
134
|
+
# @option options [String] :from The start date for paginated results.
|
135
|
+
# @return [Array<Gitlab::ObjectifiedHash>]
|
136
|
+
def activities(options = {})
|
137
|
+
get('/user/activities', query: options)
|
138
|
+
end
|
139
|
+
|
126
140
|
# Gets a list of user's SSH keys.
|
127
141
|
#
|
128
142
|
# @example
|
data/lib/gitlab/error.rb
CHANGED
@@ -63,6 +63,14 @@ module Gitlab
|
|
63
63
|
else
|
64
64
|
@response.parsed_response
|
65
65
|
end
|
66
|
+
rescue Gitlab::Error::Parsing
|
67
|
+
# Return stringified response when receiving a
|
68
|
+
# parsing error to avoid obfuscation of the
|
69
|
+
# api error.
|
70
|
+
#
|
71
|
+
# note: The Gitlab API does not always return valid
|
72
|
+
# JSON when there are errors.
|
73
|
+
@response.to_s
|
66
74
|
end
|
67
75
|
|
68
76
|
# Handle error response message in case of nested hashes
|
@@ -83,8 +83,7 @@ module Gitlab
|
|
83
83
|
def last_page
|
84
84
|
return nil if @client.nil? || !has_last_page?
|
85
85
|
|
86
|
-
|
87
|
-
@client.get(path)
|
86
|
+
@client.get(client_relative_path(@links.last))
|
88
87
|
end
|
89
88
|
|
90
89
|
def first_page?
|
@@ -95,8 +94,7 @@ module Gitlab
|
|
95
94
|
def first_page
|
96
95
|
return nil if @client.nil? || !has_first_page?
|
97
96
|
|
98
|
-
|
99
|
-
@client.get(path)
|
97
|
+
@client.get(client_relative_path(@links.first))
|
100
98
|
end
|
101
99
|
|
102
100
|
def next_page?
|
@@ -107,8 +105,7 @@ module Gitlab
|
|
107
105
|
def next_page
|
108
106
|
return nil if @client.nil? || !has_next_page?
|
109
107
|
|
110
|
-
|
111
|
-
@client.get(path)
|
108
|
+
@client.get(client_relative_path(@links.next))
|
112
109
|
end
|
113
110
|
|
114
111
|
def prev_page?
|
@@ -119,8 +116,12 @@ module Gitlab
|
|
119
116
|
def prev_page
|
120
117
|
return nil if @client.nil? || !has_prev_page?
|
121
118
|
|
122
|
-
|
123
|
-
|
119
|
+
@client.get(client_relative_path(@links.prev))
|
120
|
+
end
|
121
|
+
|
122
|
+
def client_relative_path(link)
|
123
|
+
client_endpoint_path = URI.parse(@client.endpoint).request_uri # api/v4
|
124
|
+
URI.parse(link).request_uri.sub(client_endpoint_path, '')
|
124
125
|
end
|
125
126
|
end
|
126
127
|
end
|
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.15.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: 2020-
|
12
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/gitlab/client/container_registry.rb
|
125
125
|
- lib/gitlab/client/deployments.rb
|
126
126
|
- lib/gitlab/client/environments.rb
|
127
|
+
- lib/gitlab/client/epic_issues.rb
|
127
128
|
- lib/gitlab/client/epics.rb
|
128
129
|
- lib/gitlab/client/events.rb
|
129
130
|
- lib/gitlab/client/features.rb
|