sonarqube 1.0.0 → 1.2.1

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: 226a939373b149524665b8094209ab3cf99df41f2e0392fdb8bc2c4741696e01
4
- data.tar.gz: '08dd9fbb620105b33bba11f5847d25e4ea5c1f9be67ffcfab9dd2384ad58e4cb'
3
+ metadata.gz: 801fefe171e320dd14316a7c77780e29fcd1d48a42d0a72d95c82963dad8c295
4
+ data.tar.gz: 225697afc310666c0be1f710ed4be1f84d6e8fb16c2eddb66a19b170f279a74c
5
5
  SHA512:
6
- metadata.gz: 4f98a82d09ff64eb1c241bf48985fb14152b943347fa30d5067dd3482f8e94099cc118b12b7f617f0430cbcd0c49a64cef49e910de4998b1d42b91316ebc4c81
7
- data.tar.gz: 80f4924d4c7b9c921102e1f37bc267f7c1736603b7d62f2c4faba0444009caba931d95f65c74b11c2683ccc2ecbe1e1c8f33efa76ba26528e17dc7ef3761303d
6
+ metadata.gz: f925f8ec8136457b91748054cf76a03a315187f0d7145163573821f8c5d2ab1d13c13f30e2afe0280f83e6fe4232c5fccd40e10803a03f86bcb44f66a4d061fb
7
+ data.tar.gz: 432d2e44abb168f23bc425c5e673edbea93bc06f55addd0a05863c734e5d2d4a5f1db812ea3c66595d2c46c5079d126c9b532099eca4892bd1789393af02dc8d
@@ -4,6 +4,45 @@
4
4
 
5
5
  Please see: https://github.com/psyreactor/sonarqube-ruby/releases
6
6
 
7
+ ### 1.2.1 (08/09/2020)
8
+
9
+ - Fix
10
+ * Fix groups parameter validation
11
+
12
+ ### 1.2.0 (03/09/2020)
13
+
14
+ - New features
15
+ * Added support for permissions API
16
+ * Added support for premissions internal API
17
+ - Fix
18
+ * Fix Coverage
19
+ * Fix Documentation file name
20
+ - New
21
+ * Guard config
22
+
23
+ ### 1.1.0 (24/08/2020)
24
+
25
+ - New features
26
+ * Added support for users_token API
27
+ - Fix
28
+ * Fix Readme
29
+ * Add site documentation
30
+
31
+ ### 1.0.2 (24/08/2020)
32
+
33
+ - Fix
34
+ * Fix gemspec repo url
35
+
36
+ ### 1.0.1 (24/08/2020)
37
+
38
+ - Fix
39
+ * Fix YARD comments
7
40
 
8
41
  ### 1.0.0 (19/08/2020)
9
- -
42
+
43
+ - New features
44
+ * Added support for users API
45
+ * Added support for user_groups API
46
+ * Added support for projects API
47
+
48
+
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.0.0` this gem only supports Sonarqube 7.9.
13
+ As of version `1.2.1` this gem only supports Sonarqube 7.9.
13
14
 
14
15
  ## Installation
15
16
 
@@ -88,28 +89,6 @@ project.to_hash
88
89
  # => {"project"=>{"key"=>"new_project", "name"=>"new_project", "qualifier"=>"TRK", "visibility"=>"public"}}
89
90
  ```
90
91
 
91
- #### Delete Project
92
- ```ruby
93
- project = Sonarqube.project_delete('test')
94
- # => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
95
- project.to_hash.empty?
96
- # => true
97
- ```
98
-
99
- #### Search Project
100
- ```ruby
101
- projects = Sonarqube.project_search()
102
- # => #<Sonarqube::ObjectifiedHash:46240 {hash: {"paging"=>{"pageIndex"=>1, "pageSize"=>100, "total"=>2}, "components"=>[{"organization"=>"default-organization", "key"=>"old_key", "name"=>"new_proyect", "qualifier"=>"TRK", "visibility"=>"private"}, {"organization"=>"default-organization", "key"=>"test", "name"=>"test", "qualifier"=>"TRK", "visibility"=>"public"}]}}
103
- projects.components.each do | project |
104
- puts "name: #{project.name}"
105
- puts "key: #{project.key}"
106
- end
107
- # name: new_proyect
108
- # key: old_key
109
- # name: test
110
- # key: test
111
- ```
112
-
113
92
  ### Users
