Skip to content

users

User

A user.

email: Optional[str] = Field(None, title='Email') class-attribute instance-attribute

firstname: Optional[str] = Field(None, title='Firstname') class-attribute instance-attribute

lastname: Optional[str] = Field(None, title='Lastname') class-attribute instance-attribute

middlename: Optional[str] = Field(None, title='Middlename') class-attribute instance-attribute

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

otherPhones: Optional[str] = Field(None, title='Otherphones') class-attribute instance-attribute

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

workphone: Optional[str] = Field(None, title='Workphone') class-attribute instance-attribute

client: Optional[Client] instance-attribute

email: Optional[str] = Field(None, title='Email') class-attribute instance-attribute

firstname: Optional[str] = Field(None, title='Firstname') class-attribute instance-attribute

lastname: Optional[str] = Field(None, title='Lastname') class-attribute instance-attribute

middlename: Optional[str] = Field(None, title='Middlename') class-attribute instance-attribute

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

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

otherPhones: Optional[str] = Field(None, title='Otherphones') class-attribute instance-attribute

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

workphone: Optional[str] = Field(None, title='Workphone') class-attribute instance-attribute

clients()

Get information about the authenticated user's SFAPI clients.

Returns:

Type Description
List[Client]

the api clients

Source code in sfapi_client/_sync/users.py
def clients(self) -> List[APIClient]:
    """
    Get information about the authenticated user's SFAPI clients.

    :return: the api clients
    """
    r = self.client.get("account/clients")

    json_response = r.json()

    clients = [APIClient.model_validate(c) for c in json_response]

    return clients

groups()

The groups that the user is a member of.

Returns:

Type Description
List[Group]

the groups

Source code in sfapi_client/_sync/users.py
def groups(self) -> List["Group"]:  # noqa: F821
    """
    The groups that the user is a member of.

    :return: the groups
    """
    # Avoid circular import
    from .groups import Group

    if self.name != (self.client._user()).name:
        raise SfApiError("Can only fetch groups for authenticated user.")

    r = self.client.get("account/groups")

    json_response = r.json()
    groups_reponse = GroupsResponse.model_validate(json_response)

    groups = [
        Group.model_validate(dict(g, client=self.client))
        for g in groups_reponse.groups
    ]

    return groups

projects()

The projects the user is associate with.

Returns:

Type Description
List[Project]

the projects

Source code in sfapi_client/_sync/users.py
def projects(self) -> List[Project]:
    """
    The projects the user is associate with.

    :return: the projects
    """
    if self.name != (self.client._user()).name:
        raise SfApiError("Can only fetch projects for authenticated user.")

    r = self.client.get("account/projects")

    project_values = r.json()

    projects = [
        Project.model_validate(dict(p, client=self.client))
        for p in project_values
    ]

    return projects

roles()

The roles the user is associate with.

Returns:

Type Description
List[Role]

the roles

Source code in sfapi_client/_sync/users.py
def roles(self) -> List[Role]:
    """
    The roles the user is associate with.

    :return: the roles
    """
    if self.name != (self.client._user()).name:
        raise SfApiError("Can only fetch roles for authenticated user.")

    r = self.client.get("account/roles")

    json_response = r.json()

    roles = [
        Role.model_validate(dict(p, client=self.client)) for p in json_response
    ]

    return roles