예제 #1
0
def get_project_dictionary(program=None, project=None):
    """
    Return links to the project level JSON schema definitions.

    Summary:
        Get the dictionary schema for entities of a project

    Tags:
        dictionary

    Args:
        program (str): |program_id|
        project (str): |project_id|

    Responses:
        200 (schema_links): Success
        403: Unauthorized request.
    """
    if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
        auth.validate_request(aud={"openid"}, purpose=None)
    keys = list(dictionary.schema.keys()) + ["_all"]
    links = [
        flask.url_for(
            ".get_project_dictionary_entry",
            program=program,
            project=project,
            entry=entry,
        )
        for entry in keys
    ]
    return flask.jsonify({"links": links})
예제 #2
0
def get_project_dictionary_entry(program, project, entry):
    """
    Get the dictionary entry for a specific project. (See
    :func:`get_dictionary_entry`.)
    """
    if flask.current_app.config.get('AUTH_SUBMISSION_LIST', True) is True:
        auth.validate_request(aud={'openid'}, purpose=None)
    return get_dictionary_entry(entry)
예제 #3
0
def get_projects(program):
    """
    Return the available resources at the top level of program ``program``,
    i.e. registered projects.

    Summary:
        Get the projects

    Tags:
        project

    Responses:
        200 (schema_links): Success
        403: Unauthorized request.
        404: Program not found.

    Args:
        program (str): |program_id|

    :reqheader Content-Type: |reqheader_Content-Type|
    :reqheader Accept: |reqheader_Accept|
    :reqheader X-Auth-Token: |reqheader_X-Auth-Token|
    :resheader Content-Type: |resheader_Content-Type|

    **Example**

    .. code-block:: http

           GET /v0/submission/CGCI/ HTTP/1.1
           Host: example.com
           Content-Type: application/json
           X-Auth-Token: MIIDKgYJKoZIhvcNAQcC...
           Accept: application/json

    .. code-block:: JavaScript

        {
            "links": [
                "/v0/sumission/CGCI/BLGSP"
            ]
        }
    """
    if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
        auth.validate_request(aud={"openid"}, purpose=None)
    with flask.current_app.db.session_scope():
        matching_programs = flask.current_app.db.nodes(
            models.Program).props(name=program)
        if not matching_programs.count():
            raise NotFoundError("program {} is not registered".format(program))
        projects = (flask.current_app.db.nodes(
            models.Project.code).path("programs").props(name=program).all())
    links = [
        flask.url_for(".create_entities", program=program, project=p[0])
        for p in projects
    ]
    return flask.jsonify({"links": links})
예제 #4
0
def get_project_dictionary(program=None, project=None):
    """
    Return links to the project level JSON schema definitions. (See
    :func:`get_dicionary`.)
    """
    if flask.current_app.config.get('AUTH_SUBMISSION_LIST', True) is True:
        auth.validate_request(aud={'openid'}, purpose=None)
    keys = dictionary.schema.keys() + ['_all']
    links = [
        flask.url_for('.get_project_dictionary_entry',
                      program=program,
                      project=project,
                      entry=entry) for entry in keys
    ]
    return flask.jsonify({'links': links})
예제 #5
0
def get_programs():
    """
    Return the available resources at the top level above programs i.e.
    registered programs.

    Summary:
        Get the programs

    Tags:
        program

    Responses:
        200 (schema_links): Success
        403: Unauthorized request.

    :reqheader Content-Type: |reqheader_Content-Type|
    :reqheader Accept: |reqheader_Accept|
    :reqheader X-Auth-Token: |reqheader_X-Auth-Token|
    :resheader Content-Type: |resheader_Content-Type|

    **Example**

    .. code-block:: http

           GET /v0/submission/ HTTP/1.1
           Host: example.com
           Content-Type: application/json
           X-Auth-Token: MIIDKgYJKoZIhvcNAQcC...
           Accept: application/json

    .. code-block:: JavaScript

        {
            "links": [
                "/v0/sumission/CGCI/",
                "/v0/sumission/TARGET/",
                "/v0/sumission/TCGA/"
            ]
        }
    """
    if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
        auth.validate_request(aud={"openid"}, purpose=None)
    with flask.current_app.db.session_scope():
        programs = current_app.db.nodes(models.Program.name).all()
    links = [flask.url_for(".get_projects", program=p[0]) for p in programs]
    return flask.jsonify({"links": links})
예제 #6
0
def get_programs():
    """
    /
    GET

    Return the available resources at the top level above programs i.e.
    registered programs.

    :reqheader Content-Type: |reqheader_Content-Type|
    :reqheader Accept: |reqheader_Accept|
    :reqheader X-Auth-Token: |reqheader_X-Auth-Token|
    :resheader Content-Type: |resheader_Content-Type|
    :statuscode 200: Success
    :statuscode 404: Program not found.
    :statuscode 403: Unauthorized request.

    **Example**

    .. code-block:: http

           GET /v0/submission/ HTTP/1.1
           Host: example.com
           Content-Type: application/json
           X-Auth-Token: MIIDKgYJKoZIhvcNAQcC...
           Accept: application/json

    .. code-block:: JavaScript

        {
            "links": [
                "/v0/sumission/CGCI/",
                "/v0/sumission/TARGET/",
                "/v0/sumission/TCGA/"
            ]
        }
    """
    if flask.current_app.config.get('AUTH_SUBMISSION_LIST', True) is True:
        auth.validate_request(aud={'openid'}, purpose=None)
    with flask.current_app.db.session_scope():
        programs = current_app.db.nodes(models.Program.name).all()
    links = [flask.url_for('.get_projects', program=p[0]) for p in programs]
    return flask.jsonify({'links': links})
예제 #7
0
def get_project_dictionary_entry(program, project, entry):
    """
    Get the dictionary entry for a specific project.

    Summary:
        Get the dictionary schema for an entity of a project

    Tags:
        dictionary

    Args:
        program (str): |program_id|
        project (str): |project_id|
        entry (str): entity type to retrieve the schema for (e.g. ``aliquot``)

    Responses:
        200 (schema_entity): Success
        404: Resource not found.
        403: Unauthorized request.
    """
    if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
        auth.validate_request(aud={"openid"}, purpose=None)
    return get_dictionary_entry(entry)