114
93
 
115
94
  #### Create User
@@ -122,56 +101,9 @@ user.user.name
122
101
  # name_user
123
102
  ```
124
103
 
125
- #### Delete User
126
- ```ruby
127
- user = Sonarqube.user_delete('test')
128
- # => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
129
- user.to_hash.empty?
130
- # => true
131
- ```
132
-
133
- #### Search User
134
- ```ruby
135
- users = Sonarqube.users_search()
136
- # => #<Sonarqube::ObjectifiedHash:46340 {hash: {"paging"=>{"pageIndex"=>1, "pageSize"=>50, "total"=>5}, "users"=>[{"login"=>"admin", "name"=>"Administrator", "active"=>true, "groups"=>["sonar-administrators", "sonar-users"], "tokensCount"=>1, "local"=>true, "externalIdentity"=>"admin", "externalProvider"=>"sonarqube", "lastConnectionDate"=>"2020-08-22T23:09:14+0000"}, {"login"=>"new_user", "name"=>"key_new_user", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"new_user", "externalProvider"=>"sonarqube"}, {"login"=>"login_name", "name"=>"name_user", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"login_name", "externalProvider"=>"sonarqube"}, {"login"=>"test3", "name"=>"test QA", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"test3", "externalProvider"=>"sonarqube"}, {"login"=>"newlogin", "name"=>"test QA", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"newlogin", "externalProvider"=>"sonarqube"}]}}
137
- users.users.each do | user |
138
- puts "name: #{user.name}"
139
- puts "login: #{user.login}"
140
- puts "lastConection: #{user.lastConnectionDate}" if defined? user.lastConnectionDate
141
- end
142
- # name: Administrator
143
- # login: admin
144
- # lastConection: 2020-08-22T23:09:14+0000
145
- # name: key_new_user
146
- # login: new_user
147
- # name: name_user
148
- # login: login_name
149
- # name: test QA
150
- # login: test3
151
- # name: test QA
152
- # login: newlogin
153
- ```
154
104
 
155
105
  ### Groups
156
106
 
157
- #### Create Group
158
- ```ruby
159
- group = Sonarqube.create_group('New-Group', {description: 'Sonarqube group users'})
160
- # => #<Sonarqube::ObjectifiedHash:46500 {hash: {"group"=>{"uuid"=>"AXQYrrgCsrvdoo0YodNM", "organization"=>"default-organization", "name"=>"New-Group", "description"=>"Sonarqube group users", "membersCount"=>0, "default"=>false}}}
161
- group.group.uuid
162
- # AXQYrrgCsrvdoo0YodNM
163
- group.group.description
164
- # Sonarqube group users
165
- ```
166
-
167
- #### Delete Group
168
- ```ruby
169
- group = Sonarqube.group_delete('New-Group')
170
- # => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
171
- group.to_hash.empty?
172
- # => true
173
- ```
174
-
175
107
  #### Search Group
176
108
  ```ruby
177
109
  groups = Sonarqube.search_groups({ q: 'sonar-users' })
@@ -7,7 +7,9 @@ module Sonarqube
7
7
 
8
8
  # Please keep in alphabetical order
9
9
  include Groups
10
+ include Permissions
10
11
  include Projects
12
+ include Tokens
11
13
  include Users
12
14
 
13
15
  # Text representation of the client, masking private token.
@@ -29,7 +29,7 @@ class Sonarqube::Client
29
29
  # Sonarqube.create_group('new-group')
30
30
  # Sonarqube.create_group('sonarqube', { description: 'New Sonarqube project' })
31
31
  #
32
- # @param [String] name(required) The name of a group.
32
+ # @param [String] name (required) The name of a group.
33
33
  # @param [Hash] options A customizable set of options.
