SDK e CLI ufficiali di QFieldCloud
qfieldcloud-sdk
è il client ufficiale per connettersi all' API di QFieldCloud sia come modulo Python che direttamente tramite linea di comando.
Note
qfieldcloud-sdk
richiede Python >=3.6
Installazione¶
pip install qfieldcloud-sdk
Uso del modulo¶
import requests
from qfieldcloud_sdk import sdk
client = sdk.Client(
url="https://app.qfield.cloud/api/v1/",
username="user1",
password="pass1",
)
try:
projects = client.list_projects()
except requests.exceptions.RequestException:
print("Oops!")
Uso della CLI¶
Il tool CLI ufficiale di QFieldCloud
Uso¶
qfieldcloud-cli [OPTIONS] COMMAND [ARGS]...
Esempi¶
# logs in user "user" with password "pass"
qfieldcloud-cli login user pass
# gets the projects of user "user" with password "pass" at "https://localhost/api/v1/"
qfieldcloud-cli -u user -p pass -U https://localhost/api/v1/ list-projects
# gets the projects of user authenticated with token `QFIELDCLOUD_TOKEN` at "https://localhost/api/v1/" as JSON
export QFIELDCLOUD_URL=https://localhost/api/v1/
export QFIELDCLOUD_TOKEN=017478ee2464440cb8d3e98080df5e5a
qfieldcloud-cli --json list-projects
Filtri¶
Alcuni comandi permettono di definire un filtro sui risultati basato sul nome del file con l'opzione --filter
(es. il comando download-files
).
I filtri supportano wildcard in stile Unix shell. I caratteri speciali usati nelle wildcard in stile Unix shell sono:
Pattern | Significato |
---|---|
* | corrisponde a qualsiasi cosa |
? | corrisponde a un singolo carattere |
[seq] | Corrisponde a qualsiasi carattere di seq |
[!seq] | Corrisponde a qualsiasi carattere non presente in seq |
Per una corrispondenza letterale, racchiudi il meta-carattere tra parentesi quadre. Per esempio, '[?]'
corrisponde al carattere '?'
.
Esempi¶
qfieldcloud-cli --filter 'DCIM/*.jpg'
qfieldcloud-cli --filter 'attachments/documentation-??.pdf'
Panoramica delle opzioni globali¶
-U, --url TEXT URL to the QFieldCloud API endpoint. If not
passed, gets the value from QFIELDCLOUD_URL
environment variable. Default:
https://app.qfield.cloud/api/v1/
-u, --username TEXT Username or email.
-p, --password TEXT
-t, --token TEXT Session token.
--json / --human Output the result as newline formatted json. Default: False
--verify-ssl / --no-verify-ssl Verify SSL. Default: True
--help Show this message and exit.
Variabili di ambiente possono essere usate invece di passare alcune delle opzioni globali più comuni.
QFIELDCLOUD_API
- QFieldCloud API endpoint URLQFIELDCLOUD_USERNAME
- QFieldCloud username o email. Richiede cheQFIELDCLOUD_PASSWORD
sia definito.QFIELDCLOUD_PASSWORD
- Password. Richiede cheQFIELDCLOUD_USERNAME
sia definito.QFIELDCLOUD_TOKEN
- Token che può essere usato al posto di passare username e password. Può essere ottenuto eseguendoqfieldcloud-cli login
.QFIELDCLOUD_VERIFY_SSL
- Se impostato a0
ha lo stesso effetto di passare--no-verify-ssl
.
Panoramica dei comandi¶
login Login to QFieldCloud.
logout Logout and expire the token.
list-projects List QFieldCloud projects.
list-files List QFieldCloud project files.
create-project Creates a new empty QFieldCloud project.
delete-project Deletes a QFieldCloud project.
upload-files Upload files to a QFieldCloud project.
download-files Download QFieldCloud project files.
delete-files Delete QFieldCloud project files.
list-jobs List project jobs.
job-trigger Triggers a new job.
job-status Get job status.
package-latest Check project packaging status.
package-download Download packaged QFieldCloud project files.
login¶
Login in QFieldCloud.
qfieldcloud-cli login [OPTIONS] USERNAME PASSWORD
logout¶
Logout da QFieldCloud.
qfieldcloud-cli logout
list-projects¶
Elenca i progetti QFieldCloud.
qfieldcloud-cli list-projects [OPTIONS]
Options:
--include-public / --no-public Includes the public project in the list. Default: False
list-files¶
Elenca i file del progetto QFieldCloud.
qfieldcloud-cli list-files [OPTIONS] PROJECT_ID
create-project¶
Crea un nuovo progetto QFieldCloud vuoto
qfieldcloud-cli create-project [OPTIONS] NAME
Options:
--owner TEXT Owner of the project. If omitted, the current
user is the owner.
--description TEXT Description of the project.
--is-public / --is-private Mark the project as public.
delete-project¶
Cancella un progetto QFieldCloud.
qfieldcloud-cli delete-project [OPTIONS] PROJECT_ID
upload-files¶
Carica file in un progetto QFieldCloud.
qfieldcloud-cli upload-files [OPTIONS] PROJECT_ID PROJECT_PATH
Options:
--filter TEXT Do not upload the whole project, but only
the files which match the glob.
--throw-on-error / --no-throw-on-error
If any project file upload fails stop
uploading the rest. Default: False
download-files¶
Scarica i file del progetto QFieldCloud.
qfieldcloud-cli download-files [OPTIONS] PROJECT_ID LOCAL_DIR
Options:
--filter TEXT Do not download the whole project, but only
the files which match the glob.
--throw-on-error / --no-throw-on-error
If any project file downloads fails stop
downloading the rest. Default: False
--force-download/--no-force-download
 Download file even if it already exists locally.
Default: False
delete-files¶
Cancella file di un progetto QFieldCloud.
qfieldcloud-cli delete-files [OPTIONS] PROJECT_ID PATHS...
Options:
--throw-on-error / --no-throw-on-error
If any project file delete operations fails
stop, stop deleting the rest. Default: False
job-list¶
Elenca i lavori del progetto.
qfieldcloud-cli list-jobs [OPTIONS] PROJECT_ID
Options:
--type JOBTYPES Job type. One of package, delta_apply or
process_projectfile.
job-trigger¶
Avvia un lavoro.
qfieldcloud-cli job-trigger [OPTIONS] PROJECT_ID JOB_TYPE
Options:
--force / --no-force Should force creating a new job. Default: False
job-status¶
Ottieni lo stato del lavoro.
qfieldcloud-cli job-status [OPTIONS] JOB_ID
package-latest¶
Verifica lo stato del packaging del progetto.
qfieldcloud-cli package-latest [OPTIONS] PROJECT_ID
package-download¶
Scarica il pacchetto con i file del progetto QFieldCloud.
qfieldcloud-cli package-download [OPTIONS] PROJECT_ID LOCAL_DIR
Options:
--filter TEXT Do not download the whole packaged project,
but only the files which match the glob.
--throw-on-error / --no-throw-on-error
If any packaged file downloads fails stop
downloading the rest. Default: False
--force-download/--no-force-download
 Download file even if it already exists locally.
Default: False