user_group methods

add_user_to_user_group

add_user_to_user_group(apiuser, usergroupid, userid)

Adds a user to a user group. If the user already exists in the group this command will return false.

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

This command takes the following options:

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid (int) – Set the name of the user group to which a user will be added.
  • userid (int) – Set the user_id of the user to add to the group.

Example output:

id : <id_given_in_input>
result : {
    "success": True|False # depends on if member is in group
    "msg": "added member `<username>` to user group `<groupname>` |
            User is already in that group"

}
error :  null

Example error output:

id : <id_given_in_input>
result : null
error :  {
  "failed to add member to user group `<user_group_name>`"
}

create_user_group

create_user_group(apiuser, group_name, description=<Optional:''>, owner=<Optional:<OptionalAttr:apiuser>>, active=<Optional:True>, sync=<Optional:None>)

Creates a new user group.

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.
  • group_name (str) – Set the name of the new user group.
  • description (str) – Give a description of the new user group.
  • owner (Optional(str or int)) – Set the owner of the new user group. If not set, the owner is the Authentication Token user.
  • active (Optional(True | False)) – Set this group as active.
  • sync (Optional(True | False)) – Set enabled or disabled the automatically sync from external authentication types like ldap. If User Group will be named like one from e.g ldap and sync flag is enabled members will be synced automatically. Sync type when enabled via API is set to manual_api

Example output:

id : <id_given_in_input>
result: {
          "msg": "created new user group `<groupname>`",
          "user_group": <user_group_object>
        }
error:  null

Example error output:

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

delete_user_group

delete_user_group(apiuser, usergroupid)

Deletes the specified user group.

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) – filled automatically from apikey
  • usergroupid (int) –

Example output:

id : <id_given_in_input>
result : {
  "msg": "deleted user group ID:<user_group_id> <user_group_name>"
}
error :  null

Example error output:

id : <id_given_in_input>
result : null
error :  {
  "failed to delete user group ID:<user_group_id> <user_group_name>"
  or
  "RepoGroup assigned to <repo_groups_list>"
}

get_user_group

get_user_group(apiuser, usergroupid)

Returns the data of an existing user group.

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

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid (str or int) – Set the user group from which to return data.

Example error output:

{
  "error": null,
  "id": <id>,
  "result": {
    "active": true,
    "group_description": "group description",
    "group_name": "group name",
    "permissions": [
      {
        "name": "owner-name",
        "origin": "owner",
        "permission": "usergroup.admin",
        "type": "user"
      },
      {
      {
        "name": "user name",
        "origin": "permission",
        "permission": "usergroup.admin",
        "type": "user"
      },
      {
        "name": "user group name",
        "origin": "permission",
        "permission": "usergroup.write",
        "type": "user_group"
      }
    ],
    "permissions_summary": {
      "repositories": {
        "aa-root-level-repo-1": "repository.admin"
      },
      "repositories_groups": {}
    },
    "owner": "owner name",
    "users": [],
    "users_group_id": 2
  }
}

get_user_groups

get_user_groups(apiuser)

Lists all the existing user groups within RhodeCode.

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 error output:

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

grant_user_group_permission_to_user_group

grant_user_group_permission_to_user_group(apiuser, usergroupid, sourceusergroupid, perm)

Give one user group permissions to another user group.

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid (str or int) – Set the user group on which to edit permissions.
  • sourceusergroupid (str or int) – Set the source user group to which access/permissions will be granted.
  • perm (str) – (usergroup.(none|read|write|admin))

Example output:

id : <id_given_in_input>
result : {
  "msg": "Granted perm: `<perm_name>` for user group: `<source_user_group_name>` in user group: `<user_group_name>`",
  "success": true
}
error :  null

grant_user_permission_to_user_group

grant_user_permission_to_user_group(apiuser, usergroupid, userid, perm)

Set permissions for a user in a user group.

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid (str or int) – Set the user group to edit permissions on.
  • userid (str) – Set the user from whom you wish to set permissions.
  • perm (str) – (usergroup.(none|read|write|admin))

Example output:

id : <id_given_in_input>
result : {
  "msg": "Granted perm: `<perm_name>` for user: `<username>` in user group: `<user_group_name>`",
  "success": true
}
error :  null

remove_user_from_user_group

remove_user_from_user_group(apiuser, usergroupid, userid)

Removes a user from a user group.

  • If the specified user is not in the group, this command will return false.

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

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid (str or int) – Sets the user group name.
  • userid (str or int) – The user you wish to remove from RhodeCode Enterprise.

Example output:

id : <id_given_in_input>
result: {
          "success":  True|False,  # depends on if member is in group
          "msg": "removed member <username> from user group <groupname> |
                  User wasn't in group"
        }
error:  null

revoke_user_group_permission_from_user_group

revoke_user_group_permission_from_user_group(apiuser, usergroupid, sourceusergroupid)

Revoke the permissions that one user group has to another.

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid (str or int) – Set the user group on which to edit permissions.
  • sourceusergroupid (str or int) – Set the user group from which permissions are revoked.

Example output:

id : <id_given_in_input>
result : {
  "msg": "Revoked perm for user group: `<user_group_name>` in user group: `<target_user_group_name>`",
  "success": true
}
error :  null

revoke_user_permission_from_user_group

revoke_user_permission_from_user_group(apiuser, usergroupid, userid)

Revoke a users permissions in a user group.

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid – Set the user group from which to revoke the user permissions.
  • userid (str) – Set the userid of the user whose permissions will be revoked.
Type:

usergroupid: str or int

Example output:

id : <id_given_in_input>
result : {
  "msg": "Revoked perm for user: `<username>` in user group: `<user_group_name>`",
  "success": true
}
error :  null

update_user_group

update_user_group(apiuser, usergroupid, group_name=<Optional:''>, description=<Optional:''>, owner=<Optional:None>, active=<Optional:True>, sync=<Optional:None>)

Updates the specified user group with the details provided.

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

Parameters:
  • apiuser (AuthUser) – This is filled automatically from the Authentication Token.
  • usergroupid (str or int) – Set the id of the user group to update.
  • group_name (str) – Set the new name the user group
  • description (str) – Give a description for the user group
  • owner (Optional(str or int)) – Set the owner of the user group.
  • active (Optional(True | False)) – Set the group as active.
  • sync (Optional(True | False)) – Set enabled or disabled the automatically sync from external authentication types like ldap. If User Group will be named like one from e.g ldap and sync flag is enabled members will be synced automatically. Sync type when enabled via API is set to manual_api

Example output:

id : <id_given_in_input>
result : {
  "msg": 'updated user group ID:<user group id> <user group name>',
  "user_group": <user_group_object>
}
error :  null

Example error output:

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