diff --git a/CHANGES/376.feature b/CHANGES/376.feature new file mode 100644 index 000000000..08e340b00 --- /dev/null +++ b/CHANGES/376.feature @@ -0,0 +1 @@ +Added the ability to delete tasks. diff --git a/pulpcore/cli/common/openapi.py b/pulpcore/cli/common/openapi.py index 4f70ba6a3..ceaaef910 100644 --- a/pulpcore/cli/common/openapi.py +++ b/pulpcore/cli/common/openapi.py @@ -4,7 +4,7 @@ import gettext import json import os -from typing import Any, Callable, Dict, List, Optional, Tuple, cast +from typing import Any, Callable, Dict, List, Optional, Tuple from urllib.parse import urljoin import requests @@ -187,14 +187,10 @@ def render_request( data = body else: raise OpenAPIError("No suitable content type for request specified.") - # "cast" and "ignore", because mypy does not find the annotation for "prepare_request" - return cast( - requests.PreparedRequest, - self._session.prepare_request( # type: ignore - requests.Request( - method, url, params=params, headers=headers, data=data, json=json, files=files - ) - ), + return self._session.prepare_request( + requests.Request( + method, url, params=params, headers=headers, data=data, json=json, files=files + ) ) def parse_response(self, method_spec: Dict[str, Any], response: requests.Response) -> Any: diff --git a/pulpcore/cli/core/context.py b/pulpcore/cli/core/context.py index ad1d76be7..3bcba48cf 100644 --- a/pulpcore/cli/core/context.py +++ b/pulpcore/cli/core/context.py @@ -306,6 +306,7 @@ class PulpTaskContext(PulpEntityContext): HREF = "task_href" LIST_ID = "tasks_list" READ_ID = "tasks_read" + DELETE_ID = "tasks_delete" CANCEL_ID: ClassVar[str] = "tasks_cancel" resource_context: Optional[PulpEntityContext] = None diff --git a/pulpcore/cli/core/task.py b/pulpcore/cli/core/task.py index aa824624a..9200cca12 100644 --- a/pulpcore/cli/core/task.py +++ b/pulpcore/cli/core/task.py @@ -10,7 +10,7 @@ pass_entity_context, pass_pulp_context, ) -from pulpcore.cli.common.generic import href_option, list_command, pulp_option +from pulpcore.cli.common.generic import destroy_command, href_option, list_command, pulp_option from pulpcore.cli.core.context import PulpTaskContext from pulpcore.cli.core.generic import task_filter @@ -43,6 +43,7 @@ def task(ctx: click.Context, pulp_ctx: PulpContext) -> None: task.add_command(list_command(decorators=task_filter)) +task.add_command(destroy_command(decorators=[href_option, uuid_option])) @task.command()