Internals Reference

This page contains reference to this package’s internals.

Classes

[source]final class ntfy_api.__version__._version_info(major: int, minor: int, micro: int, pre: int, post: int, dev: int)

Bases: tuple[int, int, int, int, int, int]

A version tuple implementation in many ways similar to sys.version_info. Acts as a singleton.

Composed of major(), minor(), micro(), pre(), post(), and dev() versions (in that order).

[source]property major: int

The major version (compatability).

[source]property minor: int

The minor version (features).

[source]property micro: int

The micro version (patches).

[source]property pre: int

The pre-release version.

[source]property post: int

The post-release version.

[source]property dev: int

The dev-release version.

[source]method version_str() str

The version str, e.g. 0.4.2.

[source]method release_str() str

The release str, e.g. 0.4.2.post3.dev1.

[source]class ntfy_api.actions._Action

Action base class that is used to handle formatting.

[source]method serialize() str

Serialize this action into a single header value.

Returns:

The serialized header value.

Return type:

str

[source]class ntfy_api.filter._Filter

A slightly modified version of _Message that is used to handle formatting.

[source]method serialize() dict[str, Any]

Serialize this filter into a header dictionary.

[source]class ntfy_api.message._Message

Message base class that is used to handle formatting.

[source]method serialize() dict[str, Any]

Serialize this message into a header dictionary.

[source]class ntfy_api.message._ReceivedAttachment(name: str, url: str, type: str | None = None, size: int | None = None, expires: int | None = None)

Bases: ReceivedAttachment, WrappingDataclass

Private implementation of the ReceivedAttachment protocol.

Parameters:
  • name (str) – Name of the attachment.

  • url (str) – URL of the attachment.

  • type (str | None) – Mime type of the attachment (only if uploaded to ntfy server).

  • size (int | None) – Size in bytes (only if uploaded to ntfy server).

  • expires (int | None) – Expiry date as Unix timestamp (only if uploaded to ntfy server).

ivar expires: int | None

See the expires parameter.

ivar name: str

See the name parameter.

ivar size: int | None

See the size parameter.

ivar type: str | None

See the type parameter.

ivar url: str

See the url parameter.

[source]class ntfy_api.message._ReceivedMessage(id: str, time: int, event: Event, topic: str, message: str | None = None, expires: int | None = None, title: str | None = None, tags: tuple[Tag, ...] | None = None, priority: Priority | None = None, click: str | None = None, actions: tuple[ReceivedViewAction | ReceivedBroadcastAction | ReceivedHTTPAction, ...] | None = None, attachment: ReceivedAttachment | None = None, icon: str | None = None, content_type: str | None = None)

Bases: ReceivedMessage, WrappingDataclass

Private implementation of the ReceivedMessage protocol.

Parameters:
  • id (str) – Randomly chosen message identifier.

  • time (int) – Message datetime as Unix timestamp.

  • event (Event) – Type of event.

  • topic (str) – Topics the message is associated with.

  • message (str | None) – Messag body.

  • expires (int | None) – When the message will be deleted.

  • title (str | None) – Message title.

  • tags (tuple[Tag, ...] | None) – List of tags that may map to emojis.

  • priority (Priority | None) – Message priority.

  • click (str | None) – Website opened when notification is clicked.

  • actions (tuple[ReceivedAction, ...] | None) – Action buttons that can be displayed.

  • attachment (ReceivedAttachment | None) – Details about an attachment if present.

  • icon (str | None) – The icon URL sent with the message.

  • content_type (str | None) – The content type.

ivar actions: tuple[ReceivedViewAction | ReceivedBroadcastAction | ReceivedHTTPAction, ...] | None

See the actions parameter.

ivar attachment: ReceivedAttachment | None

See the attachment parameter.

ivar click: str | None

See the click parameter.

ivar content_type: str | None

See the content_type parameter.

ivar event: Event

See the event parameter.

ivar expires: int | None

See the expires parameter.

ivar icon: str | None

See the icon parameter.

ivar id: str

See the id parameter.

ivar message: str | None

See the message parameter.

ivar priority: Priority | None

See the priority parameter.

ivar tags: tuple[Tag, ...] | None

See the tags parameter.

ivar time: int

See the time parameter.

ivar title: str | None

See the title parameter.

ivar topic: str

See the topic parameter.

[source]class ntfy_api._internals.URL(scheme: str, netloc: str, path: str, params: str, query: str, fragment: str)

Internal URL handling for ntfy API endpoints.

Parameters:
  • scheme (str) – The URL scheme (e.g., scheme in scheme://netloc/path;parameters?query#fragment).

  • netloc (str) – The URL netloc (e.g., netloc in scheme://netloc/path;parameters?query#fragment).

  • path (str) – The URL path (e.g., path in scheme://netloc/path;parameters?query#fragment).

  • params (str) – The URL params (e.g., params in scheme://netloc/path;parameters?query#fragment).

  • query (str) – The URL query (e.g., query in scheme://netloc/path;parameters?query#fragment).

  • fragment (str) – The URL fragment (e.g., fragment in scheme://netloc/path;parameters?query#fragment).

ivar scheme: str

See the scheme parameter.

ivar netloc: str

See the netloc parameter.

ivar path: str

See the path parameter.

ivar params: str

See the params parameter.

ivar query: str

See the query parameter.

ivar fragment: str

See the fragment parameter.

[source]classmethod parse(url: str) Self

Parse a URL-like string into a new URL instance.

Parameters:

url (str) – The URL-like string to parse.

Returns:

A new URL instance.

Return type:

URL

[source]method unparse(endpoint: str | Iterable[str] | None = None, scheme: tuple[str, str] | None = None) str

Reconstruct the full URL string.

Parameters:
  • endpoint (str | Iterable[str] | None, optional) – An endpoint to be appended to the path before parsing.

  • scheme (tuple[str, str] | None, optional) – A scheme two-tuple (insecure, secure) to be used instead of the existing scheme. Which version is used (insecure vs secure) will be decided based on the current scheme’s security status.

Returns:

The constructed URL.

Return type:

str

[source]class ntfy_api._internals.WrappingDataclass

A special dataclass type that allows for its attributes to be annotated with wrapper types.

[source]classmethod from_json(data: Mapping[str, Any]) Self

Parse a new WrappingDataclass instance from the given data.

Note

data is not modified when wrappers (if any) are applied. Instead, a shallow copy of the mapping is created and used. Keep in mind that, because it is a shallow copy, the wrappers may still modify the mapping values in-place.

Parameters:

data (Mapping[str, Any]) – The JSON-like data.

Returns:

The parsed WrappingDataclass instance.

Return type:

WrappingDataclass

[source]class ntfy_api._internals.ClearableQueue(maxsize=0)

Bases: Queue[_T]

A queue.Queue subclass that adds a single clear() method, which clears all remaining items in the queue.

[source]method clear() None

Clear all remaining items in the queue.

Type Variables

typevar ntfy_api._internals._T = TypeVar('_T')