Skip to content

dependencies

Application dependency providers.

create_collection_dependencies

create_collection_dependencies()

Build mapping of collection dependencies.

Returns:

Type Description
dict[str, Provide]

A dictionary of provides for pagination endpoints.

provide_created_filter

provide_created_filter(
    before=Parameter(query="created-before", default=None, required=False),
    after=Parameter(query="created-after", default=None, required=False),
)

Parameters:

Name Type Description Default
before DTorNone

Filter for records created before this date/time.

Parameter(query='created-before', default=None, required=False)
after DTorNone

Filter for records created after this date/time.

Parameter(query='created-after', default=None, required=False)

Returns:

Type Description
BeforeAfter

Type consumed by Repository.filter_on_datetime_field().

provide_filter_dependencies

provide_filter_dependencies(
    created_filter=Dependency(skip_validation=True),
    updated_filter=Dependency(skip_validation=True),
    id_filter=Dependency(skip_validation=True),
    limit_offset=Dependency(skip_validation=True),
)

Inject filtering dependencies.

Add all filters to any route by including this function as a dependency, e.g:

@get
def get_collection_handler(filters: Filters) -> ...:
    ...

The dependency is provided at the application layer, so only need to inject the dependency where it is required.

Parameters:

Name Type Description Default
id_filter CollectionFilter[UUID]

Filter for scoping query to limited set of identities.

Dependency(skip_validation=True)
created_filter BeforeAfter

Filter for scoping query to instance creation date/time.

Dependency(skip_validation=True)
updated_filter BeforeAfter

Filter for scoping query to instance update date/time.

Dependency(skip_validation=True)
limit_offset LimitOffset

Filter for query pagination.

Dependency(skip_validation=True)

Returns:

Type Description
list[FilterTypes]

List of filters parsed from connection.

provide_id_filter

provide_id_filter(ids=Parameter(query='ids', default=None, required=False))

Parameters:

Name Type Description Default
ids list[UUID] | None

Parsed out of query params.

Parameter(query='ids', default=None, required=False)

Returns:

Type Description
CollectionFilter[UUID]

Type consumed by AbstractRepository.filter_in_collection()

provide_limit_offset_pagination

provide_limit_offset_pagination(
    page=Parameter(ge=1, default=1, required=False),
    page_size=Parameter(
        query="page-size", ge=1, default=settings.api.DEFAULT_PAGINATION_LIMIT, required=False
    ),
)

Parameters:

Name Type Description Default
page int

LIMIT to apply to select.

Parameter(ge=1, default=1, required=False)
page_size int

OFFSET to apply to select.

Parameter(query='page-size', ge=1, default=settings.api.DEFAULT_PAGINATION_LIMIT, required=False)

Returns:

Type Description
LimitOffset

Type consumed by Repository.apply_limit_offset_pagination().

provide_updated_filter

provide_updated_filter(
    before=Parameter(query="updated-before", default=None, required=False),
    after=Parameter(query="updated-after", default=None, required=False),
)

Parameters:

Name Type Description Default
before DTorNone

Filter for records updated before this date/time.

Parameter(query='updated-before', default=None, required=False)
after DTorNone

Filter for records updated after this date/time.

Parameter(query='updated-after', default=None, required=False)

Returns:

Type Description
BeforeAfter

Type consumed by Repository.filter_on_datetime_field().