Skip to content

Commit 940905f

Browse files
committed
Adding the support for the status endpoint
1 parent 92dd1dd commit 940905f

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

qfieldcloud_sdk/cli.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,28 @@ def logout(ctx):
177177
log(payload["detail"])
178178

179179

180+
@cli.command()
181+
@click.pass_context
182+
def status(ctx: Context):
183+
"""Check the status of the QFieldCloud server."""
184+
log("Checking server status...")
185+
client: sdk.Client = ctx.obj["client"]
186+
is_json: bool = ctx.obj["format_json"]
187+
188+
status_info = client.check_server_status()
189+
190+
if is_json:
191+
print_json(status_info)
192+
else:
193+
log(click.style("Server Status:", bold=True))
194+
195+
if isinstance(status_info, dict):
196+
for key, value in status_info.items():
197+
log(f" {key.replace('_', ' ').capitalize()}: {value}")
198+
else:
199+
log(str(status_info))
200+
201+
180202
@cli.command()
181203
@paginated
182204
@click.option(

qfieldcloud_sdk/sdk.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,28 @@ def logout(self) -> None:
302302

303303
return resp.json()
304304

305+
def check_server_status(self) -> Dict[str, Any]:
306+
"""Checks the status of the QFieldCloud server.
307+
308+
This endpoint usually provides information of the server health.
309+
310+
Returns:
311+
A dictionary containing the server status information (e.g., {"storage": "ok", ...}).
312+
313+
Example:
314+
```python
315+
client = sdk.Client(url="[https://app.qfield.cloud/api/v1/](https://app.qfield.cloud/api/v1/)")
316+
status = client.check_server_status()
317+
print(f"Server status: {status}")
318+
```
319+
"""
320+
resp = self._request(
321+
"GET",
322+
"status/",
323+
skip_token=True,
324+
)
325+
return resp.json()
326+
305327
def list_projects(
306328
self,
307329
include_public: bool = False,

0 commit comments

Comments
 (0)