Add skeleton for city commands and add API routes

This commit is contained in:
Koa 2023-01-17 19:15:18 -05:00
parent 9c3b9cf535
commit a9e740d034
2 changed files with 69 additions and 0 deletions

View File

@ -29,6 +29,7 @@ from hub_api.session import SessionStart, SessionEnd, KeepSessionAlive
from hub_api.uptime import Uptime from hub_api.uptime import Uptime
from hub_api.greenery import Greenery from hub_api.greenery import Greenery
from hub_api.user import User, UserLogin from hub_api.user import User, UserLogin
from hub_api.city_commands import SaveCity, UpdateCity, DeleteCity, ListCities, SearchCity
from flasgger import LazyJSONEncoder, LazyString, Swagger from flasgger import LazyJSONEncoder, LazyString, Swagger
app = flask.Flask('gamification') app = flask.Flask('gamification')
@ -81,4 +82,10 @@ api.add_resource(SessionEnd, '/v1.4/session/end')
api.add_resource(KeepSessionAlive, '/v1.4/session/keep_alive') api.add_resource(KeepSessionAlive, '/v1.4/session/keep_alive')
api.add_resource(CityInfo, '/v1.4/city_info') api.add_resource(CityInfo, '/v1.4/city_info')
api.add_resource(City, '/v1.4/city') 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') api.add_resource(Greenery, '/v1.4/greenery')

62
hub_api/city_commands.py Normal file
View File

@ -0,0 +1,62 @@
"""
HeatPump Service
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Project Author Koa Wells kekoa.wells@concordia.ca
"""
import json
from flask import Response, request
from flask_restful import Resource
from imports.user_factory import UserFactory
from exports.user_factory import UserFactory as ExUserFactory
import os
from hub_logger import logger
from hub_api.helpers.auth import generate_auth_token, role_required
from persistence.models import UserRoles
#Admin commands
class SaveCity(Resource):
def __init__(self):
print()
@role_required([UserRoles.Admin.value])
def put(self):
class UpdateCity(Resource):
def __init__(self):
print()
@role_required([UserRoles.Admin.value])
def put(self):
class UpdateCity(Resource):
class DeleteCity(Resource):
def __init__(self):
print()
@role_required([UserRoles.Admin.value])
def delete(self):
#Standard user commands
class ListCities(Resource):
def __init__(self):
print()
@role_required([UserRoles.Admin.value])
def put(self):
class SearchCity(Resource):
def __init__(self):
print()
def get(self):
class UpdateCity(Resource):
def __init__(self):
print()
def get(self):