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

31 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-11 21:37 -0400

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 

22from __future__ import annotations 

23 

24from enum import StrEnum 

25from string import Template 

26from typing import TypedDict 

27 

28from yarl import URL 

29 

30 

31class 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 

41class Endpoints(TypedDict, total=False): 

42 list: Template 

43 detail: Template 

44 create: Template 

45 update: Template 

46 delete: Template 

47 

48 

49class FilteringStrategies(StrEnum): 

50 WHITELIST = "whitelist" 

51 BLACKLIST = "blacklist" 

52 ALLOW_ALL = "allow_all" 

53 ALLOW_NONE = "allow_none" 

54 

55 

56class ModelStatus(StrEnum): 

57 INITIALIZING = "initializing" 

58 UPDATING = "updating" 

59 SAVING = "saving" 

60 READY = "ready" 

61 ERROR = "error" 

62 

63 

64# API endpoint paths 

65API_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}