Beispiel #1
0
def update_horse(body):
    """
    Updates a horse's data
    
    :param body: Horse to add to barn
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Horse.from_dict(connexion.request.get_json())

    Data.put(body)
def add_person(body=None):
    """
    Adds a new person
    
    :param body: 
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Person.from_dict(connexion.request.get_json())
    Data.put(body)
    return 'Added', 202
def update_person(body=None):
    """
    Updates a person
    
    :param body: 
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Person.from_dict(connexion.request.get_json())

    Data.put(body)
    return 'Ok', 200
Beispiel #4
0
def add_horse_people(id, body):
    """
    Adds a people to the horse
    
    :param id: Identifier of the horse
    :type id: str
    :param body: New association(s) to the horse
    :type body: list | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = [Association.from_dict(d) for d in connexion.request.get_json()]

    for a in body:
        if a.id is None or len(a.id) == 0:
            a.id = str(uuid.uuid4()).replace('-', '')
        a.horse_id = id
        Data.put(a)
Beispiel #5
0
def add_horse(body):
    """
    Adds a new horse to the barn
    
    :param body: Horse object to add to barn
    :type body: dict | bytes

    :rtype: None
    """

    if connexion.request.is_json:
        body = Horse.from_dict(connexion.request.get_json())
    horse = Data.get('horse', body.id)
    if horse is not None:
        return ApiResponse(code=422,
                           type='warning',
                           message='Horse with that id already exists'), 422

    Data.put(body)
    return 'Added', 202