Coverage for api_client/models.py: 100.00%

157 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2026-11-30 14:44 +0000

1""" 

2Auto-generated Pydantic models from OpenAPI schema. 

3 

4MANUAL OVERRIDE (2025-10-29): DivisionCreate and DivisionUpdate models 

5have been manually updated to support league_id. These will be regenerated 

6from OpenAPI schema after Phase 2 backend API updates. 

7 

8DO NOT EDIT THIS FILE MANUALLY (except for temporary overrides). 

9Regenerate with: uv run python scripts/generate_api_models.py 

10""" 

11 

12# generated by datamodel-codegen: 

13# filename: openapi.json 

14# timestamp: 2025-10-06T14:50:01+00:00 

15 

16from __future__ import annotations 

17 

18from pydantic import BaseModel, Field 

19 

20 

21class AgeGroupCreate(BaseModel): 

22 name: str = Field(..., title="Name") 

23 

24 

25class AgeGroupUpdate(BaseModel): 

26 name: str = Field(..., title="Name") 

27 

28 

29class DivisionCreate(BaseModel): 

30 name: str = Field(..., title="Name") 

31 description: str | None = Field(None, title="Description") 

32 league_id: int = Field(..., title="League Id") # MANUAL: Added for league layer support 

33 

34 

35class DivisionUpdate(BaseModel): 

36 name: str | None = Field(None, title="Name") 

37 description: str | None = Field(None, title="Description") 

38 league_id: int | None = Field(None, title="League Id") # MANUAL: Added for league layer support 

39 

40 

41class EnhancedGame(BaseModel): 

42 match_date: str = Field(..., title="Match Date") # MANUAL: Fixed - backend expects match_date not game_date 

43 home_team_id: int = Field(..., title="Home Team Id") 

44 away_team_id: int = Field(..., title="Away Team Id") 

45 home_score: int = Field(..., title="Home Score") 

46 away_score: int = Field(..., title="Away Score") 

47 season_id: int = Field(..., title="Season Id") 

48 age_group_id: int = Field(..., title="Age Group Id") 

49 match_type_id: int = Field( 

50 ..., title="Match Type Id" 

51 ) # MANUAL: Fixed - backend expects match_type_id not game_type_id 

52 division_id: int | None = Field(None, title="Division Id") 

53 status: str | None = Field("scheduled", title="Status") 

54 created_by: str | None = Field(None, title="Created By") 

55 updated_by: str | None = Field(None, title="Updated By") 

56 source: str = Field("manual", title="Source") 

57 

58 

59class GamePatch(BaseModel): 

60 """ 

61 Model for partial game updates. 

62 """ 

63 

64 home_score: int | None = Field(None, title="Home Score") 

65 away_score: int | None = Field(None, title="Away Score") 

66 match_status: str | None = Field(None, title="Match Status") 

67 game_date: str | None = Field(None, title="Game Date") 

68 home_team_id: int | None = Field(None, title="Home Team Id") 

69 away_team_id: int | None = Field(None, title="Away Team Id") 

70 season_id: int | None = Field(None, title="Season Id") 

71 age_group_id: int | None = Field(None, title="Age Group Id") 

72 game_type_id: int | None = Field(None, title="Game Type Id") 

73 division_id: int | None = Field(None, title="Division Id") 

74 status: str | None = Field(None, title="Status") 

75 

76 

77class RefreshTokenRequest(BaseModel): 

78 refresh_token: str = Field(..., title="Refresh Token") 

79 

80 

81class RoleUpdate(BaseModel): 

82 user_id: str = Field(..., title="User Id") 

83 role: str = Field(..., title="Role") 

84 team_id: int | None = Field(None, title="Team Id") 

85 

86 

87class SeasonCreate(BaseModel): 

88 name: str = Field(..., title="Name") 

89 start_date: str = Field(..., title="Start Date") 

90 end_date: str = Field(..., title="End Date") 

91 

92 

93class SeasonUpdate(BaseModel): 

94 name: str = Field(..., title="Name") 

95 start_date: str = Field(..., title="Start Date") 

96 end_date: str = Field(..., title="End Date") 

97 

98 

99class Team(BaseModel): 

100 name: str = Field(..., title="Name") 

101 city: str = Field(..., title="City") 

102 age_group_ids: list[int] = Field(..., title="Age Group Ids") 

