Coverage for gws-app/gws/plugin/qfieldcloud/api.py: 100%
201 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Data classes for the QFieldCloud API, based on its ``swagger.yaml``."""
3from datetime import datetime
4from typing import Any, Optional
6import gws
8class JobStatusEnum(gws.Enum):
9 """Status of a job."""
11 pending = 'pending'
12 queued = 'queued'
13 started = 'started'
14 finished = 'finished'
15 stopped = 'stopped'
16 failed = 'failed'
19class LastStatusEnum(gws.Enum):
20 """Last status of a delta."""
22 pending = 'pending'
23 started = 'started'
24 applied = 'applied'
25 conflict = 'conflict'
26 not_applied = 'not_applied'
27 error = 'error'
28 ignored = 'ignored'
29 unpermitted = 'unpermitted'
32class OrganizationMemberRoleEnum(gws.Enum):
33 """Role of an organization member."""
35 admin = 'admin'
36 member = 'member'
39class ProjectCollaboratorRoleEnum(gws.Enum):
40 """Role of a project collaborator."""
42 admin = 'admin'
43 manager = 'manager'
44 editor = 'editor'
45 reporter = 'reporter'
46 reader = 'reader'
49class ProjectStatusEnum(gws.Enum):
50 """Status of a project."""
52 ok = 'ok'
53 busy = 'busy'
54 failed = 'failed'
57class TypeEnum(gws.Enum):
58 """Type of a job."""
60 package = 'package'
61 delta_apply = 'delta_apply'
62 process_projectfile = 'process_projectfile'
65# Data Classes
68class Login(gws.Data):
69 """Login credentials."""
71 password: str
72 """Password."""
73 username: Optional[str]
74 """User name."""
75 email: Optional[str]
76 """Email address."""
79class CompleteUser(gws.Data):
80 """Full information about the authenticated user."""
82 username: str
83 """User name."""
84 type: int
85 """User type, see ``UserType``."""
86 full_name: str
87 """Full name."""
88 avatar_url: str
89 """URL of the avatar image."""
90 email: Optional[str]
91 """Email address."""
92 first_name: Optional[str]
93 """First name."""
94 last_name: Optional[str]
95 """Last name."""
98class PublicInfoUser(gws.Data):
99 """Public information about a user."""
101 username: str
102 """User name."""
103 type: int
104 """User type, see ``UserType``."""
105 full_name: str
106 """Full name."""
107 avatar_url: str
108 """URL of the avatar image."""
109 username_display: str
110 """User name for display."""
113class Delta(gws.Data):
114 """A single change sent by QField."""
116 deltafile_id: str
117 """Id of the delta payload the delta belongs to."""
118 content: Any
119 """Delta content as sent by QField."""
120 id: str
121 """Delta id."""
122 created_by: str
123 """User who sent the delta."""
124 created_at: datetime
125 """Creation time."""
126 updated_at: datetime
127 """Last update time."""
128 status: str
129 """Delta status."""
130 output: str
131 """Output of the delta application."""
132 last_status: Optional[LastStatusEnum]
133 """Last status."""
134 last_feedback: Optional[Any]
135 """Last feedback."""
138class Job(gws.Data):
139 """A server job, e.g. packaging."""
141 type: TypeEnum
142 """Job type."""
143 id: str
144 """Job id."""
145 created_at: datetime
146 """Creation time."""
147 created_by: int
148 """Id of the user who created the job."""
149 project_id: str
150 """Project id."""
151 status: JobStatusEnum
152 """Job status."""
153 updated_at: datetime
154 """Last update time."""
155 started_at: Optional[datetime]
156 """Start time."""
157 finished_at: Optional[datetime]
158 """Finish time."""
161class Organization(gws.Data):
162 """An organization."""
164 username: str
165 """Organization name."""
166 type: int
167 """User type, see ``UserType``."""
168 avatar_url: str
169 """URL of the avatar image."""
170 members: str
171 """Organization members."""
172 organization_owner: str
173 """Owner of the organization."""
174 membership_role: str
175 """Role of the current user in the organization."""
176 membership_role_origin: str
177 """Origin of the membership role."""
178 membership_is_public: bool
179 """Whether the membership is public."""
180 teams: list[str]
181 """Organization teams."""
182 email: Optional[str]
183 """Email address."""
186class OrganizationMember(gws.Data):
187 """A member of an organization."""
189 organization: str
190 """Organization name."""
191 member: str
192 """Member user name."""
193 role: OrganizationMemberRoleEnum
194 """Member role."""
195 is_public: Optional[bool]
196 """Whether the membership is public."""
199class Project(gws.Data):
200 """A QField Cloud project."""
202 id: str
203 """Project id."""
204 name: str
205 """Project name."""
206 owner: str
207 """Project owner."""
208 created_at: datetime
209 """Creation time."""
210 updated_at: datetime
211 """Last update time."""
212 can_repackage: bool
213 """Whether the project can be packaged again."""
214 needs_repackaging: bool
215 """Whether the project must be packaged again."""
216 status: ProjectStatusEnum
217 """Project status."""
218 user_role: str
219 """Role of the current user in the project."""
220 user_role_origin: str
221 """Origin of the user role."""
222 is_shared_datasets_project: bool
223 """Whether this is a shared datasets project."""
224 is_attachment_download_on_demand: bool
225 """Whether attachments are downloaded on demand."""
226 description: Optional[str]
227 """Project description."""
228 private: Optional[bool]
229 """Whether the project is private."""
230 is_public: Optional[bool]
231 """Whether the project is public."""
232 data_last_packaged_at: Optional[datetime]
233 """Time of the last packaging."""
234 data_last_updated_at: Optional[datetime]
235 """Time of the last data update."""
236 shared_datasets_project_id: Optional[str]
237 """Id of the shared datasets project."""
238 is_featured: Optional[bool]
239 """Whether the project is featured."""
242class ProjectCollaborator(gws.Data):
243 """A collaborator of a project."""
245 collaborator: str
246 """Collaborator user name."""
247 project_id: str
248 """Project id."""
249 created_by: str
250 """User who added the collaborator."""
251 updated_by: str
252 """User who last updated the collaborator."""
253 created_at: datetime
254 """Creation time."""
255 updated_at: datetime
256 """Last update time."""
257 role: Optional[ProjectCollaboratorRoleEnum]
258 """Collaborator role."""
261class Team(gws.Data):
262 """A team in an organization."""
264 team: str
265 """Team name."""
266 organization: str
267 """Organization name."""
268 members: list[str]
269 """Team members."""
272class TeamMember(gws.Data):
273 """A member of a team."""
275 member: str
276 """Member user name."""
279## not in swagger.yaml but used in code
282class Package(gws.Data):
283 """A project package, as listed for download."""
285 files: list[dict]
286 """Package files."""
287 layers: list[dict]
288 """Package layers."""
289 status: JobStatusEnum
290 """Packaging status."""
291 package_id: str
292 """Package id."""
293 packaged_at: datetime
294 """Packaging time."""
295 data_last_updated_at: datetime
296 """Time of the last data update."""
299class AuthProvider(gws.Data):
300 """An authentication provider offered to the client."""
302 type: str
303 """Provider type."""
304 id: str
305 """Provider id."""
306 name: str
307 """Provider name for display."""
310class UserType(gws.Enum):
311 """Type of a user account."""
313 person = 1
314 organization = 2
315 team = 3
318class AuthToken(gws.Data):
319 """Authentication token and user information returned on login."""
321 token: str
322 """Session token."""
323 expires_at: datetime
324 """Expiration time."""
325 username: str
326 """User name."""
327 type: UserType
328 """User type."""
329 full_name: str
330 """Full name."""
331 avatar_url: str
332 """URL of the avatar image."""
333 email: Optional[str]
334 """Email address."""
335 first_name: Optional[str]
336 """First name."""
337 last_name: Optional[str]
338 """Last name."""
341class ServerInfo(gws.Data):
342 """Server information."""
344 version: str
345 """Server version."""
346 auth_providers: list[AuthProvider]
347 """Available authentication providers."""
348 signup_url: str
349 """URL of the signup page."""
350 whitelabel: dict
351 """Branding options."""
354class Status(gws.Data):
355 """Server status."""
357 version: str
358 """Server version."""
359 database: str
360 """Database status."""
361 storage: str
362 """Storage status."""
363 status_page_url: Optional[str]
364 """URL of the status page."""
365 incident_message: Optional[str]
366 """Incident message."""
367 incident_timestamp_utc: Optional[str]
368 """Incident time."""
369 maintenance_message: Optional[str]
370 """Maintenance message."""
371 maintenance_start_timestamp_utc: Optional[str]
372 """Maintenance start time."""
373 maintenance_end_timestamp_utc: Optional[str]
374 """Maintenance end time."""
377class Subscription(gws.Data):
378 """Subscription of a user."""
380 plan_display_name: str
381 """Plan name for display."""
382 active_storage_total_bytes: int
383 """Total storage available, in bytes."""
384 storage_used_bytes: int
385 """Storage used, in bytes."""
386 plan_storage_threshold_warning_bytes: int
387 """Storage warning threshold, in bytes."""
388 plan_storage_threshold_critical_bytes: int
389 """Storage critical threshold, in bytes."""
390 status: str
391 """Subscription status."""
394class PostJobPayload(gws.Data):
395 """Payload of a job creation request."""
397 type: TypeEnum
398 """Job type."""
399 project_id: str
400 """Project id."""
403class DeltasPayload(gws.Data):
404 """A delta payload (delta file) sent by QField."""
406 deltas: list[dict]
407 """List of deltas."""
408 files: list[dict]
409 """List of files."""
410 id: str
411 """Payload id."""
412 project: str
413 """Project id."""
414 version: str
415 """Delta file format version."""
418class StoredDelta(gws.Data):
419 """A delta as stored on the server and returned to status requests."""
421 id: str
422 """Delta id (the ``uuid`` of the delta)."""
423 deltafile_id: str
424 """Id of the delta payload."""
425 created_by: str
426 """Login name of the user who sent the delta."""
427 created_at: str
428 """Creation time."""
429 updated_at: str
430 """Last update time."""
431 status: str
432 """Delta status, e.g. ``STATUS_PENDING`` or ``STATUS_APPLIED``."""
433 client_id: str
434 """Client id."""
435 output: Optional[dict]
436 """Output of the delta application."""
437 last_status: str
438 """Last status, e.g. ``pending`` or ``applied``."""
439 last_feedback: Optional[dict]
440 """Last feedback."""
441 content: dict
442 """Delta content as sent by QField."""
445class PackageFile(gws.Data):
446 """A file in a package."""
448 name: str
449 """File name, relative to the package."""
450 size: int
451 """File size in bytes."""
452 uploaded_at: str
453 """Upload time."""
454 is_attachment: bool
455 """Whether the file is an attachment."""
456 md5sum: str
457 """MD5 checksum, in the format QField expects."""
458 last_modified: str
459 """Modification time."""
460 sha256: str
461 """SHA-256 checksum."""