Coverage for fio_wrapper/models/group_models.py: 100%
184 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-16 11:50 +0100
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-16 11:50 +0100
1from typing import List, Optional
2from datetime import datetime, timedelta
3from pydantic import BaseModel, RootModel, Field, AwareDatetime, NaiveDatetime
6class GroupAdmin(BaseModel):
7 GroupAdminUserName: str
10class GroupUser(BaseModel):
11 GroupUserName: str
14class Group(BaseModel):
15 GroupAdmins: List[GroupAdmin]
16 GroupUsers: List[GroupUser]
17 GroupModelId: int
18 GroupOwner: str
19 GroupName: str
21 def users(self) -> List[str]:
22 return [user.GroupUserName.upper() for user in self.GroupUsers]
25class GroupList(RootModel):
26 root: List[Group]
28 def __iter__(self):
29 """Iterates through all Groups
31 Returns:
32 Group: Group element
33 """
34 return iter(self.root)
36 def ids(self) -> List[int]:
37 """Returns a list of Group IDs from all Groups in the List
39 Returns:
40 List[int]: List of GroupModelId
41 """
42 return [group.GroupModelId for group in self.root]
45class GroupMembership(BaseModel):
46 GroupName: str
47 GroupId: int
50class GroupMembershipList(RootModel):
51 root: List[GroupMembership]
53 def __iter__(self):
54 """Iterates through all group memberships
56 Returns:
57 GroupMembership: Group membership element
58 """
59 return iter(self.root)
61 def ids(self) -> List[int]:
62 """Returns a list of Group IDs from all Group Memberships
64 Returns:
65 List[int]: List of GroupIDs
66 """
67 return [membership.GroupId for membership in self.root]
70class StorageItem(BaseModel):
71 MaterialTicker: Optional[str] = Field(max_length=3)
72 MaterialName: Optional[str]
73 MaterialCategoryName: Optional[str]
74 Units: int
77class PlayerCXWarehouses(BaseModel):
78 PlayerName: str
79 StorageType: str
80 Items: List[StorageItem]
83class CXWarehouse(BaseModel):
84 WarehouseLocationName: str
85 WarehouseLocationNaturalId: str
86 PlayerCXWarehouses: List[PlayerCXWarehouses]
89class RepairMaterial(BaseModel):
90 MaterialTicker: str = Field(max_length=3)
91 Amount: int
94class AddressLine(BaseModel):
95 LineId: str = Field(min_length=32)
96 LineType: str
97 NaturalId: str
98 Name: str
101class AddressLineFlight(BaseModel):
102 LineId: str = Field(min_length=32)
103 Type: str
104 LineNaturalId: str
105 LineName: str
108class ShipFuel(BaseModel):
109 CurrentSF: int
110 MaxSF: int
111 CurrentFF: int
112 MaxFF: int
115class ShipCargo(BaseModel):
116 PlayerName: str
117 StorageType: str
118 Items: List[StorageItem]
119 LastUpdated: NaiveDatetime
122class ShipFlightSegment(BaseModel):
123 OriginLines: List[AddressLineFlight]
124 DestinationLines: List[AddressLineFlight]
126 Type: str
127 DepartureTimeEpochMs: datetime
128 ArrivalTimeEpochMs: datetime
129 StlDistance: Optional[float]
130 StlFuelConsumption: Optional[float]
131 FtlDistance: Optional[float]
132 FtlFuelConsumption: Optional[float]
133 Origin: str
134 Destination: str
137class ShipFlight(BaseModel):
138 Segments: List[ShipFlightSegment]
140 FlightId: str = Field(min_length=32)
141 ShipId: str = Field(min_length=32)
142 Origin: str
143 Destination: str
144 DepartureTimeEpochMs: datetime
145 ArrivalTimeEpochMs: datetime
146 CurrentSegmentIndex: int
147 StlDistance: float
148 FtlDistance: float
149 IsAborted: bool
150 Timestamp: NaiveDatetime
153class PlayerShip(BaseModel):
154 PlayerName: str
155 ShipName: Optional[str]
156 ShipRegistration: str
157 Location: str
158 Destination: Optional[str]
159 LocationETA: Optional[AwareDatetime]
160 LocationETALocalTime: Optional[AwareDatetime]
161 Condition: float
163 RepairMaterials: List[RepairMaterial]
164 AddressLines: List[AddressLine]
166 Flight: Optional[ShipFlight]
167 Fuel: ShipFuel
168 Cargo: ShipCargo
170 LastUpdated: NaiveDatetime
173class Currency(BaseModel):
174 CurrencyName: str
175 Amount: float
176 LastUpdated: NaiveDatetime
179class Material(BaseModel):
180 MaterialTicker: str = Field(max_length=3)
181 MaterialName: str
182 MaterialCategoryName: Optional[str]
183 Units: int
186class ProductionLine(BaseModel):
187 Started: bool
188 Halted: bool
189 Recurring: bool
190 OrderDuration: timedelta
191 TimeCompletion: NaiveDatetime
192 Inputs: List[Material]
193 Outputs: List[Material]
194 LastUpdated: NaiveDatetime
195 BuildingName: str
196 BuildingTicker: str = Field(max_length=3)
197 Capacity: int
198 Efficiency: float
199 Condition: float
202class Building(BaseModel):
203 BuildingName: str
204 BuildingTicker: str = Field(max_length=3)
205 Condition: float
206 RepairMaterials: List[Material]
207 ReclaimableMaterials: List[Material]
208 ProductionLiness: List[ProductionLine]
211class Storage(BaseModel):
212 PlayerName: str
213 StorageType: str
214 Items: List[Material]
215 LastUpdated: NaiveDatetime
218class Location(BaseModel):
219 LocationIdentifier: str
220 LocationName: str
221 Buildings: List[Building]
222 BaseStorage: Storage
223 WarehouseStorage: Storage
224 StationaryPlayerShips: List[PlayerShip]
227class PlayerModel(BaseModel):
228 Username: str
229 Currencies: List[Currency]
230 Locations: List[Location]
233class GroupHub(BaseModel):
234 GroupName: Optional[str]
235 CXWarehouses: List[CXWarehouse]
236 PlayerShipsInFlight: List[PlayerShip]
237 PlayerStationaryShips: List[PlayerShip]
238 Failures: List[str]
241class Inventory(BaseModel):
242 MaterialId: str = Field(min_length=32)
243 MaterialTicker: Optional[str] = Field(max_length=3)
244 MaterialAmount: int
247class Consumption(BaseModel):
248 MaterialId: str = Field(min_length=32)
249 MaterialTicker: str = Field(max_length=3)
250 DailyAmount: float
253class Burn(BaseModel):
254 RequesterUserName: str
255 UserName: str
256 Error: Optional[str]
257 PlanetId: Optional[str] = Field(min_length=32)
258 PlanetName: Optional[str]
259 PlanetNaturalId: Optional[str]
260 PlanetConsumptionTime: Optional[NaiveDatetime]
261 LastUpdate: NaiveDatetime
262 LastUpdateCause: Optional[str]
264 Inventory: List[Inventory]
265 WorkforceConsumption: List[Consumption]
266 OrderConsumption: List[Consumption]
267 OrderProduction: List[Consumption]
270class BurnList(RootModel):
271 root: List[Burn]
273 def __iter__(self):
274 """Iterates through all burn elements
276 Returns:
277 Burn: Burn element
278 """
279 return iter(self.root)