Commit dde19701 authored by cazenave's avatar cazenave
Browse files

depuis pc maison

parents
.git
__pycache__
*.pyc
*.pyo
*.pyd
.Python
env
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State />
<State>
<id>EncapsulationJava</id>
</State>
<State>
<id>Inheritance issuesJava</id>
</State>
<State>
<id>Java</id>
</State>
</expanded-state>
</profile-state>
</entry>
</component>
</project>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
<component name="libraryTable">
<library name="logos">
<CLASSES>
<root url="jar://$PROJECT_DIR$/src/static/img/logos.zip!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/smartAPI.iml" filepath="$PROJECT_DIR$/.idea/smartAPI.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2015 The Network of BioThings Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# SmartAPI
Intelligent APIs for a more connected web.
A BD2K/Network-of-BioThings project.
SmartAPI allows API publishers to annotate their services and input/output parameters in a structured and identifiable manner, based on a standard JSON-LD format for biomedical APIs and services. By indexing and visualizing these descriptions as Linked Data in a Elasticsearch back-end, researchers can seamlessly identify the services that consume or return desired parameters, and automatically compose services in workflows that yield new insights.
Presentation: http://bit.ly/smartAPIslides
Contact: api-interoperability@googlegroups.com
# How to run a dev API server locally
1. Install Elasticsearch at localhost:9200 (follow [this instruction](https://www.elastic.co/downloads/elasticsearch)) or install with docker (follow [this instruction](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html))
```
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.7.0
````
2. Clone this repo
```
git clone https://github.com/SmartAPI/smartAPI.git
````
3. Install system packages (on Ubuntu, for example)
```
sudo apt install libcurl4-openssl-dev libssl-dev aws-cli
```
4. Change directory to SmartAPI source files
```
cd smartAPI/src
```
3. Install python dependencies
```
pip install -r requirements.txt
```
5. Create a *config_key.py* under *src* with
```
COOKIE_SECRET = '<Any Random String>'
GITHUB_CLIENT_ID = '<your Github application Client ID>'
GITHUB_CLIENT_SECRET = '<your Github application Client Secret>'
```
Follow [this instruction](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/) to create your Github Client ID and Secret.
Enter any _Application name_, `http://localhost:8000/` for _Homepage
URL_ and `http://localhost:8000/oauth` for _Authorization callback URL_.
6. Create index in Python shell:
```
from api import es
es.create_index()
```
Or import some API data from a saved dump file. Contact us for the dump file.
And replace the name of the file in the command with the backup file name.
```
from api import es
esq = es.ESQuery()
esq.restore_all("smartapi_oas3_backup_20190128.json", es.ES_INDEX_NAME)
```
8. Run dev server
```
python index.py --debug
```
You should now able to access API dev server at http://localhost:8000
version: "3.4"
services:
smartapi:
image: cines/smartapi:v1
container_name: smartapi
ports:
- 8000:8000
restart: on-failure
depends_on:
- elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
container_name: elasticsearch
ports:
- 9200:9200
- 9300:9300
environment:
- discovery.type=single-node
FROM python:3.6
# Create app directory
WORKDIR /app
# Install app dependencies
COPY src/requirements.txt ./
RUN pip install -r requirements.txt
# Bundle app source
COPY src /app
EXPOSE 8000
CMD [ "python", "index.py" , "--debug"]
{
"basePath": "http://smartapi.default.svc.cluster.local",
"name": "SmartAPI v1 API",
"protocol": "rest",
"publicPath": "",
"version": "1.0",
"resources": {
"API GET Method": {
"methods": {
"api_get": {
"description": "Retreive metadata about an API based on its id",
"httpMethod": "GET",
"name": "API GET",
"parameters": {
"api_id": {
"default": "",
"description": "A unique API id, e.g. \"mygene.info\", \"myvariant.info\". If \"all\" is passed, a dump of all API metadata is returned.",
"location": "path",
"required": true,
"type": "string"
},
"fields": {
"default": "",
"description": "a comma-separated fields to limit the fields returned from the matching API hits. The supported field names can be found from any API object (e.g. http://smart-api.info/api/metadata/mygene.info). Note that it supports dot notation, and wildcards as well, e.g., you can pass \"host\", \"operations.parameters\", \"info.title\", or \"info.*\". If \"fields=all\", all available fields will be returned. Default: \"all\".",
"type": "string"
}
},
"path": "/api/metadata/{api_id}"
}
}
},
"API Query Method": {
"methods": {
"api_query": {
"description": "Query for existing APIs matching query terms",
"httpMethod": "GET",
"name": "API Query",
"parameters": {
"q": {
"default": "",
"description": "Any query term",
"required": true,
"type": "string"
}
},
"path": "/api/query/"
}
}
},
"API Save Method": {
"methods": {
"api_post": {
"description": "Saving a new API with annotated metadata",
"httpMethod": "POST",
"name": "API Save",
"parameters": {
"api_key": {
"default": "",
"description": "Provide an API key for this operation",
"required": true,
"type": "string"
},
"overwrite": {
"description": "pass \"true\" or \"1\" to overwrite existing API metadata object",
"type": "boolean"
},
"data": {
"default": "",
"description": "A JSON formated metadata object passed as POST body",
"required": true,
"type": "string"
}
},
"path": "/api"
}
}
},
"API Field Suggestion Method": {
"methods": {
"api_field_suggestion": {
"description": "For a given field, return the possible field values in existing API database, sorted by the occurences in descending order",
"httpMethod": "GET",
"name": "API Field Suggestion",
"parameters": {
"field": {
"default": "",
"description": "A valid field name from the API metadata object, e.g. \"operations.parameters.type\", \"operations.responses.httpCode\", \"schemes\" ",
"required": true,
"type": "string"
},
"size": {
"default": 100,
"description": "The number of possible values should be returned. The default is top 100",
"required": false,
"type": "integer"
}
},
"path": "/api/suggestion/"
}
}
}
}
}
''' SmartAPI Configuration '''
# pylint: disable=wildcard-import, unused-wildcard-import, unused-import
from biothings.web.settings.default import *
from config_key import COOKIE_SECRET, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET
from web.api.handlers import APP_LIST as api_app_list
from web.api.query_builder import SmartAPIQueryBuilder
from web.handlers import APP_LIST as web_app_list
# *****************************************************************************
# Credentials
# *****************************************************************************
# Define in config_key.py:
# COOKIE_SECRET = '<Any Random String>'
# GITHUB_CLIENT_ID = '<your Github application Client ID>'
# GITHUB_CLIENT_SECRET = '<your Github application Client Secret>'
# *****************************************************************************
# Elasticsearch
# *****************************************************************************
ES_INDEX = 'smartapi_oas3'
ES_DOC_TYPE = 'api'
# *****************************************************************************
# Tornado URL Patterns
# *****************************************************************************
def add_apps(prefix='', app_list=None):
'''
Add prefix to each url handler specified in app_list.
add_apps('test', [('/', testhandler,
('/test2', test2handler)])
will return:
[('/test/', testhandler,
('/test/test2', test2handler)])
'''
if not app_list:
app_list = []
if prefix:
return [('/'+prefix+url, handler) for url, handler in app_list]
else:
return app_list
APP_LIST = []
APP_LIST += add_apps('', web_app_list)
APP_LIST += add_apps('api', api_app_list)
# *****************************************************************************
# Biothings Query Settings
# *****************************************************************************
# Subclass of biothings.web.api.es.query_builder.ESQueryBuilder
ES_QUERY_BUILDER = SmartAPIQueryBuilder
# Keyword Argument Control
QUERY_GET_ESQB_KWARGS.update({'filters': {'default': None, 'type': str}})
# Header Strings
ACCESS_CONTROL_ALLOW_METHODS = 'GET,POST,PUT,DELETE,OPTIONS'
# Only affect API endpoints
DISABLE_CACHING = True
# Heavy operation. Enable on small db only.
ALLOW_RANDOM_QUERY = True
COOKIE_SECRET = '<Any Random String>'
GITHUB_CLIENT_ID = '<your Github application Client ID>'
GITHUB_CLIENT_SECRET = '<your Github application Client Secret>'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment