Skip to content

Users

albert.resources.users

UserClass

Bases: str, Enum

The ACL class level of the user

Attributes:

Name Type Description
GUEST
STANDARD
TRUSTED
PRIVILEGED
ADMIN

GUEST

GUEST = 'guest'

STANDARD

STANDARD = 'standard'

TRUSTED

TRUSTED = 'trusted'

PRIVILEGED

PRIVILEGED = 'privileged'

ADMIN

ADMIN = 'admin'

UserFilterType

Bases: str, Enum

Attributes:

Name Type Description
ROLE

ROLE

ROLE = 'role'

User

Bases: BaseResource

Represents a User on the Albert Platform

Attributes:

Name Type Description
name str

The name of the user.

id str | None

The Albert ID of the user. Set when the user is retrieved from Albert.

location Location | None

The location of the user.

email EmailStr | None

The email of the user.

roles list[Role]

The roles of the user.

user_class UserClass

The ACL class level of the user.

metadata dict[str, str | list[EntityLink] | EntityLink] | None

Methods:

Name Description
to_note_mention

Convert the user to a note mention string.

name

name: str

id

id: UserId | None = Field(None, alias='albertId')

location

location: SerializeAsEntityLink[Location] | None = Field(
    default=None, alias="Location"
)

email

email: EmailStr = Field(default=None, alias='email')

roles

roles: list[SerializeAsEntityLink[Role]] = Field(
    max_length=1, default_factory=list, alias="Roles"
)

user_class

user_class: UserClass = Field(
    default=STANDARD, alias="userClass"
)

metadata

metadata: dict[str, MetadataItem] | None = Field(
    alias="Metadata", default=None
)

to_note_mention

to_note_mention() -> str

Convert the user to a note mention string.

Returns:

Type Description
str

The note mention string.

Source code in src/albert/resources/users.py
def to_note_mention(self) -> str:
    """Convert the user to a note mention string.

    Returns
    -------
    str
        The note mention string.
    """
    return f"@{self.name}#{self.id}#"

UserSearchRoleItem

Bases: BaseAlbertModel

Show JSON schema:
{
  "properties": {
    "roleId": {
      "title": "Roleid",
      "type": "string"
    },
    "roleName": {
      "title": "Rolename",
      "type": "string"
    }
  },
  "required": [
    "roleId",
    "roleName"
  ],
  "title": "UserSearchRoleItem",
  "type": "object"
}

Fields:

roleId

roleId: str

roleName

roleName: str

UserSearchItem

Bases: BaseAlbertModel, HydrationMixin[User]

Partial user entity as returned by the search.

Show JSON schema:
{
  "$defs": {
    "UserClass": {
      "description": "The ACL class level of the user",
      "enum": [
        "guest",
        "standard",
        "trusted",
        "privileged",
        "admin"
      ],
      "title": "UserClass",
      "type": "string"
    },
    "UserSearchRoleItem": {
      "properties": {
        "roleId": {
          "title": "Roleid",
          "type": "string"
        },
        "roleName": {
          "title": "Rolename",
          "type": "string"
        }
      },
      "required": [
        "roleId",
        "roleName"
      ],
      "title": "UserSearchRoleItem",
      "type": "object"
    }
  },
  "description": "Partial user entity as returned by the search.",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "albertId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Albertid"
    },
    "email": {
      "anyOf": [
        {
          "format": "email",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Email"
    },
    "userClass": {
      "$ref": "#/$defs/UserClass",
      "default": "standard"
    },
    "lastLoginTime": {
      "anyOf": [
        {
          "format": "date-time",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Lastlogintime"
    },
    "location": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Location"
    },
    "locationId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Locationid"
    },
    "role": {
      "items": {
        "$ref": "#/$defs/UserSearchRoleItem"
      },
      "maxItems": 1,
      "title": "Role",
      "type": "array"
    },
    "subscription": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Subscription"
    }
  },
  "required": [
    "name"
  ],
  "title": "UserSearchItem",
  "type": "object"
}

Fields:

name

name: str

id

id: UserId | None = None

email

email: EmailStr | None = None

user_class

user_class: UserClass = STANDARD

last_login_time

last_login_time: datetime | None = None

location

location: str | None = None

location_id

location_id: str | None = None

roles

subscription

subscription: str | None = None