Exemplo n.º 1
0
def get_horse(id):
    """
    Gets information for a specific horse
    
    :param id: Identifier of the horse
    :type id: str

    :rtype: Horse
    """
    horse = Data.get('horse', id)
    if horse is None:
        return 'Horse Not Found', 404
    else:
        return Horse.from_dict(horse)
Exemplo n.º 2
0
def get_person(id):
    """
    Retrieves a person
    
    :param id: RestrictsIdentifier of the person
    :type id: str

    :rtype: Person
    """
    person = Data.get('person', id)
    if person is None:
        return 'person not found', 404
    else:
        return person
Exemplo n.º 3
0
def get_horse_people(id, type=None):
    """
    Retrieves a list of all people associated with the horse
    
    :param id: Identifier of the horse
    :type id: str
    :param type: restricts the list to specific types of people
    :type type: str

    :rtype: List[Association]
    """
    horse = Data.get('horse', id)
    if horse is None:
        return 'Horse Not Found', 404
    else:
        return Data.get_horse_people(id, type)
Exemplo n.º 4
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