from argparse import _SubParsersAction
from functools import partial
from typing import List
from lxml.objectify import BoolElement, IntElement, StringElement
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase
[docs]
class ZoneRow(RepresentationRowBase):
ZoneID: IntElement = "ZoneID"
Description: StringElement = "Description"
IsProduction: BoolElement = "IsProduction"
ZoneHourID: IntElement = "ZoneHourID"
TimeZone: StringElement = "TimeZone"
ShortName: StringElement = "ShortName"
ABA: StringElement = "ABA"
ZonePasswordPolicyBundleID: IntElement = "ZonePasswordPolicyBundleID"
[docs]
class Zone(DbObject):
"Q2_Zone table"
NAME = "Zone"
REPRESENTATION_ROW_CLASS = ZoneRow
[docs]
def add_arguments(self, parser: _SubParsersAction):
subparser = parser.add_parser("get_zones")
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[ZoneRow]:
response = await self.call_hq("sdk_GetZones")
if serialize_for_cli:
columns = ["ZoneID", "Description", "TimeZone", "ShortName", "ABA"]
response = self.serialize_for_cli(response, columns)
return response