Skip to content

feat: add show_project method #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions qfieldcloud_sdk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ def list_projects(ctx: Context, include_public: bool, **opts) -> None:
log("User does not have any projects yet.")


@cli.command()
@click.argument("project_id")
@click.pass_context
def get_project(ctx: Context, project_id: str) -> None:
"""Get QFieldCloud project data."""

project: Dict[str, Any] = ctx.obj["client"].get_project(project_id)

if ctx.obj["format_json"]:
print_json(project)
else:
if project:
log("Project data:")
log(format_project_table([project]))
else:
log("User does not have access to projects yet.")


@cli.command()
@click.argument("project_id")
@click.option(
Expand Down
21 changes: 21 additions & 0 deletions qfieldcloud_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,27 @@ def list_projects(
)
return cast(List, payload)

def get_project(
self,
project_id: str,
) -> Dict[str, Any]:
"""Get project data.

Args:
project_id: the project data to get data for.

Returns:
A dictionary containing project details.

Example:
```python
client.get_project(project_id)
```
"""
payload = self._request_json("GET", f"projects/{project_id}")

return cast(Dict, payload)

def list_remote_files(
self, project_id: str, skip_metadata: bool = True
) -> List[Dict[str, Any]]:
Expand Down