mirror of https://github.com/Aidaho12/haproxy-wi
pull/390/head
parent
178116b9c1
commit
81d28536f6
|
@ -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')
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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.
|
||||
---
|
||||
|
|
Loading…
Reference in New Issue