34
34
  # @option options [String] :description Description for the new group. A group description cannot be larger than 200 characters.
35
35
  # @return [Sonarqube::ObjectifiedHash] Information about created group.
@@ -44,7 +44,7 @@ class Sonarqube::Client
44
44
  # @example
45
45
  # Sonarqube.delete_group('projecto')
46
46
  #
47
- # @param [String] name(required) The name of a group
47
+ # @param [String] name (required) The name of a group
48
48
  # @return [Sonarqube::ObjectifiedHash] Empty hash response.
49
49
  def delete_group(name)
50
50
  post('/api/user_groups/delete', body: { name: name })
@@ -57,7 +57,7 @@ class Sonarqube::Client
57
57
  # Sonarqube.group_members('AXQRcKrW9pRiZzanEJ2E')
58
58
  # Sonarqube.group_members('AXQRcKrW9pRiZzanEJ2E, { description: 'update group description })
59
59
  #
60
- # @param [String] id(required) The ID of a group.
60
+ # @param [String] id (required) The ID of a group.
61
61
  # @param [Hash] options A customizable set of options.
62
62
  # @option options [String] :description New optional description for the group. A group description cannot be larger than 200 characters. If value is not defined, then description is not changed.
63
63
  # @option options [String] :name New optional name for the group. A group name cannot be larger than 255 characters and must be unique. Value 'anyone' (whatever the case) is reserved and cannot be used. If value is empty or not defined, then name is not changed.
@@ -73,31 +73,31 @@ class Sonarqube::Client
73
73
  # Sonarqube.add_member('AXQRcKrW9pRiZzanEJ2E', 'test-user')
74
74
  # Sonarqube.add_member('AXQRcKrW9pRiZzanEJ2E', 'test-user', {name: 'sonar-groups'})
75
75
  #
76
- # @param [String] id(required) The id of group.
77
- # @param [String] login(required) The login of user.
76
+ # @param [String] id (required) The id of group.
77
+ # @param [String] login (required) The login of user.
78
78
  # @param [Hash] options A customizable set of options.
79
79
  # @option options [String] :name Optional name of group.
80
80
  # @return [Sonarqube::ObjectifiedHash]
81
81
  def add_member(id = nil, login = nil, options = {})
82
- raise ArgumentError, 'Missing required parameters' if id.nil? || login.nil?
82
+ raise ArgumentError, 'Missing required parameters' if id.nil? && login.nil?
83
83
 
84
84
  post('/api/user_groups/add_user', body: { id: id, login: login }.merge!(options))
85
85
  end
86
86
  alias member_add add_member
87
87
 
88
- # Reomve a user to a group.
88
+ # Remove a user to a group.
89
89
  #
90
90
  # @example
91
91
  # Sonarqube.remove_member('AXQRcKrW9pRiZzanEJ2E', 'test-user')
92
92
  # Sonarqube.remove_member('AXQRcKrW9pRiZzanEJ2E', 'test-user', {name: 'sonar-groups'})
93
93
  #
94
- # @param [String] id(required) The id of group.
95
- # @param [String] login(required) The login of user.
94
+ # @param [String] id (required) The id of group.
95
+ # @param [String] login (required) The login of user.
96
96
  # @param [Hash] options A customizable set of options.
97
97
  # @option options [String] :name Optional name of group.
98
98
  # @return [Sonarqube::ObjectifiedHash]
99
99
  def remove_member(id = nil, login = nil, options = {})
100
- raise ArgumentError, 'Missing required parameters' if id.nil? || login.nil?
100
+ raise ArgumentError, 'Missing required parameters' if id.nil? && login.nil?
101
101
 
102
102
  post('/api/user_groups/remove_user', body: { id: id, login: login }.merge!(options))
103
103
  end
@@ -110,8 +110,8 @@ class Sonarqube::Client
110
110
  # Sonarqube.list_members({name: 'sonar-groups'})
111
111
  #
112
112
  # @param [Hash] options A customizable set of options.
