Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions qfieldcloud_sdk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,28 @@ def logout(ctx):
log(payload["detail"])


@cli.command()
@click.pass_context
def status(ctx: Context):
"""Check the status of the QFieldCloud server."""
log("Checking server status...")
client: sdk.Client = ctx.obj["client"]
is_json: bool = ctx.obj["format_json"]

status_info = client.check_server_status()

if is_json:
print_json(status_info)
else:
log(click.style("Server Status:", bold=True))

if isinstance(status_info, dict):
for key, value in status_info.items():
log(f" {key.replace('_', ' ').capitalize()}: {value}")
else:
log(str(status_info))


@cli.command()
@paginated
@click.option(
Expand Down
22 changes: 22 additions & 0 deletions qfieldcloud_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,28 @@ def logout(self) -> None:

return resp.json()

def check_server_status(self) -> Dict[str, Any]:
"""Checks the status of the QFieldCloud server.

This endpoint usually provides information of the server health.

Returns:
A dictionary containing the server status information (e.g., {"storage": "ok", ...}).

Example:
```python
client = sdk.Client(url="[https://app.qfield.cloud/api/v1/](https://app.qfield.cloud/api/v1/)")
status = client.check_server_status()
print(f"Server status: {status}")
```
"""
resp = self._request(
"GET",
"status/",
skip_token=True,
)
return resp.json()

def list_projects(
self,
include_public: bool = False,
Expand Down