user methods

create_user

create_user(apiuser, username, email, password=<Optional:''>, firstname=<Optional:''>, lastname=<Optional:''>, description=<Optional:''>, active=<Optional:True>, admin=<Optional:False>, extern_name=<Optional:'rhodecode'>, extern_type=<Optional:'rhodecode'>, force_password_change=<Optional:False>, create_personal_repo_group=<Optional:None>)

Creates a new user and returns the new user object.

This command can only be run using an Authentication Token with admin rights to the specified repository.

This command takes the following options:

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • username (str or int) – Set the new username.
  • email (str) – Set the user email address.
  • password (Optional(str)) – Set the new user password.
  • firstname (Optional(str)) – Set the new user firstname.
  • lastname (Optional(str)) – Set the new user surname.
  • description (Optional(str)) – Set user description, or short bio. Metatags are allowed.
  • active (Optional(True | False)) – Set the user as active.
  • admin (Optional(True | False)) – Give the new user admin rights.
  • extern_name (Optional(str)) – Set the authentication plugin name. Using LDAP this is filled with LDAP UID.
  • extern_type (Optional(str)) – Set the new user authentication plugin.
  • force_password_change (Optional(True | False)) – Force the new user to change password on next login.
  • create_personal_repo_group (Optional(True | False)) – Create personal repo group for this user

Example output:

id : <id_given_in_input>
result: {
    "msg" : "created new user `<username>`",
    "user": <user_obj>
}
error:  null

Example error output:

id : <id_given_in_input>
result : null
error :  {
  "user `<username>` already exist"
  or
  "email `<email>` already exist"
  or
  "failed to create user `<username>`"
}

delete_user

delete_user(apiuser, userid)

Deletes the specified user from the RhodeCode Enterprise user database.

This command can only be run using an Authentication Token with admin rights to the specified repository.

Important

Ensure all open pull requests and open code review requests to this user are close.

Also ensure all repositories, or repository groups owned by this user are reassigned before deletion.

This command takes the following options:

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • userid (str or int) – Set the user to delete.

Example output:

id : <id_given_in_input>
result: {
    "msg" : "deleted user ID:<userid> <username>",
    "user": null
}
error:  null

Example error output:

id : <id_given_in_input>
result : null
error :  {
  "failed to delete user ID:<userid> <username>"
}

get_user

get_user(apiuser, userid=<Optional:<OptionalAttr:apiuser>>)

Returns the information associated with a username or userid.

  • If the userid is not set, this command returns the information for the userid calling the method.

Note

Normal users may only run this command against their userid. For full privileges you must run this command using an Authentication Token with admin rights.

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • userid (Optional(str or int)) – Sets the userid for which data will be returned.

Example output:

{
  "error": null,
  "id": <id>,
  "result": {
    "active": true,
    "admin": false,
    "api_keys": [ list of keys ],
    "auth_tokens": [ list of tokens with details ],
    "email": "user@example.com",
    "emails": [
      "user@example.com"
    ],
    "extern_name": "rhodecode",
    "extern_type": "rhodecode",
    "firstname": "username",
    "description": "user description",
    "ip_addresses": [],
    "language": null,
    "last_login": "Timestamp",
    "last_activity": "Timestamp",
    "lastname": "surnae",
    "permissions": <deprecated>,
    "permissions_summary": {
      "global": [
        "hg.inherit_default_perms.true",
        "usergroup.read",
        "hg.repogroup.create.false",
        "hg.create.none",
        "hg.password_reset.enabled",
        "hg.extern_activate.manual",
        "hg.create.write_on_repogroup.false",
        "hg.usergroup.create.false",
        "group.none",
        "repository.none",
        "hg.register.none",
        "hg.fork.repository"
      ],
      "repositories": { "username/example": "repository.write"},
      "repositories_groups": { "user-group/repo": "group.none" },
      "user_groups": { "user_group_name": "usergroup.read" }
    }
    "user_id": 32,
    "username": "username"
  }
}

get_user_audit_logs

get_user_audit_logs(apiuser, userid=<Optional:<OptionalAttr:apiuser>>)

Fetches all action logs made by the specified user.

This command takes the following options:

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • userid (Optional(str or int)) – Sets the userid whose list of locked repositories will be displayed.

Example output:

id : <id_given_in_input>
result : {
    [action, action,...]
}
error :  null

get_user_locks

get_user_locks(apiuser, userid=<Optional:<OptionalAttr:apiuser>>)

Displays all repositories locked by the specified user.

  • If this command is run by a non-admin user, it returns a list of repositories locked by that user.

This command takes the following options:

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • userid (Optional(str or int)) – Sets the userid whose list of locked repositories will be displayed.

Example output:

id : <id_given_in_input>
result : {
    [repo_object, repo_object,...]
}
error :  null

get_users

get_users(apiuser)

Lists all users in the RhodeCode Enterprise user database.

This command can only be run using an Authentication Token with admin rights to the specified repository.

This command takes the following options:

Parameters:apiuser (AuthUser) – This is filled automatically from the Authentication Token.

Example output:

id : <id_given_in_input>
result: [<user_object>, ...]
error:  null

update_user

update_user(apiuser, userid, username=<Optional:None>, email=<Optional:None>, password=<Optional:None>, firstname=<Optional:None>, lastname=<Optional:None>, description=<Optional:None>, active=<Optional:None>, admin=<Optional:None>, extern_type=<Optional:None>, extern_name=<Optional:None>)

Updates the details for the specified user, if that user exists.

This command can only be run using an Authentication Token with admin rights to the specified repository.

This command takes the following options:

Parameters:
  • apiuser (AuthUser) – This is filled automatically from Authentication Token.
  • userid (str or int) – Set the userid to update.
  • username (str or int) – Set the new username.
  • email (str) – Set the new email.
  • password (Optional(str)) – Set the new password.
  • firstname (Optional(str)) – Set the new first name.
  • lastname (Optional(str)) – Set the new surname.
  • description (Optional(str)) – Set user description, or short bio. Metatags are allowed.
  • active (Optional(True | False)) – Set the new user as active.
  • admin (Optional(True | False)) – Give the user admin rights.
  • extern_name (Optional(str)) – Set the authentication plugin user name. Using LDAP this is filled with LDAP UID.
  • extern_type (Optional(str)) – Set the authentication plugin type.

Example output:

id : <id_given_in_input>
result: {
    "msg" : "updated user ID:<userid> <username>",
    "user": <user_object>,
}
error:  null

Example error output:

id : <id_given_in_input>
result : null
error :  {
  "failed to update user `<username>`"
}