113
- # @option options [String] :name(required) Name of group.
114
- # @option options [String] :id(required) Id of group.
113
+ # @option options [String] :name (required) Name of group.
114
+ # @option options [String] :id (required) Id of group.
115
115
  # @return [Sonarqube::ObjectifiedHash] Information about added team member.
116
116
  def list_members(options = {})
117
117
  raise ArgumentError, 'Missing required parameters' if options[:id].nil? && options[:name].nil?
@@ -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
@@ -55,7 +55,7 @@ class Sonarqube::Client
55
55
  end
56
56
 
57
57
  alias project_delete delete_project
58
- # Gets a list of project hooks.
58
+ # Update project key.
59
59
  #
60
60
  # @example
61
61
  # Sonarqube.project_update_key(42)
@@ -69,11 +69,10 @@ class Sonarqube::Client
69
69
  end
70
70
 
71
71
  alias update_key_project project_update_key
72
- # Gets a project hook.
72
+ # Update project visibility.
73
73
  #
74
74
  # @example
75
- # Sonarqube.project_hook(42, 5)
76
- # Sonarqube.project_hook('sonarqube', 5)
75
+ # project_update_visibility('sonarqube', 'public')
77
76
  #
78
77
  # @param [String] project The name fo project.
79
78
  # @param [String] visibility The visibility of a project.
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Sonarqube::Client
4
+ # Defines methods related to tokens.
5
+ # @see https://SONAR_URL/web_api/api/user_tokens
6
+ module Tokens
7
+ # Create token for user.
8
+ #
9
+ # @example
10
+ # Sonarqube.create_token('name_token')
11
+ # Sonarqube.create_token('name_token', 'login_name')
12
+ #
13
+ # @param [String] name (required) Token name.
14
+ # @param [String] login (optional) Login user name.
15
+ # @return [Sonarqube::ObjectifiedHash]
16
+ def create_token(name, login = nil)
17
+ raise ArgumentError, 'Missing required parameters' if name.nil?
18
+
19
+ body = { name: name }
20
+ body = { login: login }.merge!(body) unless login.nil?
21
+ post('/api/user_tokens/generate', body: body)
22
+ end
23
+ alias token_create create_token
24
+
25
+ # Revoke a token.
26
+ #
27
+ # @example
28
+ # Sonarqube.revoke_token('new-group')
29
+ # Sonarqube.revoke_token('sonarqube', { description: 'New Sonarqube project' })
30
+ #
31
+ # @param [String] name (required) Token name.
32
+ # @param [String] login (optional) Login user name.
33
+ # @return [Sonarqube::ObjectifiedHash] Empty hash response.
34
+ def revoke_token(name, login = nil)
35
+ raise ArgumentError, 'Missing required parameters' if name.nil?
36
+
37
+ body = { name: name }
38
+ body = { login: login }.merge!(body) unless login.nil?
39
+ post('/api/user_tokens/revoke', body: body)
40
+ end
41
+ alias token_revoke revoke_token
42
+
43
+ # List token for user.
44
+ #
45
+ # @example
46
+ # Sonarqube.list_token('login')
47
+ #
48
+ # @param [String] login (required) The login name of user
49
+ # @return [Sonarqube::ObjectifiedHash].
50
+ def list_tokens(login)
51
+ raise ArgumentError, 'Missing required parameters' if login.nil?
52
+
53
+ get('/api/user_tokens/search', query: { login: login })
54
+ end
55
+ alias tokens_list list_tokens
56
+ end
57
+ end
@@ -29,9 +29,9 @@ class Sonarqube::Client
29
29
  # or
30
30
  # Sonarqube.create_user('joe', 'joe', 'secret')
31
31
  #
32
- # @param [String] name(required) The name of a user.
33
- # @param [String] login(required) The login of a user.
34
- # @param [String] password(required only is local user) The password of a user.
32
+ # @param [String] name (required) The name of a user.
33
+ # @param [String] login (required) The login of a user.
34
+ # @param [String] password (required only is local user) The password of a user.
35
35
  # @param [Hash] options A customizable set of options.
36
36
  # @option options [String] :email The emails of a user.
