Coverage for src/npm_mcp/models.py: 100%

1"""Data models for NPM entities."""

2

3 from typing import List, Optional

4 from pydantic import BaseModel, Field

5

6

7 class ProxyHostLocation(BaseModel):

8 path: str = "/"

9 forward_scheme: str = "http"

10 forward_host: str

11 forward_port: int

12

13

14 class ProxyHost(BaseModel):

15 id: Optional[int] = None

16 created_on: Optional[str] = None

17 modified_on: Optional[str] = None

18 owner_user_id: Optional[int] = None

19 domain_names: List[str]

20 forward_scheme: str = "http"

21 forward_host: str

22 forward_port: int

23 access_list_id: Optional[int] = None

24 certificate_id: Optional[int] = None

25 ssl_forced: bool = False

26 caching_enabled: bool = False

27 block_exploits: bool = True

28 advanced_config: str = ""

29 meta: dict = Field(default_factory=dict)

30 allow_websocket_upgrade: bool = False

31 http2_support: bool = False

32 hsts_enabled: bool = False

33 hsts_subdomains: bool = False

34 enabled: bool = True

35 locations: List[ProxyHostLocation] = Field(default_factory=list)

36

37

38 class Certificate(BaseModel):

39 id: Optional[int] = None

40 created_on: Optional[str] = None

41 modified_on: Optional[str] = None

42 provider: str = "letsencrypt"

43 nice_name: str

44 domain_names: List[str]

45 expires_on: Optional[str] = None

46 meta: dict = Field(default_factory=dict)

47

48

49 class AccessList(BaseModel):

50 id: Optional[int] = None

51 created_on: Optional[str] = None

52 modified_on: Optional[str] = None

53 name: str

54 satisfy_any: bool = False

55 pass_auth: bool = True

56 meta: dict = Field(default_factory=dict)

57 items: List[dict] = Field(default_factory=list)

58

59

60 class RedirectionHost(BaseModel):

61 id: Optional[int] = None

62 created_on: Optional[str] = None

63 modified_on: Optional[str] = None

64 owner_user_id: Optional[int] = None

65 domain_names: List[str]

66 forward_scheme: str = "auto"

67 forward_http_code: int = 302

68 forward_domain_name: str

69 preserve_path: bool = False

70 certificate_id: Optional[int] = None

71 ssl_forced: bool = False

72 hsts_enabled: bool = False

73 hsts_subdomains: bool = False

74 http2_support: bool = False

75 block_exploits: bool = True

76 advanced_config: str = ""

77 meta: dict = Field(default_factory=dict)

78 enabled: bool = True

79

80

81 class Stream(BaseModel):

82 id: Optional[int] = None

83 created_on: Optional[str] = None

84 modified_on: Optional[str] = None

85 owner_user_id: Optional[int] = None

86 incoming_port: int

87 forwarding_host: str

88 forwarding_port: int

89 tcp_forwarding: bool = True

90 udp_forwarding: bool = False

91 certificate_id: Optional[int] = None

92 meta: dict = Field(default_factory=dict)

93 enabled: bool = True

94

95

96 class DeadHost(BaseModel):

97 id: Optional[int] = None

98 created_on: Optional[str] = None

99 modified_on: Optional[str] = None

100 owner_user_id: Optional[int] = None

101 domain_names: List[str]

102 certificate_id: Optional[int] = None

103 ssl_forced: bool = False

104 hsts_enabled: bool = False

105 hsts_subdomains: bool = False

106 http2_support: bool = False

107 advanced_config: str = ""

108 meta: dict = Field(default_factory=dict)

109 enabled: bool = True

110

111

112 class User(BaseModel):

113 id: Optional[int] = None

114 created_on: Optional[str] = None

115 modified_on: Optional[str] = None

116 name: str

117 nickname: str = ""

118 email: str

119 avatar: str = ""

120 roles: List[str] = Field(default_factory=list)

121 is_disabled: bool = False

122

123

124 class Setting(BaseModel):

125 id: Optional[str] = None

126 name: Optional[str] = None

127 description: Optional[str] = None

128 value: str = ""

129 meta: dict = Field(default_factory=dict)

130

131

132 class AuditLogEntry(BaseModel):

133 id: Optional[int] = None

134 created_on: Optional[str] = None

135 modified_on: Optional[str] = None

136 user_id: Optional[int] = None

137 object_type: Optional[str] = None

138 object_id: Optional[int] = None

139 action: Optional[str] = None

140 meta: dict = Field(default_factory=dict)

141

142

143 class NPMToken(BaseModel):

144 token: str

145 expires: str

146

147

148 class NPMConfig(BaseModel):

149 url: str

150 email: str

151 password: str