gws.plugin.qfieldcloud.action_handler¶
QField Cloud API request handler.
Source code: gws.plugin.qfieldcloud.action_handler
Module Contents¶
- class gws.plugin.qfieldcloud.action_handler.Handler(action: gws.plugin.qfieldcloud.action_base.BaseAction)¶
Handler for a single QFieldCloud API request.
Finds the route for the request, authenticates the user and calls the route method. The handler holds the state of the request only, persistent data is accessed via
action.- action: gws.plugin.qfieldcloud.action_base.BaseAction¶
The action that received the request.
- auth: Handler.auth¶
user, session and token.
- Type:
Authentication result
- params: gws.Request¶
Command request.
- parts: dict¶
Variables from the path.
- post: dict¶
POST payload.
- project: gws.Project | None¶
GWS Project context.
- qfcProject: gws.plugin.qfieldcloud.core.QfcProject¶
QField Cloud Project context.
- qs: dict¶
Query string parameters.
- req: gws.WebRequester¶
The original web request.
- create_package_job() gws.Job¶
Create and schedule a packaging job for the QField project of the request.
- Returns:
The scheduled job.
- delta_db() gws.lib.sqlitex.Object¶
Return the delta database of the request’s QField project.
- Returns:
Database wrapper.
- handle(req: gws.WebRequester, params: gws.Request) gws.ContentResponse¶
Find the route method for a request and call it.
The path can start with
projectUid/<uid>to set the GWS project. If the action belongs to a project, that project is used instead.- Parameters:
req – Web requester.
params – Command request.
- Returns:
The response.
- Raises:
gws.NotFoundError – If the path is empty, the GWS project is not found or no route matches.
gws.ForbiddenError – If the user cannot use the GWS project.
- on_get_auth_providers() list[gws.plugin.qfieldcloud.api.AuthProvider]¶
Return the authentication providers.
- Returns:
A single username and password provider.
- on_get_auth_user() gws.plugin.qfieldcloud.api.CompleteUser¶
Return the authenticated user.
- Returns:
User information.
- on_get_deltas() gws.ContentResponse¶
Return the deltas the user has sent for a QField project, newest first.
The list is paged by the
limitandoffsetquery parameters. If there are more deltas, the response has anX-Next-Pageheader. Theorderingparameter is ignored.- Returns:
Delta statuses as JSON.
- Raises:
gws.NotFoundError – If the QField project is not found.
gws.BadRequestError – If
limitoroffsetis not a number.
- on_get_deltas_in_payload() list[gws.plugin.qfieldcloud.core.DeltaStatus]¶
Return the status of the deltas of a payload.
- Returns:
Delta statuses.
- Raises:
gws.NotFoundError – If the QField project is not found.
gws.NotFoundError – If the payload is not found.
- on_get_files() list[gws.plugin.qfieldcloud.api.PackageFile]¶
Return the files of the latest package.
- Returns:
Package files.
- Raises:
gws.NotFoundError – If the QField project is not found.
- on_get_jobs()¶
List jobs. Not supported.
- Raises:
gws.BadRequestError – Always.
- on_get_jobs_id() gws.plugin.qfieldcloud.api.Job¶
Return a job.
- Returns:
Job.
- Raises:
gws.NotFoundError – If the job is not found.
- on_get_package() gws.plugin.qfieldcloud.api.Package¶
Return the latest package of a QField project.
- Returns:
Package with its files. The package version is ignored.
- Raises:
gws.NotFoundError – If the QField project is not found.
- on_get_package_file() gws.ContentResponse¶
Return a file from the latest package.
- Returns:
File content. A request with a
Rangeheader gets status 416, so that QField downloads the full file.- Raises:
gws.NotFoundError – If the QField project is not found.
gws.NotFoundError – If the file is not in the package.
- on_get_projects() list[gws.plugin.qfieldcloud.api.Project]¶
Return the QField projects the user can use.
- Returns:
Projects, paged by the
limitandoffsetquery parameters.
- on_get_projects_id() gws.plugin.qfieldcloud.api.Project¶
Return a QField project.
- Returns:
Project.
- Raises:
gws.NotFoundError – If the QField project is not found.
- on_get_server_info() gws.plugin.qfieldcloud.api.ServerInfo¶
Return the server information.
- Returns:
Server information.
- on_get_status() gws.plugin.qfieldcloud.api.Status¶
Return the server status.
- Returns:
Server status, always
ok.
- on_get_subscription() gws.plugin.qfieldcloud.api.Subscription¶
Return the subscription of a user.
- Returns:
A dummy active subscription.
- on_get_thumbnail() gws.ContentResponse¶
Return the thumbnail of a QField project.
- Returns:
Thumbnail image.
- Raises:
gws.NotFoundError – If the QField project is not found.
gws.NotFoundError – If the project has no thumbnail.
- on_get_user_organizations() list¶
Return the organizations of a user.
- Returns:
An empty list, organizations are not supported.
- on_post_auth_logout()¶
Log out, deleting the session.
- on_post_auth_token() gws.plugin.qfieldcloud.api.AuthToken¶
Log in with username and password and create a session.
- Returns:
Session token and user information.
- Raises:
gws.AuthenticationError – If the credentials are invalid.
- on_post_deltas()¶
Store a delta payload and apply its changes.
The payload is uploaded as a multipart file. Deltas are identified by their content, so a delta pushed again unchanged, also under another payload id, is not applied again. The deltas that are new, or failed before, or have been pending for longer than
delta.PENDING_TIMEOUT, are applied all together or not at all.- Raises:
gws.NotFoundError – If the QField project is not found.
gws.BadRequestError – If the payload cannot be read.
core.DeltaApplyError – If a delta is still being applied, or the deltas cannot be applied.
- on_post_file() gws.ContentResponse¶
Apply a file upload.
- Returns:
An empty response with status 201.
- Raises:
gws.NotFoundError – If the QField project is not found.
gws.NotFoundError – If no feature refers to the file.
gws.BadRequestError – If the upload cannot be read.
- on_post_jobs() gws.plugin.qfieldcloud.api.Job¶
Create a job. Only
packagejobs are supported.- Returns:
The scheduled job.
- Raises:
gws.NotFoundError – If the QField project is not found.
gws.BadRequestError – If the job type is not supported.
- on_post_projects()¶
Create a project. Not supported.
- Raises:
gws.BadRequestError – Always.
- set_qfc_project(uid: str)¶
Set the QField project of the request.
- Parameters:
uid – QField project uid.
- Raises:
gws.NotFoundError – If the project is not found or the user cannot use it.
- set_qfc_project_from_parts()¶
Set the QField project of the request from the
project_idpath variable.- Raises:
gws.NotFoundError – If the project is not found or the user cannot use it.