Source code for q2_sdk.hq.db.country

from argparse import _SubParsersAction
from functools import partial
from typing import List

from q2_sdk.hq.table_row import TableRow

from .db_object import DbObject


[docs] class CountryRow(TableRow): CountryID: int IsoCode: int IsoCodeA2: str IsoCodeA3: str Name: str DialingCode: int CityAreaCodeEditMask: str LocalNumberEditMask: str IsValidForInternationalAddress: bool SmsDialingCode: int PostalCodeRequired: bool ProvinceRequired: bool
[docs] class Country(DbObject): GET_BY_NAME_KEY = "Name" NAME = "Country" REPRESENTATION_ROW_CLASS = CountryRow
[docs] def add_arguments(self, parser: _SubParsersAction): subparser = parser.add_parser("get_countries") subparser.set_defaults(parser="get_countries") subparser.set_defaults(func=partial(self.get, serialize_for_cli=True))
[docs] async def get(self, serialize_for_cli=False) -> List[CountryRow]: response = await self.call_hq("sdk_GetCountries") if serialize_for_cli: response = self.serialize_for_cli(response, ["CountryID", "Name"]) return response