Skip to content

Commit c25f003

Browse files
authored
Merge pull request #81 from opengisch/show_project
feat: add show_project method
2 parents 63ce585 + 3558c77 commit c25f003

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

qfieldcloud_sdk/cli.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,24 @@ 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 get_project(ctx: Context, project_id: str) -> None:
232+
"""Get QFieldCloud project data."""
233+
234+
project: Dict[str, Any] = ctx.obj["client"].get_project(project_id)
235+
236+
if ctx.obj["format_json"]:
237+
print_json(project)
238+
else:
239+
if project:
240+
log("Project data:")
241+
log(format_project_table([project]))
242+
else:
243+
log("User does not have access to projects yet.")
244+
245+
228246
@cli.command()
229247
@click.argument("project_id")
230248
@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 get_project(
381+
self,
382+
project_id: str,
383+
) -> Dict[str, Any]:
384+
"""Get project data.
385+
386+
Args:
387+
project_id: the project data to get data for.
388+
389+
Returns:
390+
A dictionary containing project details.
391+
392+
Example:
393+
```python
394+
client.get_project(project_id)
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)