Skip to content

Models Reference

This is a list of all the models used in PyZipline. They are used to represent the data returned from the Zipline API.

Classes:

Name Description
CountByUserItem

Model used in StatsData for storing the number of files uploaded by a user

Embed

Object containing a user's embed settings

File

File object used for uploading files to Zipline

Invite

Invite object used for managing invites

Result

Result returned from low-level RestAdapter

Stats

Stats model

StatsData

Stats data model

TypesCountItem

Model used in StatsData for storing the number of files with a specific mimetype

User

Object containing user information

Version

Model containing the current, stable, and upstream versions of Zipline

Versions

Object containing the current, stable, and upstream versions of Zipline

ZiplineApiConfig

Represents a configuration instance for the ZiplineApi/RestAdapter class.

CountByUserItem

Bases: BaseModel

Model used in StatsData for storing the number of files uploaded by a user

Attributes:

Name Type Description
username str

String of the username

count int

Integer of the number of files uploaded by this user

Source code in pyzipline/models.py
class CountByUserItem(BaseModel):
    """Model used in [StatsData](.#pyzipline.models.StatsData) for storing the number of files uploaded by a user

    Attributes:
        username (str): String of the username
        count (int): Integer of the number of files uploaded by this user
    """
    count: int
    username: str

    def __str__(self):
        return f"{self.username}: {self.count}"

Embed

Bases: BaseModel

Object containing a user's embed settings

Attributes:

Name Type Description
color Optional[str]

String of the embed's color

title Optional[str]

String of the embed's title

site_name Optional[str]

String of the embed's site name

description Optional[str]

String of the embed's description

Source code in pyzipline/models.py
class Embed(BaseModel):
    """Object containing a user's embed settings

    Attributes:
        color (Optional[str]): String of the embed's color
        title (Optional[str]): String of the embed's title
        site_name (Optional[str]): String of the embed's site name
        description (Optional[str]): String of the embed's description
    """
    color: Optional[str] = None
    title: Optional[str] = None
    siteName: Optional[str] = None
    description: Optional[str] = None

    def __str__(self):
        if self.title is None:
            return "None"
        return self.title

File

Bases: BaseModel

File object used for uploading files to Zipline

Attributes:

Name Type Description
createdAt datetime

Datetime object of when the file was created

id int

ID of the file

mimetype str

String of the file's mimetype

views int

Integer of the number of views the file has

name str

String of the file's name

size int

Integer of the file's size in bytes

favorite bool

Boolean of whether the file is favorited

originalName Optional[str]

String of the file's original name

url Optional[str]

String of the file's URL

maxViews Optional[int]

Integer of the file's maximum number of views

expiredAt Optional[datetime]

Datetime object of when the file will expire

thumbnail Optional[str]

String of the file's thumbnail URL

folderId Optional[int]

Integer of the file's folder ID

Source code in pyzipline/models.py
class File(BaseModel):
    """File object used for uploading files to Zipline

    Attributes:
        createdAt (datetime.datetime): Datetime object of when the file was created
        id (int): ID of the file
        mimetype (str): String of the file's mimetype
        views (int): Integer of the number of views the file has
        name (str): String of the file's name
        size (int): Integer of the file's size in bytes
        favorite (bool): Boolean of whether the file is favorited
        originalName (Optional[str]): String of the file's original name
        url (Optional[str]): String of the file's URL
        maxViews (Optional[int]): Integer of the file's maximum number of views
        expiredAt (Optional[datetime]): Datetime object of when the file will expire
        thumbnail (Optional[str]): String of the file's thumbnail URL
        folderId (Optional[int]): Integer of the file's folder ID
    """
    createdAt: datetime
    id: int
    mimetype: str
    views: int
    name: str
    size: int
    favorite: bool
    originalName: Optional[str] = None
    url: Optional[str] = None
    maxViews: Optional[int] = None
    expiredAt: Optional[datetime] = None
    thumbnail: Optional[str] = None
    folderId: Optional[int] = None

    def __str__(self):
        return self.name

Invite

Bases: BaseModel

Invite object used for managing invites

Attributes:

Name Type Description
id int

Integer ID of the invite

code str

String of the invite's code

createdAt datetime

Datetime object of when the invite was created

expiresAt datetime

Datetime object of when the invite will expire

used bool

Boolean of whether the invite has been used

createdById int

Integer ID of the user who created the invite

Source code in pyzipline/models.py
class Invite(BaseModel):
    """Invite object used for managing invites

    Attributes:
        id (int): Integer ID of the invite
        code (str): String of the invite's code
        createdAt (datetime): Datetime object of when the invite was created
        expiresAt (datetime): Datetime object of when the invite will expire
        used (bool): Boolean of whether the invite has been used
        createdById (int): Integer ID of the user who created the invite
    """
    id: int
    code: str
    createdAt: datetime
    expiresAt: datetime
    used: bool
    createdById: int

    def __str__(self):
        return self.code

Result

Bases: BaseModel

Result returned from low-level RestAdapter

Attributes:

Name Type Description
success bool

Boolean of whether the request was successful

status_code int

Standard HTTP Status code

message str = ''

Human readable result

data Union[List[Dict], Dict]

Python List of Dictionaries (or maybe just a single Dictionary on error)

Source code in pyzipline/models.py
class Result(BaseModel):
    """Result returned from low-level RestAdapter

    Attributes:
        success (bool): Boolean of whether the request was successful
        status_code (int): Standard HTTP Status code
        message (str = ''): Human readable result
        data (Union[List[Dict], Dict]): Python List of Dictionaries (or maybe just a single Dictionary on error)
    """
    success: bool
    status_code: int
    message: str = ''
    data: Union[List[Dict], Dict] = {}

    def __str__(self):
        return f"{self.status_code}: {self.message}"

Stats

Bases: BaseModel

Stats model

Attributes:

Name Type Description
id int

Integer ID of the stats

createdAt datetime

Datetime object of when the stats were created

data StatsData

StatsData object of the stats data

max_timestamp Optional[datetime]

Datetime object of the maximum timestamp of the stats

Source code in pyzipline/models.py
class Stats(BaseModel):
    """Stats model

    Attributes:
        id (int): Integer ID of the stats
        createdAt (datetime): Datetime object of when the stats were created
        data (StatsData): StatsData object of the stats data
        max_timestamp (Optional[datetime]): Datetime object of the maximum timestamp of the stats
    """
    id: int
    createdAt: datetime
    data: StatsData
    max_timestamp: str = Field(default=None)

StatsData

Bases: BaseModel

Stats data model

Attributes:

Name Type Description
id int

Integer ID of the stats

createdAt datetime

Datetime object of when the stats were created

max_timestamp Optional[datetime]

Datetime object of the maximum timestamp of the stats

size str

String of the size of the files

size_num int

Integer of the size of the files in bytes

count int

Integer of the number of files

count_users int

Integer of the number of users

views_count int

Integer of the number of views

types_count Optional[List[Mimetype]]

List of Mimetype objects

count_by_user Optional[List[CountByUser]]

List of CountByUser objects

Source code in pyzipline/models.py
class StatsData(BaseModel):
    """Stats data model

    Attributes:
        id (int): Integer ID of the stats
        createdAt (datetime): Datetime object of when the stats were created
        max_timestamp (Optional[datetime]): Datetime object of the maximum timestamp of the stats
        size (str): String of the size of the files
        size_num (int): Integer of the size of the files in bytes
        count (int): Integer of the number of files
        count_users (int): Integer of the number of users
        views_count (int): Integer of the number of views
        types_count (Optional[List[Mimetype]]): List of Mimetype objects
        count_by_user (Optional[List[CountByUser]]): List of CountByUser objects
    """
    size: str
    count: int
    size_num: int
    count_users: int
    types_count: List[TypesCountItem]
    views_count: int
    count_by_user: List[CountByUserItem]

TypesCountItem

Bases: BaseModel

Model used in StatsData for storing the number of files with a specific mimetype

Attributes:

Name Type Description
mimetype str

String of the mimetype

count int

Integer of the number of files with this mimetype

Source code in pyzipline/models.py
class TypesCountItem(BaseModel):
    """Model used in [StatsData](.#pyzipline.models.StatsData) for storing the number of files with a specific mimetype

    Attributes:
        mimetype (str): String of the mimetype
        count (int): Integer of the number of files with this mimetype
    """
    count: int
    mimetype: str

    def __str__(self):
        return f"{self.mimetype}: {self.count}"

User

Bases: BaseModel

Object containing user information

Contains Sensitive Information

Please be mindful of how you use/store this object, as it contains sensitive information such as the user's token and TOTP information.

Attributes:

Name Type Description
id int

Integer ID of the user

uuid str

String of the user's UUID

username str

String of the user's username

avatar Optional[str]

String of the user's avatar, base64 encoded

token str

String of the user's token

administrator bool

Boolean of whether the user is an administrator

super_admin bool

Boolean of whether the user is a super administrator

system_theme str

String of the user's system theme

embed Embed

Embed object of the user's embed

totp_secret Optional[str]

String of the user's TOTP secret

domains List[str]

List of Strings of the user's domains

oauth Optional[List[OAuth]]

List of OAuth objects

ratelimit Optional[datetime]

Datetime object of when the user's ratelimit expires

Source code in pyzipline/models.py
class User(BaseModel):
    """Object containing user information

    /// admonition | Contains Sensitive Information
        type: danger
    Please be mindful of how you use/store this object, as it contains sensitive information such as the user's token and TOTP information.
    ///

    Attributes:
        id (int): Integer ID of the user
        uuid (str): String of the user's UUID
        username (str): String of the user's username
        avatar (Optional[str]): String of the user's avatar, base64 encoded
        token (str): String of the user's token
        administrator (bool): Boolean of whether the user is an administrator
        super_admin (bool): Boolean of whether the user is a super administrator
        system_theme (str): String of the user's system theme
        embed (Embed): Embed object of the user's embed
        totp_secret (Optional[str]): String of the user's TOTP secret
        domains (List[str]): List of Strings of the user's domains
        oauth (Optional[List[OAuth]]): List of [OAuth](.#pyzipline.models.OAuth) objects
        ratelimit (Optional[datetime]): Datetime object of when the user's ratelimit expires
    """
    id: int
    uuid: str
    username: str
    avatar: Optional[str]
    token: str
    administrator: bool
    superAdmin: bool
    systemTheme: str
    embed: Embed
    ratelimit: None
    totpSecret: Optional[str]
    domains: List[str]

    def __str__(self):
        return self.username

Version

Bases: BaseModel

Model containing the current, stable, and upstream versions of Zipline

Attributes:

Name Type Description
is_upstream bool

Boolean of whether the current version is upstream (trunk branch)

update_to_type str

String of the type of update available, one of 'stable' or 'upstream'

versions Versions

Versions object containing the current, stable, and upstream versions

Source code in pyzipline/models.py
class Version(BaseModel):
    """Model containing the current, stable, and upstream versions of Zipline

    Attributes:
        is_upstream (bool): Boolean of whether the current version is upstream (`trunk` branch)
        update_to_type (str): String of the type of update available, one of 'stable' or 'upstream'
        versions (Versions): Versions object containing the current, stable, and upstream versions
    """
    isUpstream: bool
    updateToType: str
    versions: Versions

    def __str__(self):
        return self.versions.current

Versions

Bases: BaseModel

Object containing the current, stable, and upstream versions of Zipline

Attributes:

Name Type Description
stable str

String of the stable version

upstream str

String of the upstream version

current str

String of the current version

Source code in pyzipline/models.py
class Versions(BaseModel):
    """Object containing the current, stable, and upstream versions of Zipline

    Attributes:
        stable (str): String of the stable version
        upstream (str): String of the upstream version
        current (str): String of the current version
    """
    stable: str
    upstream: str
    current: str

ZiplineApiConfig

Bases: BaseModel

Represents a configuration instance for the ZiplineApi/RestAdapter class.

Parameters:

Name Type Description Default
hostname str

The hostname of your Zipline instance, WITHOUT https or http.

required
token str

String used for authentication when making requests.

required
ssl bool

Normally set to True, but if your Zipline instance doesn't use SSL/TLS, set this to False.

required
enforced_signing bool

Normally set to True, but if having SSL/TLS cert validation issues, can turn off with False.

required
logger Logger

If your app has a logger, pass it in here.

required
Source code in pyzipline/models.py
class ZiplineApiConfig(BaseModel):
    """Represents a configuration instance for the ZiplineApi/RestAdapter class.

    Args:
        hostname (str): The hostname of your Zipline instance, WITHOUT https or http.
        token (str): String used for authentication when making requests.
        ssl (bool): Normally set to True, but if your Zipline instance doesn't use SSL/TLS, set this to False.
        enforced_signing (bool): Normally set to True, but if having SSL/TLS cert validation issues, can turn off with False.
        logger (logging.Logger): If your app has a logger, pass it in here.
    """
    model_config = ConfigDict(arbitrary_types_allowed=True)
    hostname: str
    token: str = ''
    ssl: bool = True
    enforced_signing: bool = True
    logger: logging.Logger = logging.getLogger(__name__)