from argparse import _SubParsersAction
from functools import partial
from typing import List
from lxml.objectify import IntElement
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase
[docs]
class GroupToZoneRow(RepresentationRowBase): # pragma: no cover
ZoneID: IntElement = "ZoneID"
GroupID: IntElement = "GroupID"
[docs]
class GroupToZone(DbObject):
"""
More details on :ref:`zones` in the online docs
"""
REPRESENTATION_ROW_CLASS = GroupToZoneRow
[docs]
def add_arguments(self, parser: _SubParsersAction):
subparser = parser.add_parser("get_group_to_zone")
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[GroupToZoneRow]:
response = await self.call_hq("sdk_GetGroupToZone")
if serialize_for_cli:
columns = ["ZoneID", "GroupID"]
response = self.serialize_for_cli(response, columns)
return response