Exemplo n.º 1
0
def create_location(event, context):

    user = event['requestContext']['authorizer']['principalId']

    location = Location.from_dict(json.loads(event["body"]))

    value, retcode = location_controller.create_location(
        location, user,
        location_controller.authorizer(event['requestContext']['authorizer']))

    value.location_id = str(value.location_id)

    return create_response(event, retcode, value)
Exemplo n.º 2
0
def delete_location(event, context):

    user = event['requestContext']['authorizer']['principalId']

    if 'pathParameters' in event:
        location_id = event["pathParameters"]["location_id"]

    location = Location.from_dict(json.loads(event["body"]))

    value, retcode = location_controller.delete_location(
        location_id, user,
        location_controller.authorizer(event['requestContext']['authorizer']))

    return create_response(event, retcode, value)
Exemplo n.º 3
0
def change_wrist(body):
    """
    Set wrist location

    :param body: Location object
    :type body: dict | bytes

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

    location = body.location

    AX12.wrist(location)

    return Location(location)
def add_location(location):  # noqa: E501
    """Add a new user location to the system

    Add a new location of the user # noqa: E501

    :param location:
    :type location: dict | bytes

    :rtype: str
    """
    if connexion.request.is_json:
        location = Location.from_dict(
            connexion.request.get_json())  # noqa: E501
    db = PostgresDB()
    error = db.insert_new_location(location.location)
    if error:
        return jsonify(msg=error)
    return jsonify(msg='Human detected at %s' % location.location)