flaretool.shorturl package

Submodules

flaretool.shorturl.ShortUrlService module

Class for interacting with a short URL service.

Warning

This class may undergo updates and its usage may change in the near future.

flaretool.shorturl.errors module

exception flaretool.shorturl.errors.ShortUrlAuthenticationError(message, author=None, response=None, data=None)

Bases: ShortUrlError

exception flaretool.shorturl.errors.ShortUrlDataUpdateError(message, author=None, response=None, data=None)

Bases: ShortUrlError

exception flaretool.shorturl.errors.ShortUrlError(message, author=None, response=None, data=None)

Bases: FlareToolError

exception flaretool.shorturl.errors.ShortUrlValidError(message, author=None, response=None, data=None)

Bases: ShortUrlError

flaretool.shorturl.models module

class flaretool.shorturl.models.ShortUrlInfo(*args, id: int, url: str, title: str, code: str, tag: str | None = None, description: str | None = None, owner: str, is_active: bool, is_eternal: bool, limited_at: datetime | None = None, created_at: datetime, updated_at: datetime, short_url: str = '', qr_url: str = '')

Bases: BaseDataModel

code: str
created_at: datetime
description: str | None
classmethod get_qr_url(value, values)
id: int
is_active: bool
is_eternal: bool
limited_at: datetime | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

owner: str
qr_url: str
short_url: str
tag: str | None
title: str
updated_at: datetime
url: str

Module contents

class flaretool.shorturl.ShortUrlService

Bases: object

Class for interacting with a short URL service. WebAPI Wrapper class.

create(url: str, code: str = None, description: str = None, is_eternal: bool = None, is_active: bool = None) ShortUrlInfo

Create a new short URL.

Parameters:
  • url (str) – URL to shorten.

  • code (str) – Custom code for the short URL (default: None).

  • description (str) – Description of the short URL (default: None).

  • is_eternal (bool) – Whether the short URL is eternal (default: None).

  • is_active (bool) – Whether the short URL is active (default: None).

Returns:

Information about the created short URL.

Return type:

ShortUrlInfo

Raises:
delete(url_info: ShortUrlInfo)

Delete a short URL.

Parameters:

url_info (ShortUrlInfo) – Updated information about the short URL.

Raises:
get(id: int = None) list[ShortUrlInfo]

Get informations about a short URL.

Parameters:

id (int) – ID of the short URL (default: None).

Returns:

Information about the short URL.

Return type:

list[ShortUrlInfo]

Raises:
get_qr_code_raw_data(url_info: ShortUrlInfo) bytes

Get QR Code raw data

Parameters:

url_info (ShortUrlInfo) – target information about the short URL.

Returns:

image bytes data.

Return type:

bytes

update(url_info: ShortUrlInfo) ShortUrlInfo

Update a short URL.

Parameters:

url_info (ShortUrlInfo) – Updated information about the short URL.

Returns:

Information about the updated short URL.

Return type:

ShortUrlInfo

Raises: