Skip to content

Group

Representing a Datatailr Group.

This class provides methods to interact with the Datatailr Group API. It allows you to create, update, delete, and manage groups within the Datatailr platform.

Attributes:

  • name (str) –

    The name of the group.

  • members (list) –

    A list of members in the group.

  • group_id (int) –

    The unique identifier for the group.

Parameters:

  • name

    (str) –

    The name of an existing group.

  • members

    (optional, default: None ) –

    A list of members in the group.

  • group_id

    (optional, default: None ) –

    The unique identifier for the group.

Raises:

  • ValueError –

    If a group with the given name does not exist.

group_id property

The unique numeric identifier of the group.

members property

List of user IDs that are members of this group.

name property

The name of the group.

add staticmethod

Create a new group with the specified name.

Parameters:

  • name

    (str) –

    The name for the new group.

Returns:

  • Group | None –

    The newly created Group, or None if the operation failed.

add_users

Add users to the group.

Parameters:

  • usernames

    (list) –

    A list of usernames to add.

Raises:

  • ValueError –

    If the group name is not set.

exists staticmethod

Check if a group exists by its name.

Parameters:

  • name

    (str) –

    The group name to look up.

Returns:

  • bool –

    True if the group exists, False otherwise.

from_dict classmethod

Construct a Group instance from a dictionary.

Parameters:

  • data

    (dict) –

    A dictionary with keys "name", "members", and "group_id".

Returns:

  • Group –

    A Group instance populated from the dictionary.

Raises:

  • ValueError –

    If required keys are missing from data.

get staticmethod

Retrieve an existing group by name or numeric ID.

Parameters:

  • name_or_id

    (str | int) –

    The group name (str) or group ID (int).

Returns:

  • Group –

    The matching Group instance.

Raises:

  • ValueError –

    If no group with the given name or ID exists.

is_member

Check whether a user belongs to this group.

Parameters:

  • user

    (User) –

    A User instance or a user ID (int).

Returns:

  • bool –

    True if the user is a member, False otherwise.

Raises:

  • ValueError –

    If the group name is not set.

ls staticmethod

List all groups available in the Datatailr platform.

Parameters:

  • filter

    (str | None, default: None ) –

    A filter expression to apply to the groups.

Returns:

  • list –

    A list of Group instances.

remove staticmethod

Remove a group by its name.

Parameters:

  • name

    (str) –

    The name of the group to remove.

remove_users

Remove users from the group.

Parameters:

  • usernames

    (list) –

    A list of usernames to remove.

Raises:

  • ValueError –

    If the group name is not set.