zipline package
zipline.client module
- class zipline.Client(server_url, token)[source]
Bases:
objectA Zipline Client.
- async with x:
Returns the Client itself. Used to gracefully close the client on exit.
async with zipline.Client(server_url, token) as client: ...
- async create_user(*, username, password, administrator=False)[source]
This function is a coroutine.
Creates a User.
- Parameters:
- Returns:
The created User.
- Return type:
- Raises:
BadRequest – Something went wrong handling the request.
Forbidden – You are not an administrator and cannot use this method.
- async get_password_protected_image(*, id, password)[source]
This function is a coroutine.
Retrieves the content of a password protected File.
- Parameters:
- Returns:
The File’s content.
- Return type:
- Raises:
BadRequest – Something went wrong handling the request.
NotFound – The File could not be found on the server.
- async get_all_invites()[source]
This function is a coroutine.
Retrieves all Invites.
- Returns:
The invites on the server.
- Return type:
List[
Invite]- Raises:
BadRequest – Something went wrong handling this request.
Forbidden – You are not an administrator and do not have permission to access this resource.
- async create_invites(*, count=1, expires_at=None)[source]
This function is a coroutine.
Creates user invites.
- Parameters:
count (
int) – The number of invites to create, by default 1expires_at (Optional[
datetime.datetime]) – When the created invite(s) should expire, by default None
- Returns:
The created invites.
- Return type:
List[
PartialInvite]- Raises:
ZiplineError – The server returned the invites in an unexpected format.
BadRequest – The server could not process the request.
Forbidden – You are not an administrator and cannot use this method.
- async delete_invite(code, /)[source]
This function is a coroutine.
Deletes an Invite with given code.
- async get_all_folders(*, with_files=False)[source]
This function is a coroutine.
Returns all Folders
- async create_folder(name, /, *, files=None)[source]
This function is a coroutine.
Creates a Folder.
- Parameters:
- Returns:
The created Folder
- Return type:
- Raises:
BadRequest – The server could not process the request.
- async get_folder(id, /, *, with_files=False)[source]
This function is a coroutine.
Gets a folder with a given id.
- Parameters:
- Returns:
The requested Folder
- Return type:
- Raises:
- async get_all_files()[source]
This function is a coroutine.
Gets all Files belonging to your user.
- Returns:
The returned Files
- Return type:
List[
File]
- async get_recent_files(*, amount=4, filter='all')[source]
This function is a coroutine.
Gets recent files uploaded by you.
- Parameters:
amount (Optional[
int]) – The number of results to return. Must be in 1 <= amount <= 50, by default 4filter (Optional[Literal["all", "media"]]) – What files to get. “all” to get all Files, “media” to get images/videos/etc., by default “all”
- Returns:
The requested Files.
- Return type:
List[
File]- Raises:
ValueError – Amount was not within the specified bounds.
- async get_all_shortened_urls()[source]
This function is a coroutine.
Retrieves all shortened urls for your user.
- Returns:
The requested shortened urls.
- Return type:
List[
ShortenedURL]
- async shorten_url(original_url, *, vanity=None, max_views=None, zero_width_space=False)[source]
This function is a coroutine.
Shortens a url
- Parameters:
original_url (
str) – The url to shortenvanity (Optional[
str]) – A vanity name to use. None to shorten normally, by default Nonemax_views (Optional[
int]) – The number of times the url can be used before being deleted. None for unlimited uses, by default Nonezero_width_space (Optional[
bool]) – Whether to incude zero width spaces in the returned url, by default False
- Returns:
The shortened url
- Return type:
- Raises:
ValueError – Invalid value for max views passed.
BadRequest – The server could not process your request.
NotAuthenticated – An incorrect authorization header was passed
- async upload_file(payload, *, format=NameFormat.uuid, compression_percent=0, expiry=None, password=None, zero_width_space=False, embed=False, max_views=None, text=False, override_name=None, original_name=None, folder=None)[source]
This function is a coroutine.
Uploads a File to Zipline
- Parameters:
payload (
FileData) – The file to upload.format (Optional[
NameFormat]) – The format of the name to assign to the uploaded File, by defaultNameFormat’s uuid.compression_percent (Optional[
int]) – How compressed should the uploaded File be, by default 0expiry (Optional[
datetime.datetime]) – When the uploaded File should expire, by default Nonepassword (Optional[
str]) – The password required to view the uploaded File, by default Nonezero_width_space (Optional[
bool]) – Whether to include zero width spaces in the name of the uploaded File, by default Falseembed (Optional[
bool]) – Whether to include embed data for the uploaded File, typically used on Discord, by default Falsemax_views (Optional[
int]) – The number of times the uploaded File can be viewed before it is deleted, by default Nonetext (Optional[
bool]) – Whether the File is a text file, by default Falseoverride_name (Optional[
str]) – A name to give the uploaded file. If provided this will override the server generated name, by default Noneoriginal_name (Optional[
str]) – The original_name of the file. None to not preserve this data, by default Nonefolder (Optional[Union[
Folder,int]]) –The Folder (or it’s ID) to place this upload into automatically
New in version 0.15.0.
- Returns:
The uploaded File
- Return type:
- Raises:
ValueError – compression_percent was not in 0 <= compression_percent <= 100
ValueError – max_views passed was less than 0
ValueError – type passed for folder was incorrect
BadRequest – Server could not process the request
ServerError – The server responded with a 5xx error code.
zipline.models module
- class zipline.models.File(_session, created_at, expires_at, name, mimetype, id, favorite, views, folder_id, max_views, size, url, original_name)[source]
Bases:
objectRepresents a file stored on Zipline.
- created_at
When the File was created.
- Type:
- expires_at
When the File expires.
- Type:
Optional[
datetime.datetime]
- folder_id
The id of the Folder this File belongs to, None if the File is not in a Folder.
- Type:
Optional[
int]
- max_views
The number of times the File can be viewed before being removed. None if there is no limit.
- Type:
Optional[
int]
- original_name
The original_name of the File. None if this information wasn’t kept on upload.
- Type:
Optional[
str]
- async read()[source]
This function is a coroutine.
Read the File into memory.
- Returns:
The data of the File
- Return type:
- async delete()[source]
This function is a coroutine.
Delete this File.
- Raises:
NotFound – The file could not be found.
- property full_url
Returns the full URL of this File.
- class zipline.models.User(_session, id, username, avatar, token, administrator, super_admin, system_theme, embed, ratelimit, totp_secret, domains)[source]
Bases:
objectRepresents a Zipline User.
- totp_secret
The User’s Time-based One-Time Password (TOTP) secret. This secret is used for two-factor authentication (2FA). It is a unique secret key associated with the user’s account. If set, the user can generate time-based one-time passwords using this secret to enhance the security of their account.
- Type:
Optional[
str]
- class zipline.models.PartialInvite(code, created_by_id, expires_at)[source]
Bases:
objectRepresents a partial Zipline invite. This is returned by Client.create_invites.
- expires_at
When this invite expires. None if the invite does not expire.
- Type:
Optional[
datetime.datetime]
- class zipline.models.Invite(_session, code, id, created_at, expires_at, used, created_by_id)[source]
Bases:
objectRepresents a Zipline invite.
- created_at
When the Invite was created.
- Type:
- expires_at
When the Invite expires. None if it does not expire.
- Type:
Optional[
datetime.datetime]
- property url
The full url of this invite.
- class zipline.models.Folder(_session, id, name, user_id, created_at, updated_at, files)[source]
Bases:
objectRepresents a Zipline folder.
- created_at
When the Folder was created.
- Type:
- updated_at
When the folder was last updated.
- Type:
- files
The Files in this Folder, if any. None if the Folder was fetched without files.
- Type:
List[
File]
- async add_file(file, /)[source]
This function is a coroutine.
Adds a File to this Folder
- Parameters:
file (
File) – The File to add.- Raises:
BadRequest – There was an error adding the file
UnhandledError – An unexpected exception occured, please report this to the developer.
- async remove_file(file, /)[source]
This function is a coroutine.
Removes a File from this Folder
- Parameters:
file (
File) – The File to remove.- Raises:
BadRequest – There was an error removing the file
UnhandledError – An unexpected exception occured, please report this to the developer.
- class zipline.models.ShortenedURL(_session, created_at, id, destination, vanity, views, max_views, url)[source]
Bases:
objectRepresents a shortened url on Zipline.
- created_at
When the url was created.
- Type:
- max_views
The number of times this url can be viewed before deletion. None if there is no limit.
- Type:
Optional[
int]
- async delete()[source]
This function is a coroutine.
Deletes this
ShortenedURL.
- class zipline.models.UploadResponse(file_urls, expires_at, removed_gps)[source]
Bases:
objectRepresents a response to a File upload.
- expires_at
When the uploads expire. None if they do not expire.
- Type:
Optional[
datetime.datetime]
zipline.enums module
zipline.errors module
- class zipline.errors.UnhandledError[source]
Bases:
ZiplineErrorRaised by the library if the server returns a status code not handled by the lib.
- class zipline.errors.BadRequest[source]
Bases:
ZiplineErrorServer returned a 400 response.
- class zipline.errors.Forbidden[source]
Bases:
ZiplineErrorServer returned a 401 response.
- class zipline.errors.NotFound[source]
Bases:
ZiplineErrorServer returned a 404 response.
- class zipline.errors.ServerError[source]
Bases:
ZiplineErrorServer returned a 5xx response code.
- class zipline.errors.NotAuthenticated[source]
Bases:
ZiplineErrorRequesting data without an Authorization header