Skip to content

Commit cd0326b

Browse files
authored
Merge pull request #73 from opengisch/suricactus-patch-1
Update examples.md with some Markdown and heading fixes
2 parents ff69751 + a4c52ce commit cd0326b

File tree

1 file changed

+58
-52
lines changed

1 file changed

+58
-52
lines changed

docs/docs/examples.md

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
# Real Use Case: Automating QFieldCloud Project Management
1+
# Automating QFieldCloud Project Management via the SDK
22

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).
45

5-
Here it is typical user story, for **Bash** (Linux/macOS) and **PowerShell** (Windows):
6+
### Install QFieldCloud SDK
67

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:
1010

1111
```shell
1212
pip install qfieldcloud-sdk
1313
```
1414

1515
Once installed, you're ready to manage your projects directly from the command line.
16+
1617
> Note: All values are enclosed in quotes, with single quotes (`'`) recommended for Bash (_but not mandatory_) and double quotes (`"`) for PowerShell.
1718
18-
### **Log in to QFieldCloud and Create a New Project**
19+
### Log in to QFieldCloud
1920

2021
First, log in to your QFieldCloud account.
2122

@@ -49,7 +50,8 @@ The easier approach is to set an environment variable with your token:
4950
$env:QFIELDCLOUD_TOKEN = "123abcXYZ987exampleToken"
5051
```
5152

52-
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.
5355

5456
In this example, we'll use the `jq` tool to parse the JSON response and retrieve the session token.
5557

@@ -79,7 +81,7 @@ This command will output only the session token, which can be stored in an envir
7981
$env:QFIELDCLOUD_TOKEN = (qfieldcloud-cli --json login "ninjamaster" "secret_password123" | jq ".session_token")
8082
```
8183

82-
### **Create a project**
84+
### Create a project
8385

8486
Create a project called `Tree_Survey` within your organization:
8587

@@ -100,7 +102,7 @@ You’re now ready for file uploads.
100102

101103
If you forgot to copy your project ID, you can always check the list of all the projects on QFieldCloud.
102104

103-
#### **List Your Projects**
105+
### List Your Projects
104106

105107
To list all projects associated with your account:
106108

@@ -130,7 +132,7 @@ To include public projects in the list:
130132
qfieldcloud-cli list-projects --include-public
131133
```
132134

133-
### **Upload Local Files to QFieldCloud**
135+
### Upload Local Files to QFieldCloud
134136

135137
Prepare your local project files and upload them to QFieldCloud:
136138

@@ -146,7 +148,8 @@ Prepare your local project files and upload them to QFieldCloud:
146148
qfieldcloud-cli upload-files "123e4567-e89b-12d3-a456-426614174000" "C:\Users\ninjamaster\QField\cloud\Tree_survey"
147149
```
148150

149-
You can also upload specific files by using the `--filter` option. For instance, to upload only `.gpkg` files:
151+
You can also upload specific files by using the `--filter` option.
152+
For instance, to upload only `.gpkg` files:
150153

151154
=== ":material-bash: Bash"
152155

@@ -160,9 +163,9 @@ You can also upload specific files by using the `--filter` option. For instance,
160163
qfieldcloud-cli upload-files "123e4567-e89b-12d3-a456-426614174000" "C:\Users\ninjamaster\QField\cloud\Tree_survey" --filter "*.gpkg"
161164
```
162165

163-
Now you can see your files on QFieldCloud...
166+
Now you can upload and check your files on QFieldCloud.
164167

165-
#### **List Files in a Project**
168+
### List Files in a Project
166169

167170
To view all files in a specific project:
168171

@@ -178,13 +181,13 @@ To view all files in a specific project:
178181
qfieldcloud-cli list-files "123e4567-e89b-12d3-a456-426614174000"
179182
```
180183

181-
### **Manage Members and Collaborators**
184+
### Manage Members and Collaborators
182185

183-
QFieldCloud is a collaborative platform, so you can manage your fieldworks....
186+
The collaborative nature of QFieldCloud naturally involves other people in the fieldwork.
184187

185-
You can add, remove, or change the roles of members on your Organization.
188+
You can add, remove, or change the members on your Organization.
186189

187-
- **Add a Member to an Organization:**
190+
#### Add a Member to an Organization
188191

189192
=== ":material-bash: Bash"
190193

@@ -198,7 +201,7 @@ You can add, remove, or change the roles of members on your Organization.
198201
qfieldcloud-cli members-add "My_Organization_Clan" "ninja007" admin
199202
```
200203

201-
- **Change a Member's Role:**
204+
#### Change a Member's Role
202205

203206
=== ":material-bash: Bash"
204207

@@ -212,7 +215,7 @@ You can add, remove, or change the roles of members on your Organization.
212215
qfieldcloud-cli members-patch "My_Organization_Clan" "ninja007" member
213216
```
214217

215-
- **Remove a Member in an Organization:**
218+
#### Remove a Member in an Organization
216219

217220
=== ":material-bash: Bash"
218221

@@ -228,7 +231,7 @@ You can add, remove, or change the roles of members on your Organization.
228231

229232
You can add, remove, or change the roles of collaborators on your project.
230233

231-
- **Add a Collaborator in a project:**
234+
#### Add a Collaborator in a project
232235