103 division_id: int = Field(..., title="Division Id") # MANUAL: Fixed - backend expects singular division_id 

104 club_id: int | None = Field(None, title="Club Id") 

105 academy_team: bool | None = Field(False, title="Academy Team") 

106 

107 

108# MANUAL: Tournament request models (mirrors app.py TournamentCreate / TournamentMatchCreate). 

109# Kept in sync with backend until OpenAPI schema regeneration covers tournament routes. 

110class TournamentCreate(BaseModel): 

111 name: str = Field(..., title="Name") 

112 start_date: str = Field(..., title="Start Date") 

113 end_date: str | None = Field(None, title="End Date") 

114 location: str | None = Field(None, title="Location") 

115 description: str | None = Field(None, title="Description") 

116 age_group_ids: list[int] = Field(default_factory=list, title="Age Group Ids") 

117 is_active: bool = Field(True, title="Is Active") 

118 

119 

120class TournamentMatchCreate(BaseModel): 

121 """New tournament fixture (mirrors app.py TournamentMatchCreate). 

122 

123 Name each side directly: per side give exactly one of `*_team_id` (an 

124 existing team) or `*_team_name` (created if unknown). A tournament often has 

125 no "our team" at all, so there is no tracked-team side (SB-819). 

126 

127 `our_team_id` / `opponent_*` / `is_home` are the deprecated pre-SB-819 form, 

128 still accepted by the backend. 

129 """ 

130 

131 match_date: str = Field(..., title="Match Date") 

132 age_group_id: int = Field(..., title="Age Group Id") 

133 season_id: int = Field(..., title="Season Id") 

134 home_team_id: int | None = Field(None, title="Home Team Id") 

135 home_team_name: str | None = Field(None, title="Home Team Name") 

136 away_team_id: int | None = Field(None, title="Away Team Id") 

137 away_team_name: str | None = Field(None, title="Away Team Name") 

138 our_team_id: int | None = Field(None, title="Our Team Id") 

139 opponent_team_id: int | None = Field(None, title="Opponent Team Id") 

140 opponent_name: str | None = Field(None, title="Opponent Name") 

141 is_home: bool = Field(True, title="Is Home") 

142 home_score: int | None = Field(None, title="Home Score") 

143 away_score: int | None = Field(None, title="Away Score") 

144 home_penalty_score: int | None = Field(None, title="Home Penalty Score") 

145 away_penalty_score: int | None = Field(None, title="Away Penalty Score") 

146 match_status: str = Field("scheduled", title="Match Status") 

147 tournament_group: str | None = Field(None, title="Tournament Group") 

148 tournament_round: str | None = Field(None, title="Tournament Round") 

149 tournament_round_order: int | None = Field(None, title="Tournament Round Order") 

150 scheduled_kickoff: str | None = Field(None, title="Scheduled Kickoff") 

151 

152 

153class TournamentMatchUpdate(BaseModel): 

154 """Partial update for an existing tournament match (mirrors app.py TournamentMatchUpdate). 

155 

156 All fields optional — send only what changes. Used to fill in scores/status as 

157 results trickle in. Serialize with model_dump(exclude_none=True) so unset fields 

158 are left untouched by the backend. 

159 """ 

160 

161 home_score: int | None = Field(None, title="Home Score") 

162 away_score: int | None = Field(None, title="Away Score") 

163 home_penalty_score: int | None = Field(None, title="Home Penalty Score") 

164 away_penalty_score: int | None = Field(None, title="Away Penalty Score") 

165 match_status: str | None = Field(None, title="Match Status") 

166 tournament_group: str | None = Field(None, title="Tournament Group") 

167 tournament_round: str | None = Field(None, title="Tournament Round") 

168 tournament_round_order: int | None = Field(None, title="Tournament Round Order") 

169 scheduled_kickoff: str | None = Field(None, title="Scheduled Kickoff") 

170 match_date: str | None = Field(None, title="Match Date") 

171 swap_home_away: bool = Field(False, title="Swap Home Away") 

172 home_team_id: int | None = Field(None, title="Home Team Id") 

173 away_team_id: int | None = Field(None, title="Away Team Id") 

174 

175 

176class TeamGameTypeMapping(BaseModel): 

177 game_type_id: int = Field(..., title="Game Type Id") 

