Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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
Exemplo n.º 7
0
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
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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
Exemplo n.º 11
0
class ParamsResponse(JsonMappedModel):
    __mapping__ = {
        'Parameters': Attr('parameters', [Parameter]),
        'ResponseMetadata': Attr('metadata', Metadata),
        'NextToken': Attr('next_token', str),
    }
Exemplo n.º 12
0
 class EnumMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', TestEnum),
         'other': Attr('other', OtherEnum),
     }
Exemplo n.º 13
0
class Metadata(JsonMappedModel):
    __mapping__ = {
        'HTTPStatusCode': Attr('status_code', int),
        'RequestId': Attr('request_id', str),
    }
Exemplo n.º 14
0
 class TestMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', CustomType),
     }
Exemplo n.º 15
0
class TestExtendedModel(TestMappedModel):
    __mapping__ = {'second': Attr('second', str)}
Exemplo n.º 16
0
 class TestMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', int, coerce=False),
     }
Exemplo n.º 17
0
class PhotoUrls(JsonMappedModel):
    __mapping__ = {"photoUrls": Attr('photo_url', str)}

    def __init__(self, photo_url, **attrs):
        super().__init__(**attrs)
        self.photo_url = photo_url
Exemplo n.º 18
0
class TestListChildMapping(JsonMappedModel):
    __mapping__ = {'children': Attr('children', [TestMappedModel])}
Exemplo n.º 19
0
class TestDifferentAttrNaming(TestMappedModel):
    __mapping__ = {'my-thing': Attr('my_thing', str)}
Exemplo n.º 20
0
 class IntMappedModel(JsonMappedModel):
     __mapping__ = {'test': Attr('test', int, coerce=True)}
Exemplo n.º 21
0
 class FlexMapping(JsonMappedModel):
     __mapping__ = {'test': Attr('test', attr_type)}
Exemplo n.º 22
0
 class IntMappedModel(JsonMappedModel):
     __mapping__ = {'test': Attr('test', dict)}
Exemplo n.º 23
0
 class TestMappedModel(JsonMappedModel):
     __mapping__ = {
         'nope': Attr('nope', SubMappedModel),
     }
Exemplo n.º 24
0
 class SubMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', int),
     }
Exemplo n.º 25
0
class TestRequiredMappedModel(JsonMappedModel):
    __mapping__ = {
        'test': Attr('test', int),
        'other': Attr('other', int, required=True),
    }
Exemplo n.º 26
0
 class UUIDMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', [uuid.UUID]),
     }
Exemplo n.º 27
0
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
Exemplo n.º 28
0
 class MixedMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', int),
         'another': Attr('another', int, serialize=False)
     }
Exemplo n.º 29
0
 class TestMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', str),
     }
     test = ''
Exemplo n.º 30
0
 class StrMappedModel(JsonMappedModel):
     __mapping__ = {
         'test': Attr('test', [str]),
     }