You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/examples.md
+58-52Lines changed: 58 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,22 @@
1
-
# Real Use Case: Automating QFieldCloud Project Management
1
+
# Automating QFieldCloud Project Management via the SDK
2
2
3
-
## CLI Example Usage
3
+
This document presents some of the common tasks solved by using QFieldCloud SDK.
4
+
The examples are prepared for both **Bash** (Linux/macOS) and **PowerShell** (Windows).
4
5
5
-
Here it is typical user story, for **Bash** (Linux/macOS) and **PowerShell** (Windows):
6
+
### Install QFieldCloud SDK
6
7
7
-
### **Install QFieldCloud SDK**
8
-
9
-
To interact with the QFieldCloud API, start by installing the official QFieldCloud SDK. The installation command is the same for both Bash and PowerShell:
8
+
To interact with the QFieldCloud API, start by installing the official QFieldCloud SDK.
9
+
The installation command is the same for both Bash and PowerShell:
10
10
11
11
```shell
12
12
pip install qfieldcloud-sdk
13
13
```
14
14
15
15
Once installed, you're ready to manage your projects directly from the command line.
16
+
16
17
> Note: All values are enclosed in quotes, with single quotes (`'`) recommended for Bash (_but not mandatory_) and double quotes (`"`) for PowerShell.
17
18
18
-
### **Log in to QFieldCloud and Create a New Project**
19
+
### Log in to QFieldCloud
19
20
20
21
First, log in to your QFieldCloud account.
21
22
@@ -49,7 +50,8 @@ The easier approach is to set an environment variable with your token:
You may want to extract the session token directly from the JSON output of the `qfieldcloud-cli` login command. This is especially useful if you're automating tasks or chaining multiple commands.
53
+
You may want to extract the session token directly from the JSON output of the `qfieldcloud-cli` login command.
54
+
This is especially useful if you're automating tasks or chaining multiple commands.
53
55
54
56
In this example, we'll use the `jq` tool to parse the JSON response and retrieve the session token.
55
57
@@ -79,7 +81,7 @@ This command will output only the session token, which can be stored in an envir
This triggers the package job daily at the specified time. For more information about [schtasks](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks).
278
+
#### Trigger job
292
279
293
280
To manually trigger a package job at any time and force if require:
294
281
@@ -304,11 +291,9 @@ To manually trigger a package job at any time and force if require:
-**Continuously check job status until completion**:
328
+
#### Wait for job completion
344
329
345
330
To automate the process of checking a job's status until it is finished, you can use a loop that will keep checking the status until the job either succeeds or fails.
346
331
@@ -368,7 +353,30 @@ To automate the process of checking a job's status until it is finished, you can
368
353
Write-Host "Job finished with status: $JOB_STATUS"
369
354
```
370
355
371
-
### **Download Files for Backup**
356
+
#### Schedule and Trigger a Package Job
357
+
358
+
A more advanced example where the trigger of the job is automated.
359
+
360
+
Suppose your company packages the project every morning at 8:47 AM.:
This triggers the package job daily at the specified time. For more information about [schtasks](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks).
377
+
378
+
379
+
### Download Files for Backup
372
380
373
381
Once the package job is complete, download the project files for backup. To download all files or filter specific ones (e.g., `.jpg` files):
374
382
@@ -398,7 +406,7 @@ If files already exist locally and you want to overwrite them, use the `--force-
0 commit comments