|
8 | 8 | from typing import TYPE_CHECKING |
9 | 9 |
|
10 | 10 | from .. import item as item_module |
11 | | -from ..client.client import AuthenticatedClient |
| 11 | +from ..client.client import AuthenticatedClient, HTTPStatusError |
12 | 12 | from ..item.item import lazy_is_instance |
13 | 13 |
|
14 | 14 | if TYPE_CHECKING: |
@@ -207,4 +207,32 @@ def dto(summary): |
207 | 207 | return self.run_id and SimpleNamespace(get=get, metadata=metadata) |
208 | 208 |
|
209 | 209 | def __repr__(self) -> str: # noqa: D105 |
210 | | - return f"Project(hub://{self.tenant}@{self.name})" |
| 210 | + return f"Project(mode='hub', name='{self.name}', tenant='{self.tenant}')" |
| 211 | + |
| 212 | + @staticmethod |
| 213 | + def delete(tenant: str, name: str): |
| 214 | + """ |
| 215 | + Delete a hub project. |
| 216 | +
|
| 217 | + Parameters |
| 218 | + ---------- |
| 219 | + tenant : Path |
| 220 | + The tenant of the project. |
| 221 | +
|
| 222 | + A tenant is a ``skore hub`` concept that must be configured on the |
| 223 | + ``skore hub`` interface. It represents an isolated entity managing users, |
| 224 | + projects, and resources. It can be a company, organization, or team that |
| 225 | + operates independently within the system. |
| 226 | + name : str |
| 227 | + The name of the project. |
| 228 | + """ |
| 229 | + with AuthenticatedClient(raises=True) as client: |
| 230 | + try: |
| 231 | + client.delete(f"projects/{tenant}/{name}") |
| 232 | + except HTTPStatusError as e: |
| 233 | + if e.response.status_code == 403: |
| 234 | + raise PermissionError( |
| 235 | + f"Failed to delete the project; " |
| 236 | + f"please contact the '{tenant}' owner" |
| 237 | + ) from e |
| 238 | + raise |
0 commit comments