示例#1
0
def update_pet(body, id, name, category, photo_urls, tags, status):  # noqa: E501
    """Update an existing pet

    Update an existing pet by Id # noqa: E501

    :param body: Update an existent pet in the store
    :type body: dict | bytes
    :param id: 
    :type id: int
    :param name: 
    :type name: str
    :param category: 
    :type category: dict | bytes
    :param photo_urls: 
    :type photo_urls: List[str]
    :param tags: 
    :type tags: list | bytes
    :param status: 
    :type status: str

    :rtype: Pet
    """
    if connexion.request.is_json:
        body = Pet.from_dict(connexion.request.get_json())  # noqa: E501
    if connexion.request.is_json:
        category = .from_dict(connexion.request.get_json())  # noqa: E501
    if connexion.request.is_json:
        tags = [Tag.from_dict(d) for d in connexion.request.get_json()]  # noqa: E501
    return 'do some magic!'
示例#2
0
def add_pet(body):
    """
    Add a new pet to the store
    
    :param body: Pet object that needs to be added to the store
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Pet.from_dict(connexion.request.get_json())
    return 'do some magic!'
示例#3
0
def update_pet(body):  # noqa: E501
    """Update an existing pet

     # noqa: E501

    :param body: Pet object that needs to be added to the store
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Pet.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
def update_pet(body):  # noqa: E501
    """Update an existing pet

     # noqa: E501

    :param body: Pet object that needs to be added to the store
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Pet.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
示例#5
0
def add_pet(body):  # noqa: E501
    """Add another kitten, doggy, or fluffball to your store

     # noqa: E501

    :param body: Pet object that needs to be added to the store
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Pet.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
示例#6
0
def add_pet(body):  # noqa: E501
    """Add a new pet to the store

     # noqa: E501

    :param body: Pet object that needs to be added to the store
    :type body: dict | bytes

    :rtype: None
    """
    body = connexion.request.form
    for k, v in body.items():
        print("{}:{}".format(k, v))
    conn = engine.connect()
    Session = sessionmaker(bind=engine)
    Session.configure(bind=engine)
    session = Session()
    pet = Pets(name=body['name'], status=body['status'])

    tags = body['tags']
    print("Tags type is {}".format(type(tags)))

    if type(tags) != list:

        tags_list = tags.split(',')
        print(tags_list)
        tag1 = tags_list[0]
        tag2 = tags_list[1]
        newtag1 = tag1.strip('"[] ')
        newtag1_1 = newtag1.strip("'")
        newtag2 = tag2.strip('"[] ')
        newtag2_1 = newtag2.strip("'")
        print(newtag1)
        print(newtag2)

    #tags_list = re.split(r"\W+", tags)
    #tags = [ tags_list[i] for i in range(len(tags_list)) if tags_list[i]]
    #print(tags)

    #   pet.Tags = [Tags(tag1 = tags[0]), Tags(tag2 = tags[x1])]

    photoUrls = body['photoUrls']
    print("PhotoURL type is {}".format(type(photoUrls)))
    if type(photoUrls) != list:
        photoslist = photoUrls.split(',')
        photo1 = photoslist[0]
        photo2 = photoslist[1]
        newphoto1 = photo1.strip('"[] ')
        newphoto1_1 = newphoto1.strip("'")
        newphoto2 = photo2.strip('"[] ')
        newphoto2_1 = newphoto2.strip("'")
    #photo_list = re.split(r"\W+", photoUrls)
    #photos = [ photo_list[i] for i in range(len(photo_list)) if photo_list[i]]
    #print(photos)

    pet.Tags = [Tags(tag1=newtag1_1, tag2=newtag2_1)]
    pet.Photos = [Photos(photo1=newphoto1_1, photo2=newphoto2_1)]

    session.add(pet)
    session.commit()

    if connexion.request.is_json:
        body = Pet.from_dict(connexion.request.get_json())  # noqa: E501
    return json.dumps(body)