dashboard/backend/areas/apps/apps.py

68 lines
1.7 KiB
Python
Raw Normal View History

2022-10-03 06:47:25 +02:00
from flask import jsonify
2021-09-27 12:03:35 +02:00
from flask_jwt_extended import jwt_required
from flask_cors import cross_origin
from areas import api_v1
2022-09-23 19:04:29 +02:00
from .apps_service import AppsService
2021-09-27 12:03:35 +02:00
CONFIG_DATA = [
{
"id": "values.yml",
"description": "Some user friendly description",
"raw": "cronjob:\n # Set curl to accept insecure connections when acme staging is used\n curlInsecure: false",
"fields": [
{"name": "cronjob", "type": "string", "value": ""},
{"name": "curlInsecure", "type": "boolean", "value": "false"}
]
}
]
@api_v1.route('/apps', methods=['GET'])
@jwt_required()
@cross_origin()
def get_apps():
"""Return data about all apps"""
2022-09-23 19:04:29 +02:00
apps = AppsService.get_all_apps()
return jsonify(apps)
2021-09-27 12:03:35 +02:00
@api_v1.route('/apps/<string:slug>', methods=['GET'])
2022-09-28 10:02:51 +02:00
@jwt_required()
2021-09-27 12:03:35 +02:00
def get_app(slug):
"""Return data about a single app"""
2022-09-23 19:04:29 +02:00
app = AppsService.get_app(slug)
return jsonify(app)
2021-09-27 12:03:35 +02:00
@api_v1.route('/apps', methods=['POST'])
@jwt_required()
@cross_origin()
def post_app():
"""Unused function, returns bogus data for now"""
return jsonify([]), 201
2021-09-27 12:03:35 +02:00
@api_v1.route('/apps/<string:slug>', methods=['PUT'])
@jwt_required()
@cross_origin()
def put_app(slug):
"""Unused function, returns bogus data for now"""
return jsonify([])
2021-09-27 12:03:35 +02:00
@api_v1.route('/apps/<string:slug>/config', methods=['GET'])
@jwt_required()
@cross_origin()
def get_config(slug):
"""Returns bogus config data"""
2021-09-27 12:03:35 +02:00
return jsonify(CONFIG_DATA)
@api_v1.route('/apps/<string:slug>/config', methods=['DELETE'])
@jwt_required()
@cross_origin()
def delete_config(slug):
"""Does nothing, then returns bogus config data"""
2021-09-27 12:03:35 +02:00
return jsonify(CONFIG_DATA)