2020-04-06 11:52:18 +02:00
|
|
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
|
|
|
# BigchainDB and IPDB software contributors.
|
2018-08-16 12:31:32 +02:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
|
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
|
2017-11-30 15:04:14 +01:00
|
|
|
"""API Index endpoint"""
|
2016-08-19 13:56:08 +02:00
|
|
|
|
|
|
|
import flask
|
2017-01-05 13:31:05 +01:00
|
|
|
from flask_restful import Resource
|
2016-08-19 13:56:08 +02:00
|
|
|
|
2017-06-14 11:09:42 +02:00
|
|
|
from bigchaindb.web.views.base import base_ws_uri
|
2016-08-19 13:56:08 +02:00
|
|
|
from bigchaindb import version
|
2017-04-07 14:57:11 +02:00
|
|
|
from bigchaindb.web.websocket_server import EVENTS_ENDPOINT
|
2016-08-19 13:56:08 +02:00
|
|
|
|
|
|
|
|
2017-01-06 14:18:10 +01:00
|
|
|
class RootIndex(Resource):
|
2017-01-05 13:31:05 +01:00
|
|
|
def get(self):
|
2017-01-06 14:45:38 +01:00
|
|
|
docs_url = [
|
2017-02-09 11:10:58 +01:00
|
|
|
'https://docs.bigchaindb.com/projects/server/en/v',
|
|
|
|
version.__version__ + '/'
|
2017-01-06 14:45:38 +01:00
|
|
|
]
|
2017-01-05 13:31:05 +01:00
|
|
|
return flask.jsonify({
|
2017-06-12 15:13:42 +02:00
|
|
|
'api': {
|
2017-06-14 11:09:42 +02:00
|
|
|
'v1': get_api_v1_info('/api/v1/')
|
2017-01-06 14:45:38 +01:00
|
|
|
},
|
2017-06-12 15:13:42 +02:00
|
|
|
'docs': ''.join(docs_url),
|
2017-01-05 13:31:05 +01:00
|
|
|
'software': 'BigchainDB',
|
|
|
|
'version': version.__version__,
|
|
|
|
})
|
2017-01-06 14:18:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ApiV1Index(Resource):
|
|
|
|
def get(self):
|
2017-06-14 11:09:42 +02:00
|
|
|
return flask.jsonify(get_api_v1_info('/'))
|
2017-06-12 15:13:42 +02:00
|
|
|
|
|
|
|
|
2017-06-14 11:09:42 +02:00
|
|
|
def get_api_v1_info(api_prefix):
|
2017-11-30 15:04:14 +01:00
|
|
|
"""Return a dict with all the information specific for the v1 of the
|
2017-06-12 15:13:42 +02:00
|
|
|
api.
|
|
|
|
"""
|
|
|
|
websocket_root = base_ws_uri() + EVENTS_ENDPOINT
|
|
|
|
docs_url = [
|
|
|
|
'https://docs.bigchaindb.com/projects/server/en/v',
|
|
|
|
version.__version__,
|
|
|
|
'/http-client-server-api.html',
|
|
|
|
]
|
|
|
|
|
|
|
|
return {
|
|
|
|
'docs': ''.join(docs_url),
|
2017-06-14 11:09:42 +02:00
|
|
|
'transactions': '{}transactions/'.format(api_prefix),
|
2018-09-17 14:06:48 +02:00
|
|
|
'blocks': '{}blocks/'.format(api_prefix),
|
2017-06-14 11:09:42 +02:00
|
|
|
'assets': '{}assets/'.format(api_prefix),
|
|
|
|
'outputs': '{}outputs/'.format(api_prefix),
|
2017-11-22 18:31:35 +01:00
|
|
|
'streams': websocket_root,
|
|
|
|
'metadata': '{}metadata/'.format(api_prefix),
|
2018-02-27 09:00:56 +01:00
|
|
|
'validators': '{}validators'.format(api_prefix),
|
2017-06-12 15:13:42 +02:00
|
|
|
}
|