api_v1.4/bootstrap.py
2023-01-30 05:24:32 -05:00

57 lines
2.3 KiB
Python

"""
Main
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2021 Project Author name guillermo.gutierrezmorote@concordia.ca
Project Collaborator name peteryefi@gmail.com
"""
import datetime
import flask
import yaml
from flasgger import LazyJSONEncoder, Swagger
from flask import Response
from flask_restful import Api
import hub_api.helpers.session_helper as sh
from hub_api.construction_catalog import ConstructionCatalogEntry, ConstructionCatalogEntries, ConstructionCatalogNames
from hub_api.greenery_catalog import GreeneryCatalogEntry, GreeneryCatalogEntries, GreeneryCatalogNames
from hub_api.session import SessionStart, SessionEnd, KeepSessionAlive
from hub_api.uptime import Uptime
from hub_api.usage_catalog import UsageCatalogEntry, UsageCatalogEntries, UsageCatalogNames
from hub_api.user import User, UserLogin
sh.begin_time = datetime.datetime.now()
app = flask.Flask('cerc_api')
app.json_provider_class = LazyJSONEncoder
api = Api(app)
api.add_resource(Uptime, '/v1.4/uptime')
# Catalogs.
api.add_resource(GreeneryCatalogEntry, '/v1.4/greenery-catalog/entry')
api.add_resource(GreeneryCatalogEntries, '/v1.4/greenery-catalog/entries')
api.add_resource(GreeneryCatalogNames, '/v1.4/greenery-catalog/names')
api.add_resource(ConstructionCatalogEntry, '/v1.4/construction-catalog/entry')
api.add_resource(ConstructionCatalogEntries, '/v1.4/construction-catalog/entries')
api.add_resource(ConstructionCatalogNames, '/v1.4/construction-catalog/names')
api.add_resource(UsageCatalogEntry, '/v1.4/usage-catalog/entry')
api.add_resource(UsageCatalogEntries, '/v1.4/usage-catalog/entries')
api.add_resource(UsageCatalogNames, '/v1.4/usage-catalog/names')
# Session
api.add_resource(User, '/v1.4/user')
api.add_resource(UserLogin, '/v1.4/user/login')
api.add_resource(SessionStart, '/v1.4/session/start')
api.add_resource(SessionEnd, '/v1.4/session/end')
api.add_resource(KeepSessionAlive, '/v1.4/session/keep_alive')
api.add_resource(CityInfo, '/v1.4/city_info')
api.add_resource(City, '/v1.4/city')
api.add_resource(SaveCity, '/v1.4/city/save_city')
api.add_resource(UpdateCity, '/v1.4/city/update_city')
api.add_resource(DeleteCity, '/v1.4/city/delete_city')
api.add_resource(ListCities, '/v1.4/city/list_cities')
api.add_resource(SearchCity, '/v1.4/city/search_city')
api.add_resource(Greenery, '/v1.4/greenery')