Add /api/v1/ handler with no routes

This commit is contained in:
Brian C. Lane 2019-08-06 16:08:10 -07:00
parent f5bb2dca8c
commit 278214ff8e
2 changed files with 29 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import werkzeug
from pylorax import vernum from pylorax import vernum
from pylorax.api.errors import HTTP_ERROR from pylorax.api.errors import HTTP_ERROR
from pylorax.api.v0 import v0_api from pylorax.api.v0 import v0_api
from pylorax.api.v1 import v1_api
from pylorax.sysutils import joinpaths from pylorax.sysutils import joinpaths
GitLock = namedtuple("GitLock", ["repo", "lock", "dir"]) GitLock = namedtuple("GitLock", ["repo", "lock", "dir"])
@ -53,9 +54,9 @@ def api_docs(path=None):
return send_from_directory(docs_path, path) return send_from_directory(docs_path, path)
@server.route("/api/status") @server.route("/api/status")
def v0_status(): def api_status():
""" """
`/api/v0/status` `/api/status`
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
Return the status of the API Server:: Return the status of the API Server::
@ -85,3 +86,6 @@ def bad_request(error):
# Register the v0 API on /api/v0/ # Register the v0 API on /api/v0/
server.register_blueprint(v0_api, url_prefix="/api/v0/") server.register_blueprint(v0_api, url_prefix="/api/v0/")
# Register the v1 API on /api/v1/
server.register_blueprint(v1_api, url_prefix="/api/v1/")

23
src/pylorax/api/v1.py Normal file
View File

@ -0,0 +1,23 @@
#
# Copyright (C) 2019 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
""" Setup v1 of the API server
"""
from pylorax.api.flask_blueprint import BlueprintSkip
# Create the v1 routes Blueprint with skip_routes support
v1_api = BlueprintSkip("v1_routes", __name__)