Skip to content

groups

AsyncGroup

Bases: BaseModel

A user group.

gid: Optional[int] instance-attribute

members property

The users in this group.

model_config = ConfigDict(arbitrary_types_allowed=True) class-attribute instance-attribute

name: Optional[str] instance-attribute

add(users) async

Add users to the group.

Parameters:

Name Type Description Default
users Union[List[str], List[AsyncUser]]

The usernames to add

required
Source code in sfapi_client/_async/groups.py
async def add(self, users: Union[List[str], List["AsyncUser"]]):
    """
    Add users to the group.

    :param users: The usernames to add
    """
    await self._group_action(users, GroupAction.batch_add)

remove(users) async

Remove users from the group.

Parameters:

Name Type Description Default
users Union[List[str], List[AsyncUser]]

The usernames to remove

required
Source code in sfapi_client/_async/groups.py
async def remove(self, users: Union[List[str], List["AsyncUser"]]):
    """
    Remove users from the group.

    :param users: The usernames to remove
    """
    await self._group_action(users, GroupAction.batch_remove)

update() async

Update the state of the group by fetching the state from the server.

Source code in sfapi_client/_async/groups.py
async def update(self):
    """
    Update the state of the group by fetching the state from the server.
    """
    group_state = await self._fetch_group(self.client, self.name)
    self._update(group_state)

AsyncGroupMember

A group member.

name: str = Field(..., title='Name') class-attribute instance-attribute

uid: int = Field(..., title='Uid') class-attribute instance-attribute

model_config = ConfigDict(arbitrary_types_allowed=True) class-attribute instance-attribute

user() async

Get the user associated with the membership.

Source code in sfapi_client/_async/groups.py
async def user(self) -> "AsyncUser":
    """
    Get the user associated with the membership.
    """
    return await AsyncUser._fetch_user(self.client, self.name)