module Sonarqube::Client::Users
Defines methods related to users. @see SONAR_URL/web_api/api/users
Public Instance Methods
Change password the specified user. Available only for admin.
@example
Sonarqube.change_password_user('joe', 'password') Sonarqube.change_password_user('admin', 'password', admin)
@param [String] login (required) The login of a user @param [String] password (required) New password for login @param [String] old_password (optional) Previous password. Required when changing one's own password. @param [Hash] options A customizable set of options.
# File lib/sonarqube/client/users.rb, line 87 def change_password_user(login, password, old_password = nil, options = {}) body = { login: login, password: password } body = { old_password: old_password }.merge!(body) unless old_password.nil? post('/api/users/change_password', body: body.merge!(options)) end
Creates a new user. Requires authentication from an admin account.
@example
Sonarqube.create_user('joe', 'joe', 'secret', , { mail: 'joe@foo.org' }) or Sonarqube.create_user('joe', 'joe', 'secret')
@param [String] name (required) The name of a user. @param [String] login (required) The login of a user. @param [String] password (required only is local user) The password of a user. @param [Hash] options A customizable set of options. @option options [String] :email The emails of a user. @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. @option options [String] :scmAccount List of SCM accounts. To set several values, the parameter must be called once for each value. @param [Hash] options A customizable set of options. @return [Sonarqube::ObjectifiedHash] Information about created user.
# File lib/sonarqube/client/users.rb, line 41 def create_user(login, name, password = nil, options = {}) body = { login: login, password: password, name: name } body.merge!(options) post('/api/users/create', body: body) end
Blocks the specified user. Available only for admin.
@example
Sonarqube.deactivate_user('login')
@param [String] login (required) The login of a user @param [Hash] options A customizable set of options.
# File lib/sonarqube/client/users.rb, line 72 def deactivate_user(login, options = {}) post('/api/users/deactivate', body: { login: login }.merge!(options)) end
Lists the groups a user belongs to.
@example
Sonarqube.group_user('login')
@param [String] login A customizable set of options. @param [Hash] options A customizable set of options. @option options [Integer] :page The page number. @option options [Integer] :per_page The number of results per page. @option options [String] :from The start date for paginated results. @return [Array<Sonarqube::ObjectifiedHash>]
# File lib/sonarqube/client/users.rb, line 119 def groups_user(login, options = {}) get('/api/users/groups', query: { login: login }.merge!(options)) end
Update login user.
@example
Sonarqube.update_login_user('test', 'new_test')
@param [String] login (required) The login of a user @param [String] new_login (required) The new login of a user @param [Hash] options A customizable set of options. @return [Sonarqube::ObjectifiedHash]
# File lib/sonarqube/client/users.rb, line 103 def update_login_user(login, new_login, options = {}) post('/api/users/update_login', body: { login: login, newLogin: new_login }.merge!(options)) end
Updates a user.
@example
Sonarqube.update_user('joe', { email: 'joe.smith@foo.org', name: 'Joe' })
@param [String] login (required) The login of a user @param [Hash] options A customizable set of options. @option options [String] :email The email of a user. @option options [String] :name The name of a user. @option options [String] :scmAccount SCM accounts. To set several values, the parameter must be called once for each value. @param [Hash] options A customizable set of options. @return [Sonarqube::ObjectifiedHash] Information about update user.
# File lib/sonarqube/client/users.rb, line 60 def update_user(login, options = {}) post('/api/users/update', body: { login: login }.merge!(options)) end
Gets a list of users.
@example
Sonarqube.users_search() Sonarqube.users_search(query: { p: 1, ps: 10 }) Sonarqube.users_search(query: { p: 1, ps: 10, q: 'sonarqube' })
@param [Hash] options A customizable set of options. @option options [Integer] :ps Page size number of users to return per page @option options [Integer] :p The page to retrieve @option options [String] :q Filter on login, name and email @return [Array<Sonarqube::ObjectifiedHash>]
# File lib/sonarqube/client/users.rb, line 19 def users_search(options = {}) get('/api/users/search', query: options) end