(self, request, pk=None)
| 278 | |
| 279 | class RefreshIonTaskView(TaskView): |
| 280 | def post(self, request, pk=None): |
| 281 | serializer = UpdateIonAssets(data=request.data) |
| 282 | serializer.is_valid(raise_exception=True) |
| 283 | |
| 284 | task = self.get_and_check_task(request, pk) |
| 285 | token = serializer.validated_data["token"] |
| 286 | headers = {"Authorization": f"Bearer {token}"} |
| 287 | |
| 288 | is_updated = False |
| 289 | # ion cleanup check |
| 290 | for asset_type in AssetType: |
| 291 | asset_info = get_asset_info(task.id, asset_type) |
| 292 | ion_id = asset_info["id"] |
| 293 | if ion_id is None: |
| 294 | continue |
| 295 | res = requests.get(f"{ION_API_URL}/assets/{ion_id}", headers=headers) |
| 296 | if res.status_code != 200: |
| 297 | del_asset_info(task.id, asset_type) |
| 298 | is_updated = True |
| 299 | |
| 300 | # dead task cleanup |
| 301 | for asset_type in get_processing_assets(task.id): |
| 302 | del_asset_info(task.id, asset_type) |
| 303 | is_updated = True |
| 304 | |
| 305 | return Response({"updated": is_updated}, status=status.HTTP_200_OK) |
| 306 | |
| 307 | |
| 308 | class ClearErrorsTaskView(TaskView): |
nothing calls this directly
no test coverage detected