paperap.models.share_links.queryset module

Provide query functionality for ShareLinks resources in Paperless-NgX.

Contains the ShareLinksQuerySet class, which extends StandardQuerySet to provide specialized filtering methods for ShareLinks resources. Enables efficient querying of share links by various attributes such as expiration date, document association, and creation time.

class paperap.models.share_links.queryset.ShareLinksQuerySet(resource, filters=None, _cache=None, _fetch_all=False, _next_url=None, _last_response=None, _iter=None, _urls_fetched=None)[source]

Bases: StandardQuerySet[ShareLinks]

Implement a lazy-loaded, chainable query interface for ShareLinks resources.

Extends StandardQuerySet to provide ShareLinks-specific filtering methods, including filtering by expiration date, slug, document, and file version. Only fetches data when it’s actually needed, providing pagination, filtering, and caching functionality similar to Django’s QuerySet.

Examples

Get all share links:
>>> all_links = client.share_links.all()
Filter by document ID:
>>> doc_links = client.share_links.filter(document=123)
Find links that expire soon:
>>> import datetime
>>> tomorrow = datetime.datetime.now() + datetime.timedelta(days=1)
>>> expiring_soon = client.share_links.expiration_before(tomorrow)
Parameters:
  • resource (BaseResource[_Model, Self])

  • filters (dict[str, Any] | None)

  • _cache (list[_Model] | None)

  • _fetch_all (bool)

  • _next_url (str | None)

  • _last_response (ClientResponse)

  • _iter (Iterator[_Model] | None)

  • _urls_fetched (list[str] | None)

expiration_before(value)[source]

Filter ShareLinks where expiration date is before the specified value.

Parameters:

value (datetime | str) – The datetime or ISO-formatted string to compare against. If a string is provided, it should be in ISO format (YYYY-MM-DDTHH:MM:SSZ).

Returns:

A filtered queryset containing only ShareLinks that expire before the given date.

Return type:

Self

Examples

Find links expiring in the next week:
>>> next_week = datetime.datetime.now() + datetime.timedelta(days=7)
>>> expiring_soon = client.share_links.expiration_before(next_week)
Using string format:
>>> expiring_soon = client.share_links.expiration_before("2023-12-31T23:59:59Z")
expiration_after(value)[source]

Filter ShareLinks where expiration date is after the specified value.

Parameters:

value (datetime | str) – The datetime or ISO-formatted string to compare against. If a string is provided, it should be in ISO format (YYYY-MM-DDTHH:MM:SSZ).

Returns:

A filtered queryset containing only ShareLinks that expire after the given date.

Return type:

Self

Examples

Find links that haven’t expired yet:
>>> now = datetime.datetime.now()
>>> valid_links = client.share_links.expiration_after(now)
slug(value, *, exact=True, case_insensitive=True)[source]

Filter ShareLinks by their slug value.

The slug is a unique identifier for the share link that appears in the URL.

Parameters:
  • value (str) – The slug value to filter by.

  • exact (bool) – If True, matches the exact slug. If False, performs a contains search.

  • case_insensitive (bool) – If True, performs case-insensitive matching. If False, matching is case-sensitive.

Returns:

A filtered queryset containing ShareLinks matching the slug criteria.

Return type:

Self

Examples

Find a specific share link by its exact slug:
>>> link = client.share_links.slug("abc123def")
Find links containing a substring in their slug:
>>> links = client.share_links.slug("invoice", exact=False)
document(value)[source]

Filter ShareLinks by associated document ID(s).

Parameters:

value (int | list[int]) – Either a single document ID or a list of document IDs to filter by. When a list is provided, links associated with any of the documents will be returned.

Returns:

A filtered queryset containing ShareLinks associated with the specified document(s).

Return type:

Self

Examples

Find all share links for a specific document:
>>> doc_links = client.share_links.document(123)
Find links for multiple documents:
>>> multi_doc_links = client.share_links.document([123, 456, 789])
file_version(value)[source]

Filter ShareLinks by file version.

In Paperless-NgX, share links can be created for specific versions of a document. This method filters links by their associated file version.

Parameters:

value (str) – The file version string to filter by (e.g., “archive”, “original”).

Returns:

A filtered queryset containing ShareLinks with the specified file version.

Return type:

Self

Examples

Find all share links for original document versions:
>>> original_links = client.share_links.file_version("original")
Find all share links for archived versions:
>>> archive_links = client.share_links.file_version("archive")
created_before(date)[source]

Filter ShareLinks created before a given date.

Parameters:

date (datetime) – The datetime to compare against. ShareLinks created before this datetime will be included in the results.

Returns:

A filtered queryset containing ShareLinks created before the specified date.

Return type:

Self

Examples

Find links created before last month:
>>> last_month = datetime.datetime.now() - datetime.timedelta(days=30)
>>> old_links = client.share_links.created_before(last_month)
created_after(date)[source]

Filter ShareLinks created after a given date.

Parameters:

date (datetime) – The datetime to compare against. ShareLinks created after this datetime will be included in the results.

Returns:

A filtered queryset containing ShareLinks created after the specified date.

Return type:

Self

Examples

Find links created in the last week:
>>> last_week = datetime.datetime.now() - datetime.timedelta(days=7)
>>> recent_links = client.share_links.created_after(last_week)
created_between(start, end)[source]

Filter ShareLinks created between two dates.

Parameters:
  • start (datetime) – The start datetime. ShareLinks created at or after this datetime will be included in the results.

  • end (datetime) – The end datetime. ShareLinks created at or before this datetime will be included in the results.

Returns:

A filtered queryset containing ShareLinks created within the specified date range.

Return type:

Self

Examples

Find links created in January 2023:
>>> start = datetime.datetime(2023, 1, 1)
>>> end = datetime.datetime(2023, 1, 31, 23, 59, 59)
>>> jan_links = client.share_links.created_between(start, end)