sonarqube 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +2 -1
- data/lib/sonarqube/client.rb +1 -0
- data/lib/sonarqube/client/permissions.rb +237 -0
- data/lib/sonarqube/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: 2243cd4ce1e3bccfd8852b3e288aa93e1a0d161457c3902265e2b3539384997a
|
4
|
+
data.tar.gz: 2059652b00336b55c9c4af3ea0d9d5eab29208f1944b5ae59b4f32c6fa5a9dd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b55245ca6385f98e50e861fb7fd5fba42e06c70c7d488cae559bb1e69d66cd57784944c274b6d432ca9ddc57de8a638327fa71a44c127eae4b07f3238936444c
|
7
|
+
data.tar.gz: '0832fc8d69d1030b9e120e3463a3b59ddffd85dff8992331b8ad3ce7e49894b35dca566fa87cd0fc4d796553b3e8ea31fd0a856315484bac7934925c7d18dc89'
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,17 @@
|
|
4
4
|
|
5
5
|
Please see: https://github.com/psyreactor/sonarqube-ruby/releases
|
6
6
|
|
7
|
+
### 1.2.0 (03/09/2020)
|
8
|
+
|
9
|
+
- New features
|
10
|
+
* Added support for permissions API
|
11
|
+
* Added support for premissions internal API
|
12
|
+
- Fix
|
13
|
+
* Fix Coverage
|
14
|
+
* Fix Documentation file name
|
15
|
+
- New
|
16
|
+
* Guard config
|
17
|
+
|
7
18
|
### 1.1.0 (24/08/2020)
|
8
19
|
|
9
20
|
- New features
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://img.shields.io/github/workflow/status/psyreactor/sonarqube/CI/master)](https://github.com/psyreactor/sonarqube/actions?query=workflow%3ARuby)
|
4
4
|
[![Inline docs](https://inch-ci.org/github/psyreactor/sonarqube.svg)](https://inch-ci.org/github/psyreactor/sonarqube)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/psyreactor/sonarqube/badge.svg)](https://coveralls.io/github/psyreactor/sonarqube)
|
5
6
|
[![Gem version](https://img.shields.io/gem/v/sonarqube.svg)](https://rubygems.org/gems/sonarqube)
|
6
7
|
[![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/psyreactor/sonarqube/blob/master/LICENSE.txt)
|
7
8
|
|
@@ -9,7 +10,7 @@
|
|
9
10
|
[documentation](https://www.rubydoc.info/gems/sonarqube/frames)
|
10
11
|
|
11
12
|
Sonarqube is a Ruby wrapper and CLI for the Sonarqube API
|
12
|
-
As of version `1.
|
13
|
+
As of version `1.2.0` this gem only supports Sonarqube 7.9.
|
13
14
|
|
14
15
|
## Installation
|
15
16
|
|
data/lib/sonarqube/client.rb
CHANGED
@@ -0,0 +1,237 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Sonarqube::Client
|
4
|
+
# Defines methods related to permissions.
|
5
|
+
# @see https://SONAR_URL/web_api/api/permissions
|
6
|
+
module Permissions
|
7
|
+
# Add permission to a group.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# Sonarqube.permissions_add_group({ groupName: 'New-Group', permission: 'user', projectKey: 'test' })
|
11
|
+
#
|
12
|
+
# @param [Hash] options A customizable set of options.
|
13
|
+
# @option options [String] :groupId Id of group.
|
14
|
+
# @option options [String] :groupName Name of group.
|
15
|
+
# @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user
|
16
|
+
# @option options [String] :projectId Id of project, only apply for project permissions.
|
17
|
+
# @option options [String] :projectKey Key of project, only apply for project permissions.
|
18
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_group}
|
19
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
20
|
+
def permission_add_group(options = {})
|
21
|
+
options.transform_keys(&:to_sym)
|
22
|
+
raise ArgumentError, 'Missing required parameters' if options[:groupId].nil? && options[:groupName].nil?
|
23
|
+
|
24
|
+
post('/api/permissions/add_group', body: options)
|
25
|
+
end
|
26
|
+
alias add_group_permission permission_add_group
|
27
|
+
|
28
|
+
# Add group to template.
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# Sonarqube.add_group_to_template({ groupName: 'New-Group', permission: 'user', templateName: 'test' })
|
32
|
+
#
|
33
|
+
# @param [Hash] options A customizable set of options.
|
34
|
+
# @option options [String] :groupId Id of group.
|
35
|
+
# @option options [String] :groupName Name of group.
|
36
|
+
# @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user
|
37
|
+
# @option options [String] :templateId Id of template.
|
38
|
+
# @option options [String] :templateName Name of template.
|
39
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_group_to_template}
|
40
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
41
|
+
def add_group_to_template(options = {})
|
42
|
+
options.transform_keys(&:to_sym)
|
43
|
+
raise ArgumentError, 'Missing required parameters' if options[:groupId].nil? && options[:groupName].nil?
|
44
|
+
|
45
|
+
post('/api/permissions/add_group_to_template', body: options)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Add project creator to template.
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# Sonarqube.add_project_creator_to_template('issueadmin', { templateName: 'test' })
|
52
|
+
#
|
53
|
+
# @param [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user
|
54
|
+
# @param [Hash] options A customizable set of options.
|
55
|
+
# @option options [String] :templateId Id of template.
|
56
|
+
# @option options [String] :templateName Name of template.
|
57
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_project_creator_to_template}
|
58
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
59
|
+
def add_project_creator_to_template(permission, options = {})
|
60
|
+
raise ArgumentError, 'Missing required parameters' if permission.nil?
|
61
|
+
|
62
|
+
post('/api/permissions/add_project_creator_to_template', body: { permission: permission }.merge!(options))
|
63
|
+
end
|
64
|
+
|
65
|
+
# Add permissions to user.
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# Sonarqube.permission_add_user('new_user', 'issueadmin', { projectKey: 'test' })
|
69
|
+
#
|
70
|
+
# @param [String] :login Name of login user.
|
71
|
+
# @param [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user
|
72
|
+
# @param [Hash] options A customizable set of options.
|
73
|
+
# @option options [String] :projectId Id of project, only apply for project permissions.
|
74
|
+
# @option options [String] :projectKey Key of project, only apply for project permissions.
|
75
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_user}
|
76
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
77
|
+
def permission_add_user(login, permission, options = {})
|
78
|
+
options.transform_keys(&:to_sym)
|
79
|
+
raise ArgumentError, 'Missing required parameters' if login.nil? && permission.nil?
|
80
|
+
|
81
|
+
body = { login: login, permission: permission }.merge!(options)
|
82
|
+
post('/api/permissions/add_user', body: body)
|
83
|
+
end
|
84
|
+
alias add_user_permission permission_add_user
|
85
|
+
|
86
|
+
# Add user to template.
|
87
|
+
#
|
88
|
+
# @example
|
89
|
+
# Sonarqube.add_user_to_template({ 'new_user', 'issueadmin', { templateName: 'test' })
|
90
|
+
#
|
91
|
+
# @param [String] :login Name of login user.
|
92
|
+
# @param [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user.
|
93
|
+
# @param [Hash] options A customizable set of options.
|
94
|
+
# @option options [String] :templateId Id of template.
|
95
|
+
# @option options [String] :templateName Name of template.
|
96
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_user_to_template}
|
97
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
98
|
+
def add_user_to_template(login, permission, options = {})
|
99
|
+
options.transform_keys(&:to_sym)
|
100
|
+
raise ArgumentError, 'Missing required parameters' if login.nil? && permission.nil?
|
101
|
+
|
102
|
+
body = { login: login, permission: permission }.merge!(options)
|
103
|
+
post('/api/permissions/add_user_to_template', body: body)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Apply template.
|
107
|
+
#
|
108
|
+
# @example
|
109
|
+
# Sonarqube.apply_template({ projectName: 'New-Group', templateName: 'test' })
|
110
|
+
#
|
111
|
+
# @param [Hash] options A customizable set of options.
|
112
|
+
# @option options [String] :projectId Id of group.
|
113
|
+
# @option options [String] :projectName Name of group.
|
114
|
+
# @option options [String] :templateId Id of template.
|
115
|
+
# @option options [String] :templateName Name of template.
|
116
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/apply_template}
|
117
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
118
|
+
def apply_template(options = {})
|
119
|
+
options.transform_keys(&:to_sym)
|
120
|
+
|
121
|
+
post('/api/permissions/apply_template', body: options)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Bulk apply template.
|
125
|
+
#
|
126
|
+
# @example
|
127
|
+
# Sonarqube.bulk_apply_template({ templateName: 'test', projects: 'my_project,another_project' })
|
128
|
+
#
|
129
|
+
# @param [Hash] options A customizable set of options.
|
130
|
+
# @option options [String] :analyzedBefore Filter the projects for which last analysis is older than the given date .
|
131
|
+
# @option options [String] :onProvisionedOnly Filter the projects that are provisioned.
|
132
|
+
# @option options [String] :projects Comma-separated list of project keys maximum 1000
|
133
|
+
# @option options [String] :q serach project names that contain the supplied string and project keys that are exactly the same as the supplied string
|
134
|
+
# @option options [String] :qualifiers Comma-separated list of component qualifiers. Filter the results with the specified qualifiers.
|
135
|
+
# @option options [String] :templateId Id of template.
|
136
|
+
# @option options [String] :templateName Name of template.
|
137
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/bulk_apply_template}
|
138
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
139
|
+
def bulk_apply_template(options = {})
|
140
|
+
options.transform_keys(&:to_sym)
|
141
|
+
|
142
|
+
post('/api/permissions/bulk_apply_template', body: options)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Create template.
|
146
|
+
#
|
147
|
+
# @example
|
148
|
+
# Sonarqube.create_template('template_name', 'description', '.*\.finance\..*')
|
149
|
+
#
|
150
|
+
# @param [String] :name Name of template.
|
151
|
+
# @param [String] :project_key_pattern Project key pattern. Must be a valid Java regular expression.
|
152
|
+
# @param [String] :description Description of template.
|
153
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/create_template}
|
154
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
155
|
+
def create_template(name, description, project_key_pattern)
|
156
|
+
body = { name: name, description: description, projectKeyPattern: project_key_pattern }
|
157
|
+
post('/api/permissions/create_template', body: body)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Delete template.
|
161
|
+
#
|
162
|
+
# @example
|
163
|
+
# Sonarqube.create_template({ templateName: 'template_name' })
|
164
|
+
#
|
165
|
+
# @param [Hash] options A customizable set of options.
|
166
|
+
# @option options [String] :templateId Id of template.
|
167
|
+
# @option options [String] :templateName Name of template.
|
168
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/delete_template}
|
169
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
170
|
+
def delete_template(options = {})
|
171
|
+
options.transform_keys(&:to_sym)
|
172
|
+
raise ArgumentError, 'Missing required parameters' if options[:templateName].nil? && options[:templateId].nil?
|
173
|
+
|
174
|
+
post('/api/permissions/delete_template', body: options)
|
175
|
+
end
|
176
|
+
|
177
|
+
# Remove permission to a group.
|
178
|
+
#
|
179
|
+
# @example
|
180
|
+
# Sonarqube.permissions_add_group({ groupName: 'New-Group', permission: permission, projectKey: 'test' })
|
181
|
+
#
|
182
|
+
# @param [Hash] options A customizable set of options.
|
183
|
+
# @option options [String] :groupId Id of group.
|
184
|
+
# @option options [String] :groupName Name of group.
|
185
|
+
# @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user
|
186
|
+
# @option options [String] :projectId Id of project, only apply for project permissions.
|
187
|
+
# @option options [String] :projectKey Key of project, only apply for project permissions.
|
188
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/remove_group}
|
189
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
190
|
+
def permission_remove_group(options = {})
|
191
|
+
options.transform_keys(&:to_sym)
|
192
|
+
raise ArgumentError, 'Missing required parameters' if options[:groupId].nil? && options[:groupName].nil?
|
193
|
+
|
194
|
+
post('/api/permissions/remove_group', body: options)
|
195
|
+
end
|
196
|
+
alias remove_group_permission permission_remove_group
|
197
|
+
|
198
|
+
# Remove group from template.
|
199
|
+
#
|
200
|
+
# @example
|
201
|
+
# Sonarqube.remove_group_from_template({ groupName: 'New-Group', permission: 'permission', templateId: 'test' })
|
202
|
+
#
|
203
|
+
# @param [Hash] options A customizable set of options.
|
204
|
+
# @option options [String] :groupId Id of group.
|
205
|
+
# @option options [String] :groupName Name of group.
|
206
|
+
# @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user
|
207
|
+
# @option options [String] :TemplateId Id of template.
|
208
|
+
# @option options [String] :TemplateName Name of template.
|
209
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/remove_group_from_template}
|
210
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
211
|
+
def remove_group_from_template(options = {})
|
212
|
+
post('/api/permissions/remove_group_from_template', body: options)
|
213
|
+
end
|
214
|
+
|
215
|
+
# Lists the groups with their permissions
|
216
|
+
#
|
217
|
+
# @example
|
218
|
+
# Sonarqube.permission_list_group({ q: 'test', projectsKey: 'project' })
|
219
|
+
#
|
220
|
+
# @param [Hash] options A customizable set of options.
|
221
|
+
# @option options [String] :organization Key of organization, used when group name is set
|
222
|
+
# @option options [String] :p 1-based page number.
|
223
|
+
# @option options [String] :permission Possible values for global permissions or values for project permissions.
|
224
|
+
# @option options [String] :q Limit search to group names that contain the supplied string.
|
225
|
+
# @option options [String] :ps Page size. Must be greater than 0 and less or equal than 100
|
226
|
+
# @option options [String] :projectId Id of project.
|
227
|
+
# @option options [String] :projectKey Key of project.
|
228
|
+
# (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/groups?internal=true}
|
229
|
+
# @return [<Sonarqube::ObjectifiedHash>]
|
230
|
+
def permission_list_group(options = {})
|
231
|
+
options.transform_keys(&:to_sym)
|
232
|
+
|
233
|
+
get('/api/permissions/groups', quey: options)
|
234
|
+
end
|
235
|
+
alias list_group_permission permission_list_group
|
236
|
+
end
|
237
|
+
end
|
data/lib/sonarqube/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sonarqube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mariani Lucas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/sonarqube/api.rb
|
107
107
|
- lib/sonarqube/client.rb
|
108
108
|
- lib/sonarqube/client/groups.rb
|
109
|
+
- lib/sonarqube/client/permissions.rb
|
109
110
|
- lib/sonarqube/client/projects.rb
|
110
111
|
- lib/sonarqube/client/tokens.rb
|
111
112
|
- lib/sonarqube/client/users.rb
|