178 age_group_id: int = Field(..., title="Age Group Id") 

179 

180 

181class TeamMappingCreate(BaseModel): 

182 team_id: int = Field(..., title="Team Id") 

183 age_group_id: int = Field(..., title="Age Group Id") 

184 division_id: int = Field(..., title="Division Id") 

185 

186 

187class TeamUpdate(BaseModel): 

188 name: str = Field(..., title="Name") 

189 city: str = Field(..., title="City") 

190 academy_team: bool | None = Field(False, title="Academy Team") 

191 

192 

193class UserLogin(BaseModel): 

194 email: str = Field(..., title="Email") 

195 password: str = Field(..., title="Password") 

196 

197 

198class UserProfile(BaseModel): 

199 display_name: str | None = Field(None, title="Display Name") 

200 role: str | None = Field(None, title="Role") 

201 team_id: int | None = Field(None, title="Team Id") 

202 player_number: int | None = Field(None, title="Player Number") 

203 positions: list[str] | None = Field(None, title="Positions") 

204 

205 

206class UserSignup(BaseModel): 

207 email: str = Field(..., title="Email") 

208 password: str = Field(..., title="Password") 

209 display_name: str | None = Field(None, title="Display Name") 

210 

211 

212class ValidationError(BaseModel): 

213 loc: list[str | int] = Field(..., title="Location") 

214 msg: str = Field(..., title="Message") 

215 type: str = Field(..., title="Error Type") 

216 

217 

218class HTTPValidationError(BaseModel): 

219 detail: list[ValidationError] | None = Field(None, title="Detail") 

220 

221 

222# Re-exports from backend/models/ (single source of truth) 

223# These allow api_client consumers to import models without knowing the internal layout. 

224 

225from models.auth import ( # noqa: F401 

226 AdminPlayerTeamAssignment, 

227 AdminPlayerUpdate, 

228 PlayerCustomization, 

229 PlayerHistoryCreate, 

230 PlayerHistoryUpdate, 

231 ProfilePhotoSlot, 

232 UserProfileUpdate, 

233) 

234from models.lineup import LineupSave # noqa: F401 

235from models.live_match import GoalEvent, LiveMatchClock, MessageEvent # noqa: F401 

236from models.matches import MatchSubmissionData # noqa: F401 

237from models.playoffs import AdvanceWinnerRequest, GenerateBracketRequest # noqa: F401 

238from models.roster import ( # noqa: F401 

239 BulkRenumberRequest, 

240 BulkRosterCreate, 

241 BulkRosterPlayer, 

242 JerseyNumberUpdate, 

243 RenumberEntry, 

244 RosterPlayerCreate, 

245 RosterPlayerUpdate, 

246) 

247 

248 

249# Invite request models — plain duplicates to avoid EmailStr dependency in client context 

250class InviteRequestCreate(BaseModel): 

251 """Create an invite request (public endpoint).""" 

252 

253 email: str = Field(..., description="Email address of the requester") 

254 name: str = Field(..., min_length=1, max_length=255, description="Name of the requester") 

255 team: str | None = Field(None, max_length=255, description="Team or club affiliation") 

256 reason: str | None = Field(None, description="Reason for wanting to join") 

257 wants_ios_beta: bool = Field(False, description="Requester wants the iPhone beta") 

258 website: str | None = Field(None, description="Honeypot field - should be empty") 

259 

260 

261class InviteRequestStatusUpdate(BaseModel): 

262 """Update invite request status (admin only). Approve by creating the invitation.""" 

263 

264 status: str = Field(..., pattern="^(pending|rejected|existing_user)$") 

265 admin_notes: str | None = Field(None, description="Admin notes about the decision") 

266 

267 

268# Channel access request models 

269class ChannelAccessRequestCreate(BaseModel): 

270 """Create or update a channel access request (logged-in users).""" 

271 

272 telegram: bool = False 

273 discord: bool = False 

274 telegram_handle: str | None = None 

275 discord_handle: str | None = None 

276 

277 

278class ChannelAccessStatusUpdate(BaseModel): 

279 """Update per-platform status on a channel access request (admin only).""" 

280 

281 platform: str = Field(..., pattern="^(telegram|discord)$") 

282 status: str = Field(..., pattern="^(approved|denied)$") 

283 admin_notes: str | None = None