233236
=== ":material-bash: Bash"
234237

@@ -242,7 +245,7 @@ You can add, remove, or change the roles of collaborators on your project.
242245
qfieldcloud-cli collaborators-add "123e4567-e89b-12d3-a456-426614174000" "ninja007" admin
243246
```
244247

245-
- **Change a Collaborator’s Role in a project:**
248+
#### Change a Collaborator’s Role in a project
246249

247250
=== ":material-bash: Bash"
248251

@@ -256,7 +259,7 @@ You can add, remove, or change the roles of collaborators on your project.
256259
qfieldcloud-cli collaborators-patch "123e4567-e89b-12d3-a456-426614174000" "ninja001" editor
257260
```
258261

259-
- **Remove a Collaboratorin a project:**
262+
#### Remove a Collaborator in a project
260263

261264
=== ":material-bash: Bash"
262265

@@ -270,25 +273,9 @@ You can add, remove, or change the roles of collaborators on your project.
270273
qfieldcloud-cli collaborators-remove "123e4567-e89b-12d3-a456-426614174000" "ninja007"
271274
```
272275

273-
### **Schedule and Trigger a Package Job**
274-
275-
Suppose your company packages the project every morning at 8:47 AM.:
276-
277-
=== ":material-bash: Bash"
276+
### Create and monitor jobs
278277

279-
```bash
280-
47 8 * * * qfieldcloud-cli job-trigger '123e4567-e89b-12d3-a456-426614174000' package
281-
```
282-
283-
This triggers the package job daily at the specified time. For more information about [cronjob](https://crontab.guru/).
284-
285-
=== ":material-powershell: PowerShell"
286-
287-
```powershell
288-
schtasks /create /tn "QFieldCloud Job Trigger" /tr "qfieldcloud-cli job-trigger '123e4567-e89b-12d3-a456-426614174000' package" /sc daily /st 08:47
289-
```
290-
291-
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
292279

293280
To manually trigger a package job at any time and force if require:
294281

@@ -304,11 +291,9 @@ To manually trigger a package job at any time and force if require:
304291
qfieldcloud-cli job-trigger "123e4567-e89b-12d3-a456-426614174000" package --force
305292
```
306293

307-
### **Monitor Job Status**
294+
After triggering a job, monitor job's status to ensure successful completion:
308295

309-
After triggering a job, monitor its status to ensure successful completion:
310-
311-
- **List all jobs for a specific project**:
296+
#### List all jobs for a specific project
312297

313298
Before checking the status of a job, you can list all jobs associated with a project by using the `list-jobs` command.
314299

@@ -324,7 +309,7 @@ Before checking the status of a job, you can list all jobs associated with a pro
324309
qfieldcloud-cli list-jobs "123e4567-e89b-12d3-a456-426614174000" --type package
325310
```
326311

327-
- **Check the status of a specific job**:
312+
#### Check the status of a specific job
328313

329314
Once you have the job ID, you can check its status using the `job-status` command:
330315

@@ -340,7 +325,7 @@ Once you have the job ID, you can check its status using the `job-status` comman
340325
qfieldcloud-cli job-status "321e4567-e89b-12d3-a456-426614174987"
341326
```
342327

343-
- **Continuously check job status until completion**:
328+
#### Wait for job completion
344329

345330
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.
346331

@@ -368,7 +353,30 @@ To automate the process of checking a job's status until it is finished, you can
368353
Write-Host "Job finished with status: $JOB_STATUS"
369354
```
370355

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.:
361+
362+
=== ":material-bash: Bash"
363+
364+
```bash
365+
47 8 * * * qfieldcloud-cli job-trigger '123e4567-e89b-12d3-a456-426614174000' package
366+
```
367+
368+
This triggers the package job daily at the specified time. For more information about [cronjob](https://crontab.guru/).
369+
370+
=== ":material-powershell: PowerShell"
371+
372+
```powershell
373+
schtasks /create /tn "QFieldCloud Job Trigger" /tr "qfieldcloud-cli job-trigger '123e4567-e89b-12d3-a456-426614174000' package" /sc daily /st 08:47
374+
```
375+
376+
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
372380

373381
Once the package job is complete, download the project files for backup. To download all files or filter specific ones (e.g., `.jpg` files):
374382

@@ -398,7 +406,7 @@ If files already exist locally and you want to overwrite them, use the `--force-
398406
qfieldcloud-cli package-download "123e4567-e89b-12d3-a456-426614174000" "C:\Users\ninjamaster\backup_folder\DCIM\2024-11-10\" --force-download
399407
```
400408

401-
### **Delete Files to Save Space**
409+
### Delete Files to Save Space
402410

403411
To free up storage on QFieldCloud, you can delete unnecessary files, such as `.jpg` files:
404412

@@ -428,9 +436,7 @@ You can also delete specific files by specifying their exact path:
428436
qfieldcloud-cli delete-files "123e4567-e89b-12d3-a456-426614174000" "DCIM\tree-202411202334943.jpg"
429437
```
430438

431-
### **Delete a Project**
432-
433-
Once you are done with a project, you can delete it...
439+
### Delete a Project
434440

435441
To permanently delete a project (be cautious—this action cannot be undone):
436442

0 commit comments

Comments
 (0)