Groups

The following methods allow for interaction into the Tenable Vulnerability Management groups API.

Methods available on tio.groups:

class GroupsAPI(api: APISession)[source]
add_user(group_id, user_id)[source]

Add a user to a user group.

groups: add-user

Parameters:
  • group_id (int) – The unique identifier of the group to add the user to.

  • user_id (int) – The unique identifier of the user to add.

Returns:

The user was successfully added to the group.

Return type:

None

Examples

>>> tio.groups.add_user(1, 1)
create(name, *, managed_by_saml=None)[source]

Create a new user group.

groups: create

Parameters:
  • name (str) – The name of the group that will be created.

  • managed_by_saml (bool, optional) – If True, SAML single sign-on can add users to and remove users from the group. If False, group membership is managed independently of SAML. If omitted, the API default applies.

Returns:

The group resource record of the newly minted group. It includes managed_by_saml only if the flag was set.

Return type:

dict

Examples

>>> group = tio.groups.create('Group Name')

Create a group whose membership SAML manages:

>>> group = tio.groups.create('SAML Admins', managed_by_saml=True)
delete(id)[source]

Delete a user group.

groups: delete

Parameters:

id (int) – The unique identifier for the group to be deleted.

Returns:

The group was successfully deleted.

Return type:

None

Examples

>>> tio.groups.delete(1)
delete_user(group_id, user_id)[source]

Delete a user from a user group.

groups: delete-user

Parameters:
  • group_id (int) – The unique identifier for the group to be modified.

  • user_id (int) – The unique identifier for the user to be removed from the group.

Returns:

The user was successfully removed from the group.

Return type:

None

Examples

>>> tio.groups.delete_user(1, 1)
edit(id, name, *, managed_by_saml=None)[source]

Edit a user group.

groups: edit

Parameters:
  • id (int) – The unique identifier for the group to be modified.

  • name (str) – The new name for the group. The API requires a name on every edit, so pass the current name to change only managed_by_saml.

  • managed_by_saml (bool, optional) – If True, SAML single sign-on can add users to and remove users from the group. If False, group membership is managed independently of SAML. If omitted, the current setting is kept.

Returns:

The group resource record.

Return type:

dict

Examples

>>> tio.groups.edit(1, 'Updated name')

Stop SAML from managing the group’s membership:

>>> tio.groups.edit(1, 'SAML Admins', managed_by_saml=False)
list()[source]

Lists all of the available user groups.

groups: list

Returns:

List of the group resource records

Return type:

list

Examples

>>> for group in tio.groups.list():
...     pprint(group)
list_users(id)[source]

List the user memberships within a specific user group.

groups: list-users

Parameters:

id (int) – The unique identifier of the group requested.

Returns:

List of user resource records based on membership to the specified group.

Return type:

list

Example

>>> for user in tio.groups.list_users(1):
...     pprint(user)