Pulls updates for the plugin. This method attempts to pull updates for the plugin by calling the `update` method of the plugin's Python class. It also handles any exceptions that occur during this process. Args: request (Request): The HTTP reque
(self, request, name=None)
| 1327 | url_path="pull", |
| 1328 | ) |
| 1329 | def pull(self, request, name=None): |
| 1330 | """ |
| 1331 | Pulls updates for the plugin. |
| 1332 | |
| 1333 | This method attempts to pull updates for the plugin by calling |
| 1334 | the `update` method of the plugin's Python class. It also handles |
| 1335 | any exceptions that occur during this process. |
| 1336 | |
| 1337 | Args: |
| 1338 | request (Request): The HTTP request object. |
| 1339 | name (str, optional): The name of the plugin. Defaults to None. |
| 1340 | |
| 1341 | Returns: |
| 1342 | Response: HTTP response with the update status of the plugin. |
| 1343 | |
| 1344 | Raises: |
| 1345 | ValidationError: If the update is not implemented or if an |
| 1346 | unexpected exception occurs. |
| 1347 | """ |
| 1348 | logger.info(f"post pull from user {request.user}, name {name}") |
| 1349 | obj: PythonConfig = self.get_object() |
| 1350 | python_obj = obj.python_module.python_class(obj) |
| 1351 | try: |
| 1352 | update_status = python_obj.update() |
| 1353 | except NotImplementedError as e: |
| 1354 | raise ValidationError({"detail": str(e)}) |
| 1355 | except Exception as e: |
| 1356 | logger.exception(e) |
| 1357 | raise ValidationError({"detail": "Unexpected exception raised. Check the code."}) |
| 1358 | else: |
| 1359 | if update_status is None: |
| 1360 | raise ValidationError({"detail": "This Plugin has no Update implemented"}) |
| 1361 | return Response(data={"status": update_status}, status=status.HTTP_200_OK) |
| 1362 | |
| 1363 | |
| 1364 | class PluginConfigViewSet(ModelWithOwnershipViewSet): |
no test coverage detected