CLI: Port "ara record delete" from 0.x
This provides the ability to delete a specified record. Change-Id: Ib721fede4fb27f7b630830d8de38ce3ae52c8ec7
This commit is contained in:
parent
6c78cf1151
commit
81e3558fe2
@ -5,6 +5,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from cliff.command import Command
|
||||||
from cliff.lister import Lister
|
from cliff.lister import Lister
|
||||||
from cliff.show import ShowOne
|
from cliff.show import ShowOne
|
||||||
|
|
||||||
@ -138,3 +139,34 @@ class RecordShow(ShowOne):
|
|||||||
)
|
)
|
||||||
# fmt: on
|
# fmt: on
|
||||||
return (columns, ([record[column] for column in columns]))
|
return (columns, ([record[column] for column in columns]))
|
||||||
|
|
||||||
|
|
||||||
|
class RecordDelete(Command):
|
||||||
|
""" Deletes the specified record and associated resources """
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(RecordDelete, self).get_parser(prog_name)
|
||||||
|
parser = global_arguments(parser)
|
||||||
|
# fmt: off
|
||||||
|
parser.add_argument(
|
||||||
|
"record_id",
|
||||||
|
metavar="<record-id>",
|
||||||
|
help="Record 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/records/%s" % args.record_id)
|
||||||
|
@ -203,6 +203,11 @@ Examples:
|
|||||||
# Show a specific record and format the results as json
|
# Show a specific record and format the results as json
|
||||||
ara record show 9001 -f json
|
ara record show 9001 -f json
|
||||||
|
|
||||||
|
ara record delete
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
.. command-output:: ara record delete --help
|
||||||
|
|
||||||
ara result list
|
ara result list
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ ara.cli =
|
|||||||
host delete = ara.cli.host:HostDelete
|
host delete = ara.cli.host:HostDelete
|
||||||
record list = ara.cli.record:RecordList
|
record list = ara.cli.record:RecordList
|
||||||
record show = ara.cli.record:RecordShow
|
record show = ara.cli.record:RecordShow
|
||||||
|
record delete = ara.cli.record:RecordDelete
|
||||||
result list = ara.cli.result:ResultList
|
result list = ara.cli.result:ResultList
|
||||||
result show = ara.cli.result:ResultShow
|
result show = ara.cli.result:ResultShow
|
||||||
result delete = ara.cli.result:ResultDelete
|
result delete = ara.cli.result:ResultDelete
|
||||||
|
Loading…
Reference in New Issue
Block a user