Skip to content
Open
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
8 changes: 7 additions & 1 deletion webmate_sdk/packagemgmt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import time
from typing import Mapping, Optional
from typing import List, Mapping, Optional

from ..blobs.client import BlobClient
from ..exceptions import WebmateApiError
Expand All @@ -16,6 +16,7 @@ class PackageMgmtClient:
_CREATE_PACKAGE = UriTemplate("/projects/{projectId}/packages", name="CreatePackage")
_UPDATE_PACKAGE = UriTemplate("/package/packages/{packageId}", name="UpdatePackage")
_GET_PACKAGE = UriTemplate("/package/packages/{packageId}", name="GetPackage")
_GET_PACKAGES_FOR_PROJECT = UriTemplate("/projects/{projectId}/packages/full", name="GetPackagesForProject")
_DELETE_PACKAGE = UriTemplate("/package/packages/{packageId}", name="DeletePackage")

def __init__(self, session: WebmateSession) -> None:
Expand Down Expand Up @@ -49,6 +50,11 @@ def get_package(self, package_id: PackageId | str) -> dict | None:
response = self._client.get(self._GET_PACKAGE, path_params={"packageId": str(package_id)})
return _safe_json(response)

def get_packages_for_project(self, project_id: ProjectId | None = None) -> List[dict]:
project = project_id or self._session.require_project()
response = self._client.get(self._GET_PACKAGES_FOR_PROJECT, path_params={"projectId": str(project)})
return _safe_json(response)

def wait_for_package(self, package_id: PackageId | str, *, timeout_seconds: float = 600.0, poll_interval: float = 3.0) -> dict:
deadline = time.monotonic() + timeout_seconds
last_error: Exception | None = None
Expand Down