CLI: Port "ara task delete" command from ara 0.x

This provides support for deleting a specific task.

Change-Id: I3c9ea49b025e8d83a3702ddb9252084371fdc6ce
This commit is contained in:
David Moreau Simard 2020-07-21 20:00:12 -04:00
parent 9e54b26a34
commit 96e26dc650
3 changed files with 43 additions and 0 deletions

View File

@ -4,6 +4,7 @@
import logging
import sys
from cliff.command import Command
from cliff.lister import Lister
from cliff.show import ShowOne
@ -159,3 +160,34 @@ class TaskShow(ShowOne):
"handler",
)
return (columns, ([task[column] for column in columns]))
class TaskDelete(Command):
""" Deletes the specified task and associated resources """
log = logging.getLogger(__name__)
def get_parser(self, prog_name):
parser = super(TaskDelete, self).get_parser(prog_name)
parser = global_arguments(parser)
# fmt: off
parser.add_argument(
"task_id",
metavar="<task-id>",
help="Task to delete",
)
# fmt: on
return parser
def take_action(self, args):
client = get_client(
client=args.client,
endpoint=args.server,
timeout=args.timeout,
username=args.username,
password=args.password,
verify=False if args.insecure else True,
)
# TODO: Improve client to be better at handling exceptions
client.delete("/api/v1/tasks/%s" % args.task_id)

View File

@ -216,6 +216,16 @@ Return detailed information about a specific task:
ara task show 9001
ara task delete
---------------
.. note::
This command requires write privileges.
You can read more about read and write permissions :ref:`here <api-security:user management>`.
.. command-output:: ara task delete --help
CLI: ara-manage (django)
========================

View File

@ -46,6 +46,7 @@ ara.cli =
result delete = ara.cli.result:ResultDelete
task list = ara.cli.task:TaskList
task show = ara.cli.task:TaskShow
task delete = ara.cli.task:TaskDelete
[extras]
server=