Skip to content

Commit 5a527dd

Browse files
committed
update asset archive
1 parent 0a3a70f commit 5a527dd

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

python/lib/sift_client/_internal/low_level_wrappers/assets.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from typing import Any, cast
44

55
from sift.assets.v1.assets_pb2 import (
6-
DeleteAssetRequest,
6+
ArchiveAssetRequest,
7+
ArchiveAssetResponse,
78
GetAssetRequest,
89
GetAssetResponse,
910
ListAssetsRequest,
@@ -96,6 +97,8 @@ async def update_asset(self, update: AssetUpdate) -> Asset:
9697
updated_grpc_asset = cast("UpdateAssetResponse", response).asset
9798
return Asset._from_proto(updated_grpc_asset)
9899

99-
async def delete_asset(self, asset_id: str, archive_runs: bool = False) -> None:
100-
request = DeleteAssetRequest(asset_id=asset_id, archive_runs=archive_runs)
101-
await self._grpc_client.get_stub(AssetServiceStub).DeleteAsset(request)
100+
async def archive_asset(self, asset_id: str, archive_runs: bool = False) -> list[str] | None:
101+
request = ArchiveAssetRequest(asset_id=asset_id, archive_runs=archive_runs)
102+
response = await self._grpc_client.get_stub(AssetServiceStub).ArchiveAsset(request)
103+
response = cast("ArchiveAssetResponse", response)
104+
return response.archived_runs

python/lib/sift_client/resources/assets.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,17 @@ async def archive(self, asset: str | Asset, *, archive_runs: bool = False) -> As
192192
"""
193193
asset_id = asset._id_or_error if isinstance(asset, Asset) else asset
194194

195-
await self._low_level_client.delete_asset(asset_id, archive_runs=archive_runs)
195+
await self._low_level_client.archive_asset(asset_id, archive_runs=archive_runs)
196196

197197
return await self.get(asset_id=asset_id)
198198

199-
# TODO: unarchive
199+
async def unarchive(self, asset: str | Asset) -> Asset:
200+
"""Unarchive an asset.
201+
202+
Args:
203+
asset: The Asset or asset ID to unarchive.
204+
205+
Returns:
206+
The unarchived Asset.
207+
"""
208+
return await self.update(asset, AssetUpdate(is_archived=False))

0 commit comments

Comments
 (0)