37
37
  # @option options [String] :local Specify if the user should be authenticated from SonarQube server or from an external authentication system. Password should not be set when local is set to false.
@@ -50,7 +50,7 @@ class Sonarqube::Client
50
50
  # @example
51
51
  # Sonarqube.update_user('joe', { email: 'joe.smith@foo.org', name: 'Joe' })
52
52
  #
53
- # @param [String] login(required) The login of a user
53
+ # @param [String] login (required) The login of a user
54
54
  # @param [Hash] options A customizable set of options.
55
55
  # @option options [String] :email The email of a user.
56
56
  # @option options [String] :name The name of a user.
@@ -65,9 +65,9 @@ class Sonarqube::Client
65
65
  # Blocks the specified user. Available only for admin.
66
66
  #
67
67
  # @example
68
- # Sonarqube.block_user(15)
68
+ # Sonarqube.deactivate_user('login')
69
69
  #
70
- # @param [String] login(required) The login of a user
70
+ # @param [String] login (required) The login of a user
71
71
  # @param [Hash] options A customizable set of options.
72
72
  def deactivate_user(login, options = {})
73
73
  post('/api/users/deactivate', body: { login: login }.merge!(options))
@@ -80,9 +80,9 @@ class Sonarqube::Client
80
80
  # Sonarqube.change_password_user('joe', 'password')
81
81
  # Sonarqube.change_password_user('admin', 'password', admin)
82
82
  #
83
- # @param [String] login(required) The login of a user
84
- # @param [String] password(required) New password for login
85
- # @param [String] old_password(optional) Previous password. Required when changing one's own password.
83
+ # @param [String] login (required) The login of a user
84
+ # @param [String] password (required) New password for login
85
+ # @param [String] old_password (optional) Previous password. Required when changing one's own password.
86
86
  # @param [Hash] options A customizable set of options.
87
87
  def change_password_user(login, password, old_password = nil, options = {})
88
88
  body = { login: login, password: password }
@@ -91,13 +91,13 @@ class Sonarqube::Client
91
91
  end
92
92
 
93
93
  alias user_change_password change_password_user
94
- # Creates a new user session.
94
+ # Update login user.
95
95
  #
96
96
  # @example
97
- # Sonarqube.session('jack@example.com', 'secret12345')
97
+ # Sonarqube.update_login_user('test', 'new_test')
98
98
  #
99
- # @param [String] login(required) The login of a user
100
- # @param [String] new_login(required) The new login of a user
99
+ # @param [String] login (required) The login of a user
100
+ # @param [String] new_login (required) The new login of a user
101
101
  # @param [Hash] options A customizable set of options.
102
102
  # @return [Sonarqube::ObjectifiedHash]
103
103
  def update_login_user(login, new_login, options = {})
@@ -108,7 +108,7 @@ class Sonarqube::Client
108
108
  # Lists the groups a user belongs to.
109
109
  #
110
110
  # @example
111
- # Sonarqube.group_user
111
+ # Sonarqube.group_user('login')
112
112
  #
113
113
  # @param [String] login A customizable set of options.
114
114
  # @param [Hash] options A customizable set of options.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sonarqube
4
- VERSION = '1.0.0'
4
+ VERSION = '1.2.1'
5
5
  end
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.0.0
4
+ version: 1.2.1
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-08-23 00:00:00.000000000 Z
11
+ date: 2020-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -106,14 +106,16 @@ 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
111
+ - lib/sonarqube/client/tokens.rb
110
112
  - lib/sonarqube/client/users.rb
111
113
  - lib/sonarqube/configuration.rb
112
114
  - lib/sonarqube/error.rb
113
115
  - lib/sonarqube/objectified_hash.rb
114
116
  - lib/sonarqube/request.rb
115
117
  - lib/sonarqube/version.rb
116
- homepage: https://github.com/psyreactor/sonarqube-ruby
118
+ homepage: https://github.com/psyreactor/sonarqube
117
119
  licenses:
118
120
  - BSD-2-Clause
119
121
  metadata: {}