2023-12-20 18:13:55 -05:00
|
|
|
"""This is a list of all the models used in PyZipline. They are used to represent the data returned from the Zipline API."""
|
2023-12-19 05:36:18 -05:00
|
|
|
from datetime import datetime
|
2024-03-28 11:15:27 -04:00
|
|
|
from typing import Dict, List, Optional, Union
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
from pydantic import BaseModel, Field
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
|
|
|
|
class File(BaseModel):
|
2023-12-20 18:13:55 -05:00
|
|
|
"""File object used for uploading files to Zipline
|
|
|
|
|
2023-12-20 21:37:02 -05:00
|
|
|
Attributes:
|
2024-03-28 11:15:27 -04:00
|
|
|
createdAt (datetime.datetime): Datetime object of when the file was created
|
2023-12-20 18:13:55 -05:00
|
|
|
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
|
2024-03-28 11:15:27 -04:00
|
|
|
originalName (Optional[str]): String of the file's original name
|
2023-12-21 14:08:55 -05:00
|
|
|
url (Optional[str]): String of the file's URL
|
2024-03-28 11:15:27 -04:00
|
|
|
maxViews (Optional[int]): Integer of the file's maximum number of views
|
|
|
|
expiredAt (Optional[datetime]): Datetime object of when the file will expire
|
2023-12-21 14:08:55 -05:00
|
|
|
thumbnail (Optional[str]): String of the file's thumbnail URL
|
2024-03-28 11:15:27 -04:00
|
|
|
folderId (Optional[int]): Integer of the file's folder ID
|
2023-12-20 18:13:55 -05:00
|
|
|
"""
|
2024-03-28 11:15:27 -04:00
|
|
|
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
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2023-12-21 14:08:55 -05:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
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
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
def __str__(self):
|
|
|
|
return self.code
|
|
|
|
|
|
|
|
class Result(BaseModel):
|
2023-12-20 18:13:55 -05:00
|
|
|
"""Result returned from low-level RestAdapter
|
|
|
|
|
2023-12-20 21:37:02 -05:00
|
|
|
Attributes:
|
2023-12-20 18:13:55 -05:00
|
|
|
success (bool): Boolean of whether the request was successful
|
|
|
|
status_code (int): Standard HTTP Status code
|
|
|
|
message (str = ''): Human readable result
|
2023-12-21 14:08:55 -05:00
|
|
|
data (Union[List[Dict], Dict]): Python List of Dictionaries (or maybe just a single Dictionary on error)
|
2023-12-20 18:13:55 -05:00
|
|
|
"""
|
2024-03-28 11:15:27 -04:00
|
|
|
success: bool
|
|
|
|
status_code: int
|
|
|
|
message: str = ''
|
|
|
|
data: Union[List[Dict], Dict] = {}
|
2023-12-21 14:08:55 -05:00
|
|
|
|
|
|
|
def __str__(self):
|
2024-03-28 11:15:27 -04:00
|
|
|
return f"{self.status_code}: {self.message}"
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
class TypesCountItem(BaseModel):
|
|
|
|
"""Model used in [StatsData](.#pyzipline.models.StatsData) for storing the number of files with a specific mimetype
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
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}"
|
|
|
|
|
|
|
|
|
|
|
|
class CountByUserItem(BaseModel):
|
|
|
|
"""Model used in [StatsData](.#pyzipline.models.StatsData) for storing the number of files uploaded by a user
|
2023-12-20 18:13:55 -05:00
|
|
|
|
2023-12-20 21:37:02 -05:00
|
|
|
Attributes:
|
2024-03-28 11:15:27 -04:00
|
|
|
username (str): String of the username
|
|
|
|
count (int): Integer of the number of files uploaded by this user
|
2023-12-20 18:13:55 -05:00
|
|
|
"""
|
2024-03-28 11:15:27 -04:00
|
|
|
count: int
|
|
|
|
username: str
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2023-12-21 14:08:55 -05:00
|
|
|
def __str__(self):
|
2024-03-28 11:15:27 -04:00
|
|
|
return f"{self.username}: {self.count}"
|
2023-12-21 14:08:55 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
|
|
|
|
class StatsData(BaseModel):
|
|
|
|
"""Stats data model
|
2023-12-21 14:08:55 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
2024-03-28 11:15:27 -04:00
|
|
|
size: str
|
|
|
|
count: int
|
|
|
|
size_num: int
|
|
|
|
count_users: int
|
|
|
|
types_count: List[TypesCountItem]
|
|
|
|
views_count: int
|
|
|
|
count_by_user: List[CountByUserItem]
|
2023-12-19 05:36:18 -05:00
|
|
|
|
2023-12-21 15:34:04 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
class Stats(BaseModel):
|
|
|
|
"""Stats model
|
2023-12-20 18:13:55 -05:00
|
|
|
|
2023-12-20 21:37:02 -05:00
|
|
|
Attributes:
|
2024-03-28 11:15:27 -04:00
|
|
|
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
|
2023-12-20 18:13:55 -05:00
|
|
|
"""
|
2024-03-28 11:15:27 -04:00
|
|
|
id: int
|
|
|
|
createdAt: datetime
|
|
|
|
data: StatsData
|
|
|
|
max_timestamp: str = Field(default=None)
|
|
|
|
|
|
|
|
|
|
|
|
class Embed(BaseModel):
|
|
|
|
color: Optional[str] = None
|
|
|
|
title: Optional[str] = None
|
|
|
|
siteName: Optional[str] = None
|
|
|
|
description: Optional[str] = None
|
|
|
|
|
|
|
|
|
|
|
|
class User(BaseModel):
|
|
|
|
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]
|
2023-12-21 14:08:55 -05:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.username
|
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
class Versions(BaseModel):
|
|
|
|
stable: str
|
|
|
|
upstream: str
|
|
|
|
current: str
|
2023-12-21 14:08:55 -05:00
|
|
|
|
2024-03-28 11:15:27 -04:00
|
|
|
|
|
|
|
class Version(BaseModel):
|
|
|
|
isUpstream: bool
|
|
|
|
updateToType: str
|
|
|
|
versions: Versions
|
2023-12-21 14:08:55 -05:00
|
|
|
|
|
|
|
def __str__(self):
|
2024-03-28 11:15:27 -04:00
|
|
|
return self.versions.current
|