from argparse import _SubParsersAction
from functools import partial
from typing import List
from lxml.objectify import IntElement, StringElement
from q2_sdk.core.dynamic_imports import (
api_ExecuteStoredProcedure as ExecuteStoredProcedure,
)
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase
[docs]
class NavigationRow(RepresentationRowBase):
NavigationID: IntElement = "NavigationID"
DisplayName: StringElement = "DisplayName"
[docs]
class Navigation(DbObject):
REPRESENTATION_ROW_CLASS = NavigationRow
[docs]
def add_arguments(self, parser: _SubParsersAction):
subparser = parser.add_parser("get_navigation_trees")
subparser.set_defaults(parser="get")
subparser.set_defaults(func=partial(self.get, serialize_for_cli=True))
[docs]
async def get(self, serialize_for_cli=False) -> List[NavigationRow]:
response = await self.call_hq(
"sdk_GetNavigation", ExecuteStoredProcedure.SqlParameters([])
)
if serialize_for_cli:
columns = ["NavigationID", "DisplayName"]
response = self.serialize_for_cli(response, columns)
return response