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:
parent
9e54b26a34
commit
96e26dc650
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
========================
|
||||
|
||||
|
|
Loading…
Reference in New Issue