diff --git a/app/create_db.py b/app/create_db.py index 0578abdf..75aba551 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -4,7 +4,11 @@ import sys import distro sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/')) -from app.modules.db.db_model import * +from app.modules.db.db_model import ( + connect, Setting, Role, User, UserGroups, Groups, Services, RoxyTool, Version, SmonHttpCheck, GeoipCodes, SmonTcpCheck, SMON, + SmonPingCheck, migrate, mysql_enable, create_tables +) +from peewee import DateTimeField, IntegerField, CharField, SQL conn = connect() @@ -696,7 +700,7 @@ def update_db_v_7_4(): def update_ver(): try: - Version.update(version='7.3.3.0').execute() + Version.update(version='8.0').execute() except Exception: print('Cannot update version') diff --git a/app/modules/db/db_model.py b/app/modules/db/db_model.py index e17a97f0..f06914b7 100644 --- a/app/modules/db/db_model.py +++ b/app/modules/db/db_model.py @@ -199,7 +199,7 @@ class Cred(BaseModel): class Meta: table_name = 'cred' - constraints = [SQL('UNIQUE (name, `groups`)')] + constraints = [SQL('UNIQUE (name, `group_id`)')] class Backup(BaseModel): diff --git a/app/views/ha/views.py b/app/views/ha/views.py index 371551fe..5146408a 100644 --- a/app/views/ha/views.py +++ b/app/views/ha/views.py @@ -32,9 +32,7 @@ class HAView(MethodView): name: 'service' description: 'Can be only "cluster"' required: true - schema: - type: 'string' - enum: ['cluster'] + type: 'string' - in: 'path' name: 'cluster_id' description: 'ID of the HA cluster to retrieve information from.' @@ -124,9 +122,7 @@ class HAView(MethodView): name: 'service' description: 'Can be only "cluster"' required: true - schema: - type: 'string' - enum: ['cluster'] + type: 'string' - in: body name: body required: true @@ -523,7 +519,7 @@ class HAVIPView(MethodView): required: true type: 'string' - in: 'path' - name: 'cluster_id' + name: 'router_id' description: 'ID of the VIP to delete' required: true type: 'integer' diff --git a/app/views/install/views.py b/app/views/install/views.py index e24936f2..2a55de64 100644 --- a/app/views/install/views.py +++ b/app/views/install/views.py @@ -27,9 +27,7 @@ class InstallView(MethodView): parameters: - in: path name: service - schema: - type: string - enum: [haproxy, nginx, apache, keepalived] + type: 'integer' required: true description: The type of service (haproxy, nginx, apache, keepalived) - in: path diff --git a/app/views/server/views.py b/app/views/server/views.py index a4b29313..702adca3 100644 --- a/app/views/server/views.py +++ b/app/views/server/views.py @@ -270,8 +270,7 @@ class ServerView(MethodView): name: 'server_id' description: 'ID of server to delete' required: true - schema: - type: 'integer' + type: 'integer' responses: 204: description: Server deletion successful @@ -614,14 +613,6 @@ class CredView(MethodView): description: 'Username associated with the credential' 404: description: 'Credential not found' - content: - application/json: - schema: - type: 'object' - properties: - error: - type: 'string' - description: 'Error message' """ group_id = int(g.user_params['group_id']) try: @@ -835,28 +826,26 @@ class CredsView(MethodView): responses: 200: description: 'Credentials Information' - content: - application/json: - schema: - type: 'array' - items: - type: 'object' - properties: - group_id: - type: 'integer' - description: 'Group ID the credential belongs to' - id: - type: 'integer' - description: 'Credential ID' - key_enabled: - type: 'integer' - description: 'Key status of the credential' - name: - type: 'string' - description: 'Name of the credential' - username: - type: 'string' - description: 'Username of the credential' + schema: + type: 'array' + items: + type: 'object' + properties: + group_id: + type: 'integer' + description: 'Group ID the credential belongs to' + id: + type: 'integer' + description: 'Credential ID' + key_enabled: + type: 'integer' + description: 'Key status of the credential' + name: + type: 'string' + description: 'Name of the credential' + username: + type: 'string' + description: 'Username of the credential' """ group_id = SupportClass.return_group_id(query) try: diff --git a/app/views/service/views.py b/app/views/service/views.py index b95840b9..228a09e8 100644 --- a/app/views/service/views.py +++ b/app/views/service/views.py @@ -33,9 +33,7 @@ class ServiceView(MethodView): parameters: - in: path name: service - schema: - type: string - enum: [haproxy, nginx, apache, keepalived] + type: 'string' required: true description: The type of service (haproxy, nginx, apache, keepalived) - in: path @@ -160,9 +158,7 @@ class ServiceActionView(MethodView): parameters: - in: path name: service - schema: - type: string - enum: [haproxy, nginx, apache, keepalived, waf_haproxy, waf_nginx] + type: 'integer' required: true description: The type of service (haproxy, nginx, apache, keepalived, waf_haproxy, waf_nginx) - in: path @@ -172,9 +168,7 @@ class ServiceActionView(MethodView): description: The ID or IP of the server - in: path name: action - schema: - type: string - enum: [start, stop, reload, restart] + type: 'string' required: true description: The action to be performed on the service (start, stop, reload, restart) responses: @@ -217,9 +211,7 @@ class ServiceBackendView(MethodView): parameters: - in: path name: service - schema: - type: string - enum: [haproxy, nginx, apache, keepalived] + type: 'integer' required: true description: The type of service (haproxy, nginx, apache, keepalived) - in: path @@ -265,9 +257,7 @@ class ServiceConfigView(MethodView): parameters: - in: path name: service - schema: - type: string - enum: [haproxy, nginx, apache, keepalived] + type: 'integer' required: true description: The type of service (haproxy, nginx, apache, keepalived) - in: path @@ -277,14 +267,12 @@ class ServiceConfigView(MethodView): description: The ID or IP of the server - in: query name: file_name - schema: - type: string + type: 'string' required: false description: The full path to the configuration file (used only for nginx and apache, replace "/" with 92) - in: query name: version - schema: - type: string + type: 'string' required: false description: The version of the configuration file responses: @@ -423,15 +411,12 @@ class ServiceConfigVersionsView(MethodView): parameters: - in: path name: service - schema: - type: string - enum: [haproxy, nginx, apache, keepalived] + type: 'integer' required: true description: The type of service (haproxy, nginx, apache, keepalived) - in: path name: server_id - schema: - type: string + type: 'integer' required: true description: The ID or IP of the server responses: diff --git a/app/views/tools/views.py b/app/views/tools/views.py index d1a6fb42..dea428cc 100644 --- a/app/views/tools/views.py +++ b/app/views/tools/views.py @@ -29,15 +29,12 @@ class CheckerView(MethodView): parameters: - in: path name: service - schema: - type: string - enum: [haproxy, nginx, apache, keepalived] + type: 'integer' required: true description: The type of service (haproxy, nginx, apache, keepalived) - in: path name: server_id - schema: - type: string + type: 'integer' required: true description: The ID or IP of the server responses: diff --git a/app/views/udp/views.py b/app/views/udp/views.py index c6b7b43b..fcb476c8 100644 --- a/app/views/udp/views.py +++ b/app/views/udp/views.py @@ -41,7 +41,6 @@ class UDPListener(MethodView): type: integer required: true description: The listener's identifier - responses: 200: description: Listener configuration returned successfully @@ -137,8 +136,7 @@ class UDPListener(MethodView): name: 'service' description: 'Can be only "udp"' required: true - schema: - type: 'string' + type: 'string' - in: body name: body required: true @@ -221,14 +219,12 @@ class UDPListener(MethodView): name: 'service' description: 'Can be only "udp"' required: true - schema: - type: 'string' + type: 'string' - in: 'path' name: 'listener_id' description: 'ID of the UDP listener' required: true - schema: - type: 'integer' + type: 'integer' - in: body name: body required: true @@ -310,14 +306,12 @@ class UDPListener(MethodView): name: 'service' description: 'Can be only "udp"' required: true - schema: - type: 'string' + type: 'string' - in: 'path' name: 'listener_id' description: 'ID of the UDP listener' required: true - schema: - type: 'integer' + type: 'integer' responses: 204: description: UDP listener deletion successful @@ -447,18 +441,16 @@ class UDPListenerActionView(MethodView): - in: path name: service required: true + type: 'string' description: Can be only "udp" - in: path name: listener_id - schema: - type: integer + type: 'integer' required: true description: The ID af the UDP listener - in: path name: action - schema: - type: string - enum: [start, stop, reload, restart] + type: 'string' required: true description: The action to be performed on the service (start, stop, reload, restart) responses: diff --git a/app/views/user/views.py b/app/views/user/views.py index c0bbc20d..c4f3f416 100644 --- a/app/views/user/views.py +++ b/app/views/user/views.py @@ -283,7 +283,8 @@ class UserGroupView(MethodView): methods = ["GET", "POST", "PUT", "DELETE", "PATCH"] decorators = [jwt_required(), get_user_params(), page_for_admin(level=4), check_group()] - def get(self, user_id: int): + @staticmethod + def get(user_id: int): """ Fetch a specific User Group. ---