Example #1
0
def get_upload(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    upload_uid = aws_get_path_parameter(event, "upload_uid")
    upload = db_queries.get_upload(connection=conn, organization_id=organization_id, upload_uid=upload_uid)
    if upload is None:
        raise DatabaseReturnedNone(f"Check object id: {upload_uid}")
    return upload.to_dict()
Example #2
0
def get_history(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    history_id = aws_get_path_parameter(event, "history_id")
    history = db_queries.get_history(connection=conn, organization_id=organization_id, history_id=history_id)
    if history is None:
        raise DatabaseReturnedNone(f"Check object id: {history_id}")
    return history.to_dict()
Example #3
0
def get_mapping(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    mapping_id = aws_get_path_parameter(event, "mapping_id")
    mapping = db_queries.get_mapping(connection=conn,
                                     organization_id=organization_id,
                                     mapping_id=mapping_id)
    if mapping is None:
        raise DatabaseReturnedNone(f"Check object id: {mapping_id}")
    return mapping.to_dict()
Example #4
0
def get_connection(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    connection_id = aws_get_path_parameter(event, "connection_id")
    connection = db_queries.get_connection(connection=conn,
                                           organization_id=organization_id,
                                           connection_id=connection_id)
    if connection is None:
        raise DatabaseReturnedNone(f"Check object id: {connection_id}")
    return connection.to_dict()
Example #5
0
def get_download(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    download_id = aws_get_path_parameter(event, "download_id")
    download = db_queries.get_download(connection=conn,
                                       organization_id=organization_id,
                                       download_id=download_id)
    if download is None:
        raise DatabaseReturnedNone(f"Check object id: {download_id}")
    return download.to_dict()
Example #6
0
def get_download_link(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    download_id = aws_get_path_parameter(event, "download_id")
    download = db_queries.get_download(connection=conn,
                                       organization_id=organization_id,
                                       download_id=download_id)
    bucket_name = download._bucket_name
    obj_name = download._obj_name
    if bucket_name is not None:
        link = _generate_download_link(bucket_name, obj_name)
        expiration = DOWNLOAD_LINK_EXPIRATION
    else:
        link = 'No link created'
        expiration = 0
    return {'download_link': link, 'expiration': expiration}
Example #7
0
def create_upload(event, context):
    """Create an Upload record."""
    organization_id = aws_get_path_parameter(event, "organization_id")
    body = json.loads(event['body'])
    upload_obj = Upload(body)
    response = db_queries.create_upload(connection=conn, organization_id=organization_id, upload=upload_obj)
    tup = response[0][0]
    return {tup[0]: tup[1]}
Example #8
0
def get_upload_link(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    # body = json.loads(event['body'])
    # The better way to do this might be to send back a signed URL 
    # to the client and have them upload to S3. 
    # Then have the client make another post to kick off the conversion process.
    key = '/'.join([organization_id, _get_date(), '${filename}'])
    response = _create_presigned_post(UPLOAD_BUCKET_NAME, key)
    return response
Example #9
0
def connections(event, context):
    organization_id = aws_get_path_parameter(event, "organization_id")
    connection_list = db_queries.get_connections(conn, organization_id)
    return [connection.to_dict() for connection in connection_list]