目录结构调整
This commit is contained in:
parent
58d8cdf3d5
commit
43d3aa20ff
2
app.py
2
app.py
|
@ -7,7 +7,7 @@ from flask.logging import default_handler
|
|||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||||
from database.mongodb import initialize_db
|
||||
from routes import blueprint_api
|
||||
from api.routes import blueprint_api
|
||||
from settings.dev import LOGGING
|
||||
from settings.common import INSTANCE, VERSION
|
||||
from common.utils import make_response
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from flask import Blueprint
|
||||
from project.routes import project_v1
|
||||
# from project.routes import project_v2
|
||||
from asset.routes import asset_v1
|
||||
from api.v1.asset import asset as asset_v1
|
||||
from api.v1.project import project as project_v1
|
||||
|
||||
|
||||
blueprint_api = Blueprint('api-main', __name__, url_prefix='/api')
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import Api
|
||||
|
||||
from asset.views import views
|
||||
|
||||
from controller.asset import views
|
||||
|
||||
# 当前app的蓝图,以app名为前缀
|
||||
asset_v1 = Blueprint('asset', __name__, url_prefix="/asset")
|
||||
asset = Blueprint('asset', __name__, url_prefix="/asset")
|
||||
|
||||
# 增加路由
|
||||
api = Api(asset_v1)
|
||||
api = Api(asset)
|
||||
api.add_resource(views.HostViews, '/host/', endpoint="host")
|
||||
api.add_resource(views.HostDetailViews, '/host/<string:pk>/', endpoint="host-detail")
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
from flask import Blueprint
|
||||
from flask_restful import Api
|
||||
|
||||
from project.views import views, operation
|
||||
from controller.project import views, operation
|
||||
|
||||
|
||||
# 当前app的蓝图,以app名为前缀
|
||||
project_v1 = Blueprint('project', __name__, url_prefix="/project")
|
||||
project = Blueprint('project', __name__, url_prefix="/project")
|
||||
|
||||
# 增加路由
|
||||
api = Api(project_v1)
|
||||
api = Api(project)
|
||||
# 项目模型的视图
|
||||
api.add_resource(views.ProjectViews, '/item/', endpoint="project")
|
||||
api.add_resource(views.ProjectDetailViews, '/item/<string:pk>/', endpoint="project-detail")
|
||||
|
@ -25,11 +25,3 @@ api.add_resource(operation.ServerSyncView, '/server/sync/', endpoint="server-syn
|
|||
|
||||
# 机器信息
|
||||
api.add_resource(operation.AgentInfo, '/agent/info/<string:agent_id>/', endpoint="agent-info")
|
||||
|
||||
|
||||
# # 接口版本v2
|
||||
# project_v2 = Blueprint('project', __name__, url_prefix="/project")
|
||||
# # 增加路由
|
||||
# api = Api(project_v2)
|
||||
# # 项目模型的视图
|
||||
# api.add_resource(views.ProjectViews, '/item/', endpoint="project_v2")
|
|
@ -2,8 +2,8 @@ import datetime
|
|||
|
||||
from flask_restful import reqparse
|
||||
|
||||
from asset import fields
|
||||
from asset import models
|
||||
from models.asset import fields as assetField
|
||||
from models.asset import models as assetModel
|
||||
from common.views import ListCreateViewSet, DetailViewSet
|
||||
|
||||
|
||||
|
@ -38,8 +38,8 @@ class HostParse:
|
|||
|
||||
|
||||
class HostViews(HostParse, ListCreateViewSet):
|
||||
model = models.Host
|
||||
fields = fields.HostFields
|
||||
model = assetModel.Host
|
||||
fields = assetField.HostFields
|
||||
|
||||
def __init__(self):
|
||||
self.init_parse()
|
||||
|
@ -49,8 +49,8 @@ class HostViews(HostParse, ListCreateViewSet):
|
|||
|
||||
|
||||
class HostDetailViews(HostParse, DetailViewSet):
|
||||
model = models.Host
|
||||
fields = fields.HostFields
|
||||
model = assetModel.Host
|
||||
fields = assetField.HostFields
|
||||
|
||||
def __init__(self):
|
||||
self.init_parse()
|
||||
|
@ -72,8 +72,8 @@ class DatabaseServerParse:
|
|||
|
||||
|
||||
class MySQLInstanceViews(DatabaseServerParse, ListCreateViewSet):
|
||||
model = models.MySQLInstance
|
||||
fields = fields.MySQLInstanceFields
|
||||
model = assetModel.MySQLInstance
|
||||
fields = assetField.MySQLInstanceFields
|
||||
|
||||
def __init__(self):
|
||||
self.init_parse()
|
||||
|
@ -91,8 +91,8 @@ class MySQLInstanceViews(DatabaseServerParse, ListCreateViewSet):
|
|||
|
||||
|
||||
class MySQLInstanceDetail(DatabaseServerParse, DetailViewSet):
|
||||
model = models.MySQLInstance
|
||||
fields = fields.MySQLInstanceFields
|
||||
model = assetModel.MySQLInstance
|
||||
fields = assetField.MySQLInstanceFields
|
||||
|
||||
def __init__(self):
|
||||
"""对象修改的参数解析"""
|
||||
|
@ -111,8 +111,8 @@ class MySQLInstanceDetail(DatabaseServerParse, DetailViewSet):
|
|||
|
||||
|
||||
class RedisInstanceViews(DatabaseServerParse, ListCreateViewSet):
|
||||
model = models.RedisInstance
|
||||
fields = fields.RedisInstanceFields
|
||||
model = assetModel.RedisInstance
|
||||
fields = assetField.RedisInstanceFields
|
||||
|
||||
def __init__(self):
|
||||
self.init_parse()
|
||||
|
@ -128,8 +128,8 @@ class RedisInstanceViews(DatabaseServerParse, ListCreateViewSet):
|
|||
|
||||
|
||||
class RedisInstanceDetail(DatabaseServerParse, DetailViewSet):
|
||||
model = models.RedisInstance
|
||||
fields = fields.RedisInstanceFields
|
||||
model = assetModel.RedisInstance
|
||||
fields = assetField.RedisInstanceFields
|
||||
|
||||
def __init__(self):
|
||||
self.init_parse()
|
||||
|
@ -158,8 +158,8 @@ class MiddlewareParse:
|
|||
|
||||
|
||||
class NginxInstanceViews(MiddlewareParse, ListCreateViewSet):
|
||||
model = models.NginxInstance
|
||||
fields = fields.NginxInstanceFields
|
||||
model = assetModel.NginxInstance
|
||||
fields = assetField.NginxInstanceFields
|
||||
|
||||
def __init__(self):
|
||||
self.init_parse()
|
||||
|
@ -172,8 +172,8 @@ class NginxInstanceViews(MiddlewareParse, ListCreateViewSet):
|
|||
|
||||
|
||||
class NginxInstanceDetail(MiddlewareParse, DetailViewSet):
|
||||
model = models.NginxInstance
|
||||
fields = fields.NginxInstanceFields
|
||||
model = assetModel.NginxInstance
|
||||
fields = assetField.NginxInstanceFields
|
||||
|
||||
def __init__(self):
|
||||
self.init_parse()
|
||||
|
@ -186,8 +186,8 @@ class NginxInstanceDetail(MiddlewareParse, DetailViewSet):
|
|||
|
||||
|
||||
class CDNViews(ListCreateViewSet):
|
||||
model = models.CDN
|
||||
fields = fields.CDNFields
|
||||
model = assetModel.CDN
|
||||
fields = assetField.CDNFields
|
||||
uniq_fields = ("domain",)
|
||||
|
||||
def __init__(self):
|
||||
|
@ -200,8 +200,8 @@ class CDNViews(ListCreateViewSet):
|
|||
|
||||
|
||||
class CDNDetail(DetailViewSet):
|
||||
model = models.CDN
|
||||
fields = fields.CDNFields
|
||||
model = assetModel.CDN
|
||||
fields = assetField.CDNFields
|
||||
uniq_fields = ("domain",)
|
||||
|
||||
def __init__(self):
|
|
@ -1,12 +1,12 @@
|
|||
import datetime
|
||||
|
||||
from flask import current_app as app
|
||||
from flask_restful import reqparse, Resource, marshal, fields as F
|
||||
from flask_restful import reqparse, marshal, fields as F
|
||||
|
||||
from asset.models import Host
|
||||
from asset.fields import HostFields
|
||||
from project import fields
|
||||
from project.models import Project, Channel, Server, Version
|
||||
from models.asset.models import Host
|
||||
from models.asset.fields import HostFields
|
||||
from models.project import fields
|
||||
from models.project.models import Project, Channel, Server, Version
|
||||
from common.views import CreateMixin, RetrieveMixin
|
||||
from common.permission import token_header_required
|
||||
from common.utils import make_response
|
|
@ -1,7 +1,7 @@
|
|||
"""数据模型常规增删查改的接口"""
|
||||
|
||||
from project import fields
|
||||
from project.models import Project, Channel, Server
|
||||
from models.project import fields
|
||||
from models.project.models import Project, Channel, Server
|
||||
from common.views import ListMixin, CreateMixin, ListCreateViewSet, DetailViewSet
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import *
|
|
@ -86,6 +86,7 @@ CDNFields = {
|
|||
"id": fields.String,
|
||||
"domain": fields.String,
|
||||
"data": fields.Raw,
|
||||
"manage": fields.String,
|
||||
"tags": fields.List(fields.String),
|
||||
"labels": fields.Raw,
|
||||
}
|
|
@ -98,6 +98,7 @@ class NginxInstance(Middleware):
|
|||
class CDN(DocumentBase):
|
||||
"""cdn域名"""
|
||||
domain = mongo.StringField(max_length=256, required=True) # cdn域名
|
||||
manage = mongo.StringField(max_length=128, default="")
|
||||
data = mongo.DictField(default=dict)
|
||||
# 标记和标签
|
||||
tags = mongo.ListField(mongo.StringField(), default=list) # tags 默认是空列表
|
|
@ -3,7 +3,7 @@ project marshal fields
|
|||
"""
|
||||
|
||||
from flask_restful import fields
|
||||
from asset.fields import HostSimpleFields
|
||||
from models.asset.fields import HostSimpleFields
|
||||
|
||||
ProjectFields = {
|
||||
"id": fields.String,
|
||||
|
@ -81,19 +81,19 @@ AgentServerFields = {
|
|||
"spid": fields.String,
|
||||
"agent": fields.String,
|
||||
"is_cross": fields.Boolean,
|
||||
# "channel_id": fields.String,
|
||||
# "channel_id": serializer.String,
|
||||
"project": fields.String,
|
||||
"project_name": fields.String,
|
||||
"project_fork": fields.String,
|
||||
"public_ip": fields.String,
|
||||
"private_ip": fields.String,
|
||||
# "host_id": fields.String,
|
||||
# "host_id": serializer.String,
|
||||
"domain": fields.String,
|
||||
"port": fields.Integer,
|
||||
"version": fields.Nested(VersionFields),
|
||||
"status": fields.String,
|
||||
"weight": fields.Integer,
|
||||
"slot": fields.Integer,
|
||||
# "tags": fields.List(fields.String),
|
||||
# "labels": fields.Raw,
|
||||
# "tags": serializer.List(serializer.String),
|
||||
# "labels": serializer.Raw,
|
||||
}
|
|
@ -4,7 +4,7 @@ from settings import common
|
|||
from common.document import DocumentBase
|
||||
from common.validator import isalnum, is_hex_string
|
||||
|
||||
from asset.models import Host
|
||||
from models.asset.models import Host
|
||||
|
||||
|
||||
class Project(DocumentBase):
|
Loading…
Reference in New Issue