class Tags(JsonMappedModel): __mapping__ = {"id": Attr('tag_id', int), "name": Attr('tag_name', str)} def __init__(self, tag_id, tag_name, **attrs): super().__init__(**attrs) self.tag_id = tag_id self.tag_name = tag_name
class Category(BaseApiClass): __mapping__ = { "id": Attr("id", int), "name": Attr("name", str), } def __init__(self, category_id: int = None, category_name: str = None): self.id = category_id self.name = category_name
class Category(JsonMappedModel): __mapping__ = { 'id': Attr('categ_id', int), "name": Attr('categ_name', str) } def __init__(self, categ_id, categ_name, **attrs): super().__init__(**attrs) self.categ_id = categ_id self.categ_name = categ_name
class Customer(BaseApiClass): __mapping__ = { "id": Attr("id", int), "username": Attr("user_name", str), "address": Attr("address", Address) } def __init__(self, customer_id: int = None, user_name: str = None, address: Address = None): self.id = customer_id self.user_name = user_name self.address = address
class User(BaseApiClass): __mapping__ = { "id": Attr("id", int), "name": Attr("user_name", str), "firstName": Attr("first_name", str), "lastName": Attr("last_name", str), "email": Attr("email", str), "password": Attr("password", str), "phone": Attr("phone", str), "userStatus": Attr("user_status", UserStatus), } def __init__(self, user_id: int = None, user_name: str = None, first_name: str = None, last_name: str = None, email: str = None, password: str = None, phone: str = None, user_status: UserStatus = None): self.id = user_id self.user_name = user_name self.first_name = first_name self.last_name = last_name self.email = email self.password = password self.phone = phone self.user_status = user_status
class Address(BaseApiClass): __mapping__ = { "street": Attr("street", str), "city": Attr("city", str), "state": Attr("state", str), "zip": Attr("zip", str), } def __init__(self, street: str = None, city: str = None, state: str = None, zip_code: str = None): self.street = street self.city = city self.state = state self.zip = zip_code
class Parameter(JsonMappedModel): __mapping__ = { 'Name': Attr('name', str), 'Type': Attr('type', str), 'Value': Attr('_value', str), 'KeyId': Attr('key_id', str), 'Overwrite': Attr('overwrite', bool), } def __init__(self, type=None, name=None, value=None, key_id=None): self.type = type self.name = name self._value = value self.key_id = key_id self.overwrite = True @property def value(self): try: return json.loads(self._value) except ValueError: return self._value
class Pet(JsonModel): __mapping__ = { 'id': Attr('pet_id', int), 'category': Attr('category', Category), 'name': Attr('pet_name', str), 'status': Attr('status', str), 'tags': Attr('tags', [Tags]), 'photoUrls': Attr('photo_url', [PhotoUrls]) } def __init__(self, pet_id, categ_id, categ_name, pet_name, photo_url, tag_id, tag_name, status, **attrs): super().__init__(**attrs) self.pet_id = pet_id self.pet_name = pet_name self.status = status # self.photo_url = [PhotoUrls(photo_url)] self.tags = [Tags(tag_id, tag_name)] self.category = Category(categ_id, categ_name)
class Pet(BaseApiClass): __mapping__ = { "id": Attr("id", int), "name": Attr("name", str), "category": Attr("category", Category), "photoUrls": Attr("photo_urls", [str]), "tags": Attr("tags", [Tag]), "status": Attr("status", PetStatus), } def __init__(self, pet_id: int = None, name: str = None, category: Category = None, photo_urls: [] = None, tags: [Tag] = None, status: PetStatus = None): self.id = pet_id self.name = name self.category = category self.photo_urls = photo_urls self.tags = tags self.status = status
class Order(BaseApiClass): __mapping__ = { "id": Attr("id", int), "petId": Attr("pet_id", int), "quantity": Attr("quantity", int), "shipDate": Attr("ship_date", str), "status": Attr("status", OrderStatus), "complete": Attr("complete", bool), } def __init__(self, order_id: int = None, pet_id: int = None, quantity: int = None, ship_date: str = None, status: OrderStatus = None, complete: bool = None): self.id = order_id self.pet_id = pet_id self.quantity = quantity self.ship_date = ship_date self.status = status self.complete = complete
class ParamsResponse(JsonMappedModel): __mapping__ = { 'Parameters': Attr('parameters', [Parameter]), 'ResponseMetadata': Attr('metadata', Metadata), 'NextToken': Attr('next_token', str), }
class EnumMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', TestEnum), 'other': Attr('other', OtherEnum), }
class Metadata(JsonMappedModel): __mapping__ = { 'HTTPStatusCode': Attr('status_code', int), 'RequestId': Attr('request_id', str), }
class TestMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', CustomType), }
class TestExtendedModel(TestMappedModel): __mapping__ = {'second': Attr('second', str)}
class TestMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', int, coerce=False), }
class PhotoUrls(JsonMappedModel): __mapping__ = {"photoUrls": Attr('photo_url', str)} def __init__(self, photo_url, **attrs): super().__init__(**attrs) self.photo_url = photo_url
class TestListChildMapping(JsonMappedModel): __mapping__ = {'children': Attr('children', [TestMappedModel])}
class TestDifferentAttrNaming(TestMappedModel): __mapping__ = {'my-thing': Attr('my_thing', str)}
class IntMappedModel(JsonMappedModel): __mapping__ = {'test': Attr('test', int, coerce=True)}
class FlexMapping(JsonMappedModel): __mapping__ = {'test': Attr('test', attr_type)}
class IntMappedModel(JsonMappedModel): __mapping__ = {'test': Attr('test', dict)}
class TestMappedModel(JsonMappedModel): __mapping__ = { 'nope': Attr('nope', SubMappedModel), }
class SubMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', int), }
class TestRequiredMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', int), 'other': Attr('other', int, required=True), }
class UUIDMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', [uuid.UUID]), }
class Tag(BaseApiClass): __mapping__ = {"id": Attr("id", int), "name": Attr("name", str)} def __init__(self, tag_id: int = None, tag_name: str = None): self.id = tag_id self.name = tag_name
class MixedMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', int), 'another': Attr('another', int, serialize=False) }
class TestMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', str), } test = ''
class StrMappedModel(JsonMappedModel): __mapping__ = { 'test': Attr('test', [str]), }