dump-things-service/dump_things_service/__init__.py
Christian Monch df83cf8d9a fix: ensure backward compatible policy declarations
This commit reintroduces the policy configuration keys to
the collection configuration record. This ensures that
existing 6.5 configurations can be read.

If an external policy configuration source is defined for
a collection (via `policy_info_location`), it will be used.
In this case, if the configuration defines a policy inline
(via `policy_annotation_tag`, `default_policy`, and
`policy_mapping`), the latter will be ignored and a
warning will be issued.

If the configuration does not define an external policy
source, but defines a policy inline (via
`policy_annotation_tag`, `default_policy`, and
`policy_mapping`), the inlined policy definition will
be used.
2026-10-06 11:03:12 +02:00

65 lines
1.4 KiB
Python

from enum import Enum
from typing import Any
from starlette.status import (
HTTP_200_OK,
HTTP_201_CREATED,
HTTP_300_MULTIPLE_CHOICES,
HTTP_400_BAD_REQUEST,
HTTP_401_UNAUTHORIZED,
HTTP_403_FORBIDDEN,
HTTP_404_NOT_FOUND,
HTTP_406_NOT_ACCEPTABLE,
HTTP_409_CONFLICT,
HTTP_413_CONTENT_TOO_LARGE,
HTTP_422_UNPROCESSABLE_CONTENT,
HTTP_500_INTERNAL_SERVER_ERROR,
HTTP_503_SERVICE_UNAVAILABLE,
)
from dump_things_service._version import __version__
__all__ = [
'HTTP_200_OK',
'HTTP_201_CREATED',
'HTTP_300_MULTIPLE_CHOICES',
'HTTP_400_BAD_REQUEST',
'HTTP_401_UNAUTHORIZED',
'HTTP_403_FORBIDDEN',
'HTTP_404_NOT_FOUND',
'HTTP_406_NOT_ACCEPTABLE',
'HTTP_409_CONFLICT',
'HTTP_413_CONTENT_TOO_LARGE',
'HTTP_422_UNPROCESSABLE_CONTENT',
'HTTP_500_INTERNAL_SERVER_ERROR',
'HTTP_503_SERVICE_UNAVAILABLE',
'JSON',
'YAML',
'Format',
'__version__',
'config_file_name',
'dump_things_private_collection_name',
'reserved_collection_names',
]
class Format(str, Enum):
json = 'json'
ttl = 'ttl'
JSON = dict[str, Any] | list[Any] | str | int | float | None
YAML = JSON
config_file_name = '.dumpthings.yaml'
dump_things_private_collection_name = '__dump_things__'
reserved_collection_names = (
'collections',
'tokens',
'admin_tokens',
'api',
'v1',
dump_things_private_collection_name,
)