Source code for maestral.core
"""
Dataclasses for our internal and external APIs.
"""
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
# ==== user ============================================================================
[docs]
class AccountType(Enum):
"""Enum of account types"""
@dataclass
[docs]
class Team:
"""A group of users with joint access to shared folders"""
"""Unique identifier of the team"""
"""Display name of the team"""
@dataclass
[docs]
class RootInfo:
"""Namespace info for the root of a shared filesystem"""
"""Unique ID of the user's root namespace"""
"""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.
"""
@dataclass
[docs]
class UserRootInfo(RootInfo):
pass
@dataclass
[docs]
class TeamRootInfo(RootInfo):
"""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.
"""
@dataclass
[docs]
class Account:
"""Represents the user's account"""
"""Unique account ID"""
"""The user's name for display purposes"""
"""The user's email address"""
"""Whether the email address was verified"""
[docs]
profile_photo_url: str | None
"""A URL to the user's photo"""
"""Whether the account is disabled"""
@dataclass
[docs]
class FullAccount(Account):
"""Represents the user's account and sync information"""
"""The user's country"""
"""The user's locale"""
"""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"""
"""The user's root namespace to sync"""
@dataclass
[docs]
class SpaceUsage:
"""Space usage information"""
"""Space used by in bytes"""
"""Space available in bytes"""
@dataclass
[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]
Overwrite = "overwrite"
@dataclass
@dataclass
@dataclass
@dataclass
@dataclass
[docs]
class ListFolderResult:
"""Result from listing the contents of a folder"""
[docs]
entries: list[Metadata]
"""List of entries"""
"""Whether there are more entries than listed"""
"""Cursor to iterate and fetch more entries"""
# ==== sharing =========================================================================
[docs]
class LinkAccessLevel(Enum):
"""Enum of access levels to shared links"""
[docs]
class LinkAudience(Enum):
"""Enum of shared link audience"""
@dataclass
[docs]
class LinkPermissions:
"""Permissions for a shared link"""
"""If the link can be revoked"""
"""If the link allows users to download the item"""
[docs]
effective_audience: LinkAudience
"""The effective audience of link (who can use it)"""
[docs]
link_access_level: LinkAccessLevel
"""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."""
@dataclass
@dataclass
[docs]
class ListSharedLinkResult:
"""Result from listing shared links"""
[docs]
entries: list[SharedLinkMetadata]
"""List of shared link metadata"""
"""Whether there are more items to fetch"""
"""A cursor to continue iterating over shared links"""
# ==== update checks ===================================================================
@dataclass
[docs]
class UpdateCheckResult:
"""Information on update availability"""
"""Whether an update to Maestral is available"""
"""The latest release that can be updated to"""
"""Release notes for all releases between the currently running version up to and
including the latest version"""