Module: Sonarqube::Client::Users

Included in:
Sonarqube::Client
Defined in:
lib/sonarqube/client/users.rb

Overview

Defines methods related to users.

Instance Method Summary collapse

Instance Method Details

#change_password_user(login, password, old_password = nil, options = {}) ⇒ Object Also known as: user_change_password

Change password the specified user. Available only for admin.

Examples:

Sonarqube.change_password_user('joe', 'password')
Sonarqube.change_password_user('admin', 'password', admin)

Parameters:

  • login (String)

    (required) The login of a user

  • password (String)

    (required) New password for login

  • old_password (String) (defaults to: nil)

    (optional) Previous password. Required when changing one’s own password.

  • options (Hash) (defaults to: {})

    A customizable set of options.



87
88
89
90
91
# File 'lib/sonarqube/client/users.rb', line 87

def change_password_user(, password, old_password = nil, options = {})
  body = { login: , password: password }
  body = { old_password: old_password }.merge!(body) unless old_password.nil?
  post('/api/users/change_password', body: body.merge!(options))
end

#create_user(login, name, password = nil, options = {}) ⇒ Sonarqube::ObjectifiedHash Also known as: user_create

Creates a new user. Requires authentication from an admin account.

Examples:

Sonarqube.create_user('joe', 'joe', 'secret', , { mail: '[email protected]' })
or
Sonarqube.create_user('joe', 'joe', 'secret')

Parameters:

  • name (String)

    (required) The name of a user.

  • login (String)

    (required) The login of a user.

  • password (String) (defaults to: nil)

    (required only is local user) The password of a user.

  • options (Hash) (defaults to: {})

    A customizable set of options.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :email (String)

    The emails of a user.

  • :local (String)

    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.

  • :scmAccount (String)

    List of SCM accounts. To set several values, the parameter must be called once for each value.

Returns:



41
42
43
44
45
# File 'lib/sonarqube/client/users.rb', line 41

def create_user(, name, password = nil, options = {})
  body = { login: , password: password, name: name }
  body.merge!(options)
  post('/api/users/create', body: body)
end

#deactivate_user(login, options = {}) ⇒ Object Also known as: user_deactivate

Blocks the specified user. Available only for admin.

Examples:

Sonarqube.deactivate_user('login')

Parameters:

  • login (String)

    (required) The login of a user

  • options (Hash) (defaults to: {})

    A customizable set of options.



72
73
74
# File 'lib/sonarqube/client/users.rb', line 72

def deactivate_user(, options = {})
  post('/api/users/deactivate', body: { login:  }.merge!(options))
end

#groups_user(login, options = {}) ⇒ Array<Sonarqube::ObjectifiedHash> Also known as: user_groups

Lists the groups a user belongs to.

Examples:

Sonarqube.group_user('login')

Parameters:

  • login (String)

    A customizable set of options.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

  • :from (String)

    The start date for paginated results.

Returns:



119
120
121
# File 'lib/sonarqube/client/users.rb', line 119

def groups_user(, options = {})
  get('/api/users/groups', query: { login:  }.merge!(options))
end

#update_login_user(login, new_login, options = {}) ⇒ Sonarqube::ObjectifiedHash Also known as: user_update_login

Update login user.

Examples:

Sonarqube.('test', 'new_test')

Parameters:

  • login (String)

    (required) The login of a user

  • new_login (String)

    (required) The new login of a user

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:



103
104
105
# File 'lib/sonarqube/client/users.rb', line 103

def (, , options = {})
  post('/api/users/update_login', body: { login: , newLogin:  }.merge!(options))
end

#update_user(login, options = {}) ⇒ Sonarqube::ObjectifiedHash Also known as: user_update

Updates a user.

Examples:

Sonarqube.update_user('joe', { email: '[email protected]', name: 'Joe' })

Parameters:

  • login (String)

    (required) The login of a user

  • options (Hash) (defaults to: {})

    A customizable set of options.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :email (String)

    The email of a user.

  • :name (String)

    The name of a user.

  • :scmAccount (String)

    SCM accounts. To set several values, the parameter must be called once for each value.

Returns:



60
61
62
# File 'lib/sonarqube/client/users.rb', line 60

def update_user(, options = {})
  post('/api/users/update', body: { login:  }.merge!(options))
end

#users_search(options = {}) ⇒ Array<Sonarqube::ObjectifiedHash> Also known as: search_users

Gets a list of users.

Examples:

Sonarqube.users_search()
Sonarqube.users_search(query: { p: 1, ps: 10 })
Sonarqube.users_search(query: { p: 1, ps: 10, q: 'sonarqube' })

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :ps (Integer)

    Page size number of users to return per page

  • :p (Integer)

    The page to retrieve

  • :q (String)

    Filter on login, name and email

Returns:



19
20
21
# File 'lib/sonarqube/client/users.rb', line 19

def users_search(options = {})
  get('/api/users/search', query: options)
end