Skip to content

Commit

Permalink
Add task destroy command
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg committed Sep 22, 2021
1 parent a47473e commit 68d1955
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES/376.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the ability to delete tasks.
14 changes: 5 additions & 9 deletions pulpcore/cli/common/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pulpcore/cli/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pulpcore/cli/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 68d1955

Please sign in to comment.