aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/metadata.py
blob: 4fe9e6774eb8e4f336de0c0f9919c6a9ee9d091c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""API for fetching metadata using an API"""
from flask import Blueprint
from flask import jsonify
from flask import current_app

from SPARQLWrapper import SPARQLWrapper

from gn3.db.rdf import get_dataset_metadata


metadata = Blueprint("metadata", __name__)


@metadata.route("/dataset/<accession_id>", methods=["GET"])
def jsonify_dataset_metadata(accession_id):
    """Fetch a dataset's metadata given it's ACCESSION_ID"""
    return jsonify(get_dataset_metadata(
        SPARQLWrapper(current_app
                      .config
                      .get("SPARQL_ENDPOINT")),
        accession_id
    ).data)