Source code for maestral.core

Dataclasses for our internal and external APIs.

from __future__ import annotations

from enum import Enum
from dataclasses import dataclass
from datetime import datetime

# ==== user ============================================================================

[docs] class AccountType(Enum): """Enum of account types"""
[docs] Basic = "basic"
[docs] Pro = "pro"
[docs] Business = "business"
[docs] Other = "other"
[docs] class Team: """A group of users with joint access to shared folders"""
[docs] id: str
"""Unique identifier of the team"""
[docs] name: str
"""Display name of the team"""
[docs] class RootInfo: """Namespace info for the root of a shared filesystem"""
[docs] root_namespace_id: str
"""Unique ID of the user's root namespace"""
[docs] home_namespace_id: str
"""Unique ID of the user's personal namespace This will be different from :attr:`root_namespace_id` when Maestral is set up to sync the shared folder of a team. """
[docs] class UserRootInfo(RootInfo): pass
[docs] class TeamRootInfo(RootInfo):
[docs] home_path: str
"""Path of the user's personal home folder relative to the root namespace Only present for accounts set up as part of a team when syncing the entire team's folder. """
[docs] class Account: """Represents the user's account"""
[docs] account_id: str
"""Unique account ID"""
[docs] display_name: str
"""The user's name for display purposes"""
[docs] email: str
"""The user's email address"""
[docs] email_verified: bool
"""Whether the email address was verified"""
[docs] profile_photo_url: str | None
"""A URL to the user's photo"""
[docs] disabled: bool
"""Whether the account is disabled"""
[docs] class FullAccount(Account): """Represents the user's account and sync information"""
[docs] country: str | None
"""The user's country"""
[docs] locale: str
"""The user's locale"""
[docs] team: Team | None
"""The team that a user belongs to, if any"""
[docs] team_member_id: str | None
"""The member ID of user in a team, if any"""
[docs] account_type: AccountType
"""The account type"""
[docs] root_info: RootInfo
"""The user's root namespace to sync"""
[docs] class SpaceUsage: """Space usage information"""
[docs] used: int
"""Space used by in bytes"""
[docs] allocated: int
"""Space available in bytes"""
[docs] class PersonalSpaceUsage(SpaceUsage): """Space usage information for a user"""
[docs] team_usage: SpaceUsage | None
"""Space usage of a user's team, if any"""
# ==== files ===========================================================================
[docs] class WriteMode(Enum): """Enum of write modes when uploading a file"""
[docs] Add = "add"
[docs] Update = "update"
[docs] Overwrite = "overwrite"
[docs] class Metadata: """Base class for sync item metadata"""
[docs] name: str
"""Name of the file or folder"""
[docs] path_lower: str
"""Normalised path on the server"""
[docs] path_display: str
"""Cased path for display purposes and the local file system"""
[docs] class DeletedMetadata(Metadata): """Metadata of a deleted item""" pass
[docs] class FileMetadata(Metadata): """File metadata"""
[docs] id: str
"""Unique ID on the server"""
[docs] client_modified: datetime
"""Modified time in UTC as provided by clients"""
[docs] server_modified: datetime
"""Server-side modified time in UTC"""
[docs] rev: str
"""Unique ID of this version of a file"""
[docs] size: int
"""File size in bytes""" """If the file is a symlink, path of the target relative to the root namespace"""
[docs] shared: bool
"""Whether the file is shared"""
[docs] modified_by: str | None
"""Unique ID of the account that created / modified this revision"""
[docs] is_downloadable: bool
"""Whether the file can be downloaded"""
[docs] content_hash: str
"""A content hash of the file"""
[docs] class FolderMetadata(Metadata): """Folder metadata"""
[docs] id: str
"""Unique ID on the server"""
[docs] shared: bool
"""Whether the folder is shared"""
[docs] class ListFolderResult: """Result from listing the contents of a folder"""
[docs] entries: list[Metadata]
"""List of entries"""
[docs] has_more: bool
"""Whether there are more entries than listed"""
[docs] cursor: str
"""Cursor to iterate and fetch more entries"""
# ==== sharing =========================================================================
[docs] class LinkAccessLevel(Enum): """Enum of access levels to shared links"""
[docs] Viewer = "viewer"
[docs] Editor = "editor"
[docs] Other = "other"
[docs] class LinkAudience(Enum): """Enum of shared link audience"""
[docs] Public = "public"
[docs] Team = "team"
[docs] NoOne = "no_one"
[docs] Other = "other"
[docs] class LinkPermissions: """Permissions for a shared link"""
[docs] can_revoke: bool
"""If the link can be revoked"""
[docs] allow_download: bool
"""If the link allows users to download the item"""
[docs] effective_audience: LinkAudience
"""The effective audience of link (who can use it)""" """The type of access that the link grants to the item (how they can use it)"""
[docs] require_password: bool | None
"""Whether a password is required when accessing the item through this link Note that users who already have access to an item otherwise will not need a password regardless of this value."""
[docs] class SharedLinkMetadata: """Metadata for a shared link"""
[docs] url: str
"""The URL string"""
[docs] name: str
"""The basename of the item"""
[docs] path_lower: str | None
"""The normalised path of the item"""
[docs] expires: datetime | None
"""Expiry time for a link in UTC""" """Permissions that a link grants its users"""
[docs] class ListSharedLinkResult: """Result from listing shared links"""
[docs] entries: list[SharedLinkMetadata]
"""List of shared link metadata"""
[docs] has_more: bool
"""Whether there are more items to fetch"""
[docs] cursor: str
"""A cursor to continue iterating over shared links"""
# ==== update checks =================================================================== @dataclass
[docs] class UpdateCheckResult: """Information on update availability"""
[docs] update_available: bool
"""Whether an update to Maestral is available"""
[docs] latest_release: str
"""The latest release that can be updated to"""
[docs] release_notes: str
"""Release notes for all releases between the currently running version up to and including the latest version"""