Skip to content

Commit 4de9f14

Browse files
authored
Merge pull request #409 from ReaNAiveD/delete-tree-json
Drop tree.json
2 parents 8ff9a3d + 979a92e commit 4de9f14

File tree

8 files changed

+1770
-726
lines changed

8 files changed

+1770
-726
lines changed

src/aaz_dev/command/api/specs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from flask import Blueprint, jsonify, request
2+
23
from utils import exceptions
34
from utils.plane import PlaneEnum
45
from command.controller.specs_manager import AAZSpecsManager
@@ -7,6 +8,17 @@
78
bp = Blueprint('specs', __name__, url_prefix='/AAZ/Specs')
89

910

11+
# modules
12+
@bp.route("/CommandTree/Simple", methods=("GET",))
13+
def simple_command_tree():
14+
manager = AAZSpecsManager()
15+
tree = manager.simple_tree
16+
if not tree:
17+
raise exceptions.ResourceNotFind("Command group not exist")
18+
tree = tree.to_primitive()
19+
return jsonify(tree)
20+
21+
1022
# modules
1123
@bp.route("/CommandTree/Nodes/<names_path:node_names>", methods=("GET",))
1224
def command_tree_node(node_names):
@@ -38,6 +50,23 @@ def command_tree_leaf(node_names, leaf_name):
3850
return jsonify(result)
3951

4052

53+
@bp.route("/CommandTree/Nodes/Leaves", methods=("POST",))
54+
def command_tree_leaves():
55+
data = request.get_json()
56+
result = []
57+
manager = AAZSpecsManager()
58+
59+
for command_names in data:
60+
if command_names[0] != AAZSpecsManager.COMMAND_TREE_ROOT_NAME:
61+
raise exceptions.ResourceNotFind(f"Command not exist: {' '.join(command_names)}")
62+
command_names = command_names[1:]
63+
leaf = manager.find_command(*command_names)
64+
if not leaf:
65+
raise exceptions.ResourceNotFind(f"Command not exist: {' '.join(command_names)}")
66+
result.append(leaf.to_primitive())
67+
return jsonify(result)
68+
69+
4170
@bp.route("/CommandTree/Nodes/<names_path:node_names>/Leaves/<name:leaf_name>/Versions/<base64:version_name>", methods=("GET",))
4271
def aaz_command_in_version(node_names, leaf_name, version_name):
4372
if node_names[0] != AAZSpecsManager.COMMAND_TREE_ROOT_NAME:

0 commit comments

Comments
 (0)