Skip to content

Commit f1e06e7

Browse files
committed
feat: add show_project method
Show data of an individual project.
1 parent 16a6dfb commit f1e06e7

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

qfieldcloud_sdk/cli.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,25 @@ def list_projects(ctx: Context, include_public: bool, **opts) -> None:
225225
log("User does not have any projects yet.")
226226

227227

228+
@cli.command()
229+
@click.argument("project_id")
230+
@click.pass_context
231+
def show_project(ctx: Context, project_id: str) -> None:
232+
"""Show QFieldCloud project data."""
233+
234+
project: Dict[str, Any] = ctx.obj["client"].show_project(project_id)
235+
236+
if ctx.obj["format_json"]:
237+
print_json(project)
238+
else:
239+
log("Listing projects…")
240+
if project:
241+
log("Project data:")
242+
log(format_project_table([project]))
243+
else:
244+
log("User does not have access to projects yet.")
245+
246+
228247
@cli.command()
229248
@click.argument("project_id")
230249
@click.option(

qfieldcloud_sdk/sdk.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,27 @@ def list_projects(
377377
)
378378
return cast(List, payload)
379379

380+
def show_project(
381+
self,
382+
project_id: str,
383+
) -> Dict[str, Any]:
384+
"""Show project data.
385+
386+
Args:
387+
project_id: the project data to list data for
388+
389+
Returns:
390+
A dictionary containing project details.
391+
392+
Example:
393+
```python
394+
client.show_project()
395+
```
396+
"""
397+
payload = self._request_json("GET", f"projects/{project_id}")
398+
399+
return cast(Dict, payload)
400+
380401
def list_remote_files(
381402
self, project_id: str, skip_metadata: bool = True
382403
) -> List[Dict[str, Any]]:

0 commit comments

Comments
 (0)