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:
-
(namestr) –The name of an existing group.
-
(membersoptional, default:None) –A list of members in the group.
-
(group_idoptional, 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:
-
(namestr) –The name for the new group.
Returns:
-
'Group' | None–The newly created Group, or
Noneif the operation failed.
add_users
Add users to the group.
Parameters:
-
(usernameslist) –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:
-
(namestr) –The group name to look up.
Returns:
-
bool–Trueif the group exists,Falseotherwise.
from_dict
classmethod
Construct a Group instance from a dictionary.
Parameters:
-
(datadict) –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_idstr | 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:
-
(userUser) –A
Userinstance or a user ID (int).
Returns:
-
bool–Trueif the user is a member,Falseotherwise.
Raises:
-
ValueError–If the group name is not set.
ls
staticmethod
List all groups available in the Datatailr platform.
Parameters:
-
(filterstr | 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:
-
(namestr) –The name of the group to remove.
remove_users
Remove users from the group.
Parameters:
-
(usernameslist) –A list of usernames to remove.
Raises:
-
ValueError–If the group name is not set.