Coverage for src/paperap/const.py: 100%

1"""

2----------------------------------------------------------------------------

3

4 METADATA:

5

6 File: const.py

7 Project: paperap

8 Created: 2025-03-04

9 Version: 0.0.5

10 Author: Jess Mann

11 Email: jess@jmann.me

12 Copyright (c) 2025 Jess Mann

13

14----------------------------------------------------------------------------

15

16 LAST MODIFIED:

17

18 2025-03-04 By Jess Mann

19

20"""

21

22 from __future__ import annotations

23

24 from enum import StrEnum

25 from string import Template

26 from typing import TypedDict

27

28 from yarl import URL

29

30

31 class URLS:

32 index: Template = Template("/api/")

33 token: Template = Template("/api/token/")

34 list: Template = Template("/api/${resource}/")

35 detail: Template = Template("/api/${resource}/${pk}/")

36 create: Template = Template("/api/${resource}/")

37 update: Template = Template("/api/${resource}/${pk}/")

38 delete: Template = Template("/api/${resource}/${pk}/")

39

40

41 class Endpoints(TypedDict, total=False):

42 list: Template

43 detail: Template

44 create: Template

45 update: Template

46 delete: Template

47

48

49 class FilteringStrategies(StrEnum):

50 WHITELIST = "whitelist"

51 BLACKLIST = "blacklist"

52 ALLOW_ALL = "allow_all"

53 ALLOW_NONE = "allow_none"

54

55

56 class ModelStatus(StrEnum):

57 INITIALIZING = "initializing"

58 UPDATING = "updating"

59 SAVING = "saving"

60 READY = "ready"

61 ERROR = "error"

62

63

64# API endpoint paths

65 API_PATH: dict[str, str] = {

66 # Document endpoints

67 "documents": "/api/documents/",

68 "documents_download": "/api/documents/${pk}/download/",

69 "documents_meta": "/api/documents/${pk}/metadata/",

70 "documents_next_asn": "/api/documents/next_asn/",

71 "documents_notes": "/api/documents/${pk}/notes/",

72 "documents_preview": "/api/documents/${pk}/preview/",

73 "documents_thumbnail": "/api/documents/${pk}/thumb/",

74 "documents_post": "/api/documents/post_document/",

75 "documents_single": "/api/documents/${pk}/",

76 "documents_suggestions": "/api/documents/${pk}/suggestions/",

77}