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
12 changes: 8 additions & 4 deletions mergin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,12 @@ def projects_list(
break
return projects

def project_info(self, project_path, since=None, version=None):
def project_info(self, project_path_or_id, since=None, version=None):
"""
Fetch info about project.

:param project_path: Project's full name (<namespace>/<name>)
:type project_path: String
:param project_path_or_id: Project's full name (<namespace>/<name>) or id
:type project_path_or_id: String
:param since: Version to track history of geodiff files from
:type since: String
:param version: Project version to get details for (particularly list of files)
Expand All @@ -639,7 +639,11 @@ def project_info(self, project_path, since=None, version=None):
# since and version are mutually exclusive
if version:
params = {"version": version}
resp = self.get("/v1/project/{}".format(project_path), params)

if re.match("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", project_path_or_id):
resp = self.get("/v1/project/by_uuid/{}".format(project_path_or_id), params)
else:
resp = self.get("/v1/project/{}".format(project_path_or_id), params)
return json.load(resp)

def project_versions(self, project_path, since=None, to=None):
Expand Down
7 changes: 7 additions & 0 deletions mergin/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ def test_create_remote_project_from_local(mc):
assert project_info["namespace"] == API_USER
assert project_info["id"] == source_mp.project_id()

# check project metadata retrieval by id
project_info = mc.project_info(source_mp.project_id())
assert project_info["version"] == "v1"
assert project_info["name"] == test_project
assert project_info["namespace"] == API_USER
assert project_info["id"] == source_mp.project_id()

versions = mc.project_versions(project)
assert len(versions) == 1
assert versions[0]["name"] == "v1"
Expand Down