Coverage for apps/integrations/schemas.py: 100%

57 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-11-04 17:24 +0000

1"""Ninja schemas for the integrations admin API. Secrets are write-only: inputs accept a 

2``secret`` but outputs only report ``has_secret`` (design D2).""" 

3 

4from __future__ import annotations 

5 

6from ninja import Schema 

7 

8 

9class CatalogEntryOut(Schema): 

10 code: str 

11 category: str 

12 scope: str 

13 label: str 

14 

15 

16class OrgIntegrationOut(Schema): 

17 id: int 

18 org_unit_id: int 

19 provider: str 

20 enabled: bool 

21 config: dict 

22 has_secret: bool 

23 

24 

25class OrgIntegrationIn(Schema): 

26 org_unit_id: int 

27 provider: str 

28 enabled: bool = False 

29 config: dict | None = None 

30 secret: str | None = None 

31 

32 

33class UserCredentialOut(Schema): 

34 id: int 

35 user_id: int 

36 provider: str 

37 config: dict 

38 has_secret: bool 

39 

40 

41class UserCredentialIn(Schema): 

42 provider: str 

43 config: dict | None = None 

44 secret: str | None = None 

45 

46 

47class LenderOut(Schema): 

48 id: int 

49 org_unit_id: int 

50 name: str 

51 pricing_ind: bool 

52 registration_ind: bool 

53 doc_submission_ind: bool 

54 auto_sync_ind: bool 

55 authorization_ind: bool 

56 is_active: bool 

57 

58 

59class LenderCreate(Schema): 

60 org_unit_id: int 

61 name: str 

62 pricing_ind: bool = False 

63 registration_ind: bool = False 

64 doc_submission_ind: bool = False 

65 auto_sync_ind: bool = False 

66 authorization_ind: bool = False 

67 is_active: bool = True 

68 

69 

70class LenderPatch(Schema): 

71 name: str | None = None 

72 pricing_ind: bool | None = None 

73 registration_ind: bool | None = None 

74 doc_submission_ind: bool | None = None 

75 auto_sync_ind: bool | None = None 

76 authorization_ind: bool | None = None 

77 is_active: bool | None = None