From 74c22e7fcc94d83660ebfbdae6657ef1d98d8d94 Mon Sep 17 00:00:00 2001 From: alex-smile <443677891@qq.com> Date: Tue, 7 Nov 2023 13:35:51 +0800 Subject: [PATCH 1/7] add gateway app binding --- .../apis/web/gateway/serializers.py | 14 ++++++ .../apigateway/apis/web/gateway/views.py | 9 ++++ .../migrations/0004_auto_20230901_1525.py | 2 +- .../migrations/0009_auto_20230902_1307.py | 2 +- .../migrations/0010_auto_20230902_1307.py | 2 +- .../migrations/0016_auto_20230818_1200.py | 2 +- .../migrations/0017_auto_20230901_1716.py | 2 +- .../apigateway/biz/gateway/gateway.py | 8 +++- .../apigateway/biz/gateway_app_binding.py | 47 +++++++++++++++++++ .../apigateway/apigateway/conf/default.py | 1 + .../apigateway/apigateway/core/admin.py | 8 ++++ .../core/migrations/0033_gatewayappbinding.py | 47 +++++++++++++++++++ ...818_1200.py => 0034_auto_20230818_1200.py} | 2 +- ...onfig.py => 0035_backend_backendconfig.py} | 2 +- ...824_1737.py => 0036_auto_20230824_1737.py} | 2 +- ...proxy_backend.py => 0037_proxy_backend.py} | 2 +- ...902_1307.py => 0038_auto_20230902_1307.py} | 2 +- ...023_1526.py => 0039_auto_20231023_1526.py} | 2 +- .../apigateway/apigateway/core/models.py | 22 ++++++++- .../apis/web/gateway/test_serializers.py | 24 ++++++++++ .../tests/apis/web/gateway/test_views.py | 6 ++- .../tests/biz/gateway/test_gateway.py | 14 +++++- .../tests/biz/test_gateway_app_binding.py | 40 ++++++++++++++++ 23 files changed, 246 insertions(+), 16 deletions(-) create mode 100644 src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py create mode 100644 src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py rename src/dashboard/apigateway/apigateway/core/migrations/{0033_auto_20230818_1200.py => 0034_auto_20230818_1200.py} (99%) rename src/dashboard/apigateway/apigateway/core/migrations/{0034_backend_backendconfig.py => 0035_backend_backendconfig.py} (98%) rename src/dashboard/apigateway/apigateway/core/migrations/{0035_auto_20230824_1737.py => 0036_auto_20230824_1737.py} (97%) rename src/dashboard/apigateway/apigateway/core/migrations/{0036_proxy_backend.py => 0037_proxy_backend.py} (96%) rename src/dashboard/apigateway/apigateway/core/migrations/{0037_auto_20230902_1307.py => 0038_auto_20230902_1307.py} (98%) rename src/dashboard/apigateway/apigateway/core/migrations/{0038_auto_20231023_1526.py => 0039_auto_20231023_1526.py} (97%) create mode 100644 src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py diff --git a/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py b/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py index 9ee467173..c2e36c2c3 100644 --- a/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py +++ b/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py @@ -20,6 +20,7 @@ from rest_framework.validators import UniqueTogetherValidator from tencent_apigateway_common.i18n.field import SerializerTranslatedField +from apigateway.biz.constants import APP_CODE_PATTERN from apigateway.biz.gateway import GatewayHandler from apigateway.biz.gateway_type import GatewayTypeHandler from apigateway.core.constants import ( @@ -83,6 +84,9 @@ class GatewayCreateInputSLZ(serializers.ModelSerializer): developers = serializers.ListField( child=serializers.CharField(), allow_empty=True, default=list, help_text="网关开发者" ) + bk_app_codes = serializers.ListField( + child=serializers.RegexField(APP_CODE_PATTERN), allow_empty=True, default=list, help_text="网关关联的应用" + ) class Meta: model = Gateway @@ -92,6 +96,7 @@ class Meta: "maintainers", "developers", "is_public", + "bk_app_codes", ) lookup_field = "id" @@ -140,6 +145,7 @@ class GatewayRetrieveOutputSLZ(serializers.ModelSerializer): docs_url = serializers.SerializerMethodField(help_text="文档地址") public_key_fingerprint = serializers.SerializerMethodField(help_text="公钥(指纹)") allow_update_gateway_auth = serializers.SerializerMethodField(help_text="是否允许更新网关认证配置") + bk_app_codes = serializers.SerializerMethodField(help_text="网关关联的应用") class Meta: model = Gateway @@ -159,6 +165,7 @@ class Meta: "api_domain", "docs_url", "public_key_fingerprint", + "bk_app_codes", ) read_only_fields = fields lookup_field = "id" @@ -199,12 +206,18 @@ def get_allow_update_gateway_auth(self, obj): def get_is_official(self, obj): return GatewayTypeHandler.is_official(self.context["auth_config"].gateway_type) + def get_bk_app_codes(self, obj): + return self.context.get("bk_app_codes", []) + class GatewayUpdateInputSLZ(serializers.ModelSerializer): maintainers = serializers.ListField(child=serializers.CharField(), allow_empty=True, help_text="网关维护人员") developers = serializers.ListField( child=serializers.CharField(), allow_empty=True, default=list, help_text="网关开发者" ) + bk_app_codes = serializers.ListField( + child=serializers.RegexField(APP_CODE_PATTERN), allow_empty=True, default=list, help_text="网关关联的应用" + ) class Meta: model = Gateway @@ -213,6 +226,7 @@ class Meta: "maintainers", "developers", "is_public", + "bk_app_codes", ) lookup_field = "id" diff --git a/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py b/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py index 6431bc6d3..3eed30215 100644 --- a/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py +++ b/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py @@ -27,6 +27,7 @@ from apigateway.apis.web.constants import UserAuthTypeEnum from apigateway.apps.audit.constants import OpTypeEnum from apigateway.biz.gateway import GatewayHandler +from apigateway.biz.gateway_app_binding import GatewayAppBindingHandler from apigateway.common.contexts import GatewayAuthContext from apigateway.common.error_codes import error_codes from apigateway.common.release.publish import trigger_gateway_publish @@ -104,6 +105,8 @@ def create(self, request, *args, **kwargs): slz = GatewayCreateInputSLZ(data=request.data, context={"created_by": request.user.username}) slz.is_valid(raise_exception=True) + bk_app_codes = slz.validated_data.pop("bk_app_codes") + # 1. save gateway slz.save( status=GatewayStatusEnum.ACTIVE.value, @@ -116,6 +119,7 @@ def create(self, request, *args, **kwargs): gateway=slz.instance, user_auth_type=UserAuthTypeEnum(settings.DEFAULT_USER_AUTH_TYPE).value, username=request.user.username, + app_codes_to_binding=bk_app_codes, ) # 3. record audit log @@ -175,6 +179,7 @@ def retrieve(self, request, *args, **kwargs): instance, context={ "auth_config": GatewayAuthContext().get_auth_config(instance.pk), + "bk_app_codes": GatewayAppBindingHandler.get_bound_app_codes(instance), }, ) return OKJsonResponse(data=slz.data) @@ -186,8 +191,12 @@ def update(self, request, *args, **kwargs): slz = GatewayUpdateInputSLZ(instance=instance, data=request.data, partial=partial) slz.is_valid(raise_exception=True) + bk_app_codes = slz.validated_data.pop("bk_app_codes") + slz.save(updated_by=request.user.username) + GatewayAppBindingHandler.update_gateway_app_bindings(instance, bk_app_codes) + GatewayHandler.record_audit_log_success( username=request.user.username, gateway_id=instance.id, diff --git a/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py b/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py index c5f0fd720..7f43ad634 100644 --- a/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py +++ b/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0036_proxy_backend'), + ('core', '0037_proxy_backend'), ('label', '0003_auto_20230227_2006'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py b/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py index 47bce3d9c..5a4b66e24 100644 --- a/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py +++ b/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0037_auto_20230902_1307'), + ('core', '0038_auto_20230902_1307'), ('monitor', '0008_auto_20230227_2006'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py b/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py index 4b7f02043..9e7bf1e25 100644 --- a/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py +++ b/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0037_auto_20230902_1307'), + ('core', '0038_auto_20230902_1307'), ('permission', '0009_auto_20210219_2129'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py b/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py index e246861e0..cdd5ad222 100644 --- a/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py +++ b/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0033_auto_20230818_1200'), + ('core', '0034_auto_20230818_1200'), ('support', '0015_auto_20230227_2006'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py b/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py index 5e5c8d4d6..fba9294b3 100644 --- a/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py +++ b/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0036_proxy_backend'), + ('core', '0037_proxy_backend'), ('support', '0016_auto_20230818_1200'), ] diff --git a/src/dashboard/apigateway/apigateway/biz/gateway/gateway.py b/src/dashboard/apigateway/apigateway/biz/gateway/gateway.py index f35d7cae1..9fe47421b 100644 --- a/src/dashboard/apigateway/apigateway/biz/gateway/gateway.py +++ b/src/dashboard/apigateway/apigateway/biz/gateway/gateway.py @@ -28,6 +28,7 @@ from apigateway.apps.monitor.models import AlarmStrategy from apigateway.apps.plugin.models import PluginBinding from apigateway.apps.support.models import ReleasedResourceDoc +from apigateway.biz.gateway_app_binding import GatewayAppBindingHandler from apigateway.biz.gateway_jwt import GatewayJWTHandler from apigateway.biz.gateway_related_app import GatewayRelatedAppHandler from apigateway.biz.iam import IAMHandler @@ -149,6 +150,7 @@ def save_related_data( user_config: Optional[dict] = None, unfiltered_sensitive_keys: Optional[List[str]] = None, api_type: Optional[GatewayTypeEnum] = None, + app_codes_to_binding: Optional[List[str]] = None, ): # 1. save gateway auth_config GatewayHandler.save_auth_config( @@ -175,7 +177,11 @@ def save_related_data( if related_app_code: GatewayRelatedAppHandler.add_related_app(gateway.id, related_app_code) - # 6. 在权限中心注册分级管理员,创建用户组 + # 6. update gateway app binding + if app_codes_to_binding is not None: + GatewayAppBindingHandler.update_gateway_app_bindings(gateway, app_codes_to_binding) + + # 7. 在权限中心注册分级管理员,创建用户组 if settings.USE_BK_IAM_PERMISSION: IAMHandler.register_grade_manager_and_builtin_user_groups(gateway) diff --git a/src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py b/src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py new file mode 100644 index 000000000..5786517e1 --- /dev/null +++ b/src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# +from typing import List + +from apigateway.core.models import Gateway, GatewayAppBinding + + +class GatewayAppBindingHandler: + @classmethod + def update_gateway_app_bindings(cls, gateway: Gateway, bk_app_codes: List[str]): + """ + 更新网关应用的绑定 + - 1. 如果 bk_app_codes 中应用未绑定,则新增绑定 + - 2. 如果已绑定的应用未在 bk_app_codes 中,则删除 + """ + bound_app_codes = cls.get_bound_app_codes(gateway) + app_codes_to_add = set(bk_app_codes) - set(bound_app_codes) + app_codes_to_delete = set(bound_app_codes) - set(bk_app_codes) + + if app_codes_to_add: + GatewayAppBinding.objects.bulk_create( + [GatewayAppBinding(gateway=gateway, bk_app_code=code) for code in app_codes_to_add] + ) + + if app_codes_to_delete: + GatewayAppBinding.objects.filter(gateway=gateway, bk_app_code__in=app_codes_to_delete).delete() + + @staticmethod + def get_bound_app_codes(gateway: Gateway) -> List[str]: + """获取已绑定的应用""" + return list(GatewayAppBinding.objects.filter(gateway=gateway).values_list("bk_app_code", flat=True)) diff --git a/src/dashboard/apigateway/apigateway/conf/default.py b/src/dashboard/apigateway/apigateway/conf/default.py index 5f719fd11..1b7eb5c97 100644 --- a/src/dashboard/apigateway/apigateway/conf/default.py +++ b/src/dashboard/apigateway/apigateway/conf/default.py @@ -790,6 +790,7 @@ "MENU_ITEM_ESB_API_DOC": env.bool("FEATURE_FLAG_MENU_ITEM_ESB_API_DOC", True), "SYNC_ESB_TO_APIGW_ENABLED": env.bool("FEATURE_FLAG_SYNC_ESB_TO_APIGW_ENABLED", True), "GATEWAY_DEVELOPERS_ENABLED": env.bool("FEATURE_FLAG_GATEWAY_DEVELOPERS_ENABLED", False), + "GATEWAY_APP_BINDING_ENABLED": env.bool("FEATURE_FLAG_GATEWAY_APP_BINDING_ENABLED", False), # api-support "ENABLE_SDK": env.bool("FEATURE_FLAG_ENABLE_SDK", False), "ALLOW_CREATE_APPCHAT": env.bool("FEATURE_FLAG_ALLOW_CREATE_APPCHAT", False), diff --git a/src/dashboard/apigateway/apigateway/core/admin.py b/src/dashboard/apigateway/apigateway/core/admin.py index 75c844504..f867672c9 100644 --- a/src/dashboard/apigateway/apigateway/core/admin.py +++ b/src/dashboard/apigateway/apigateway/core/admin.py @@ -25,6 +25,7 @@ BackendConfig, Context, Gateway, + GatewayAppBinding, GatewayRelatedApp, MicroGateway, MicroGatewayReleaseHistory, @@ -168,6 +169,12 @@ class SslCertificateBindingAdmin(admin.ModelAdmin): list_filter = ["gateway"] +class GatewayAppBindingAdmin(admin.ModelAdmin): + list_display = ["id", "gateway", "bk_app_code", "updated_time"] + search_fields = ["gateway__id", "bk_app_code"] + list_filter = ["gateway"] + + admin.site.register(Gateway, GatewayAdmin) admin.site.register(Stage, StageAdmin) admin.site.register(Resource, ResourceAdmin) @@ -187,3 +194,4 @@ class SslCertificateBindingAdmin(admin.ModelAdmin): admin.site.register(BackendConfig, BackendConfigAdmin) admin.site.register(SslCertificate, SslCertificateAdmin) admin.site.register(SslCertificateBinding, SslCertificateBindingAdmin) +admin.site.register(GatewayAppBinding, GatewayAppBindingAdmin) diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py b/src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py new file mode 100644 index 000000000..5deab8f79 --- /dev/null +++ b/src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py @@ -0,0 +1,47 @@ +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# +# Generated by Django 3.2.18 on 2023-11-07 03:51 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0032_gateway__developers'), + ] + + operations = [ + migrations.CreateModel( + name='GatewayAppBinding', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_time', models.DateTimeField(auto_now_add=True, null=True)), + ('updated_time', models.DateTimeField(auto_now=True, null=True)), + ('created_by', models.CharField(blank=True, max_length=32, null=True)), + ('updated_by', models.CharField(blank=True, max_length=32, null=True)), + ('bk_app_code', models.CharField(db_index=True, max_length=32)), + ('gateway', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.gateway')), + ], + options={ + 'db_table': 'core_gateway_app_binding', + 'unique_together': {('gateway', 'bk_app_code')}, + }, + ), + ] \ No newline at end of file diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0033_auto_20230818_1200.py b/src/dashboard/apigateway/apigateway/core/migrations/0034_auto_20230818_1200.py similarity index 99% rename from src/dashboard/apigateway/apigateway/core/migrations/0033_auto_20230818_1200.py rename to src/dashboard/apigateway/apigateway/core/migrations/0034_auto_20230818_1200.py index 29bbe978a..ee828be8e 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0033_auto_20230818_1200.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0034_auto_20230818_1200.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0032_gateway__developers'), + ('core', '0033_gatewayappbinding'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0034_backend_backendconfig.py b/src/dashboard/apigateway/apigateway/core/migrations/0035_backend_backendconfig.py similarity index 98% rename from src/dashboard/apigateway/apigateway/core/migrations/0034_backend_backendconfig.py rename to src/dashboard/apigateway/apigateway/core/migrations/0035_backend_backendconfig.py index 0ac63cd2c..6f46457b3 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0034_backend_backendconfig.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0035_backend_backendconfig.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0033_auto_20230818_1200'), + ('core', '0034_auto_20230818_1200'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0035_auto_20230824_1737.py b/src/dashboard/apigateway/apigateway/core/migrations/0036_auto_20230824_1737.py similarity index 97% rename from src/dashboard/apigateway/apigateway/core/migrations/0035_auto_20230824_1737.py rename to src/dashboard/apigateway/apigateway/core/migrations/0036_auto_20230824_1737.py index 2ab6ad713..dc93b706a 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0035_auto_20230824_1737.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0036_auto_20230824_1737.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0034_backend_backendconfig'), + ('core', '0035_backend_backendconfig'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0036_proxy_backend.py b/src/dashboard/apigateway/apigateway/core/migrations/0037_proxy_backend.py similarity index 96% rename from src/dashboard/apigateway/apigateway/core/migrations/0036_proxy_backend.py rename to src/dashboard/apigateway/apigateway/core/migrations/0037_proxy_backend.py index 6d0f1335e..fe0adbf8f 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0036_proxy_backend.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0037_proxy_backend.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0035_auto_20230824_1737'), + ('core', '0036_auto_20230824_1737'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0037_auto_20230902_1307.py b/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20230902_1307.py similarity index 98% rename from src/dashboard/apigateway/apigateway/core/migrations/0037_auto_20230902_1307.py rename to src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20230902_1307.py index 16fb28be9..26f5c2dac 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0037_auto_20230902_1307.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20230902_1307.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0036_proxy_backend'), + ('core', '0037_proxy_backend'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py b/src/dashboard/apigateway/apigateway/core/migrations/0039_auto_20231023_1526.py similarity index 97% rename from src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py rename to src/dashboard/apigateway/apigateway/core/migrations/0039_auto_20231023_1526.py index 71e4d9649..b58a7916c 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0039_auto_20231023_1526.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0037_auto_20230902_1307'), + ('core', '0038_auto_20230902_1307'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/models.py b/src/dashboard/apigateway/apigateway/core/models.py index b6cb467c5..128a90d7c 100644 --- a/src/dashboard/apigateway/apigateway/core/models.py +++ b/src/dashboard/apigateway/apigateway/core/models.py @@ -709,7 +709,10 @@ class Meta: class GatewayRelatedApp(TimestampedModelMixin): - """网关关联的蓝鲸应用""" + """ + 网关关联的蓝鲸应用 + - 应用可以通过 openapi 操作网关数据 + """ gateway = models.ForeignKey(Gateway, db_column="api_id", on_delete=models.CASCADE) bk_app_code = models.CharField(max_length=32, db_index=True) @@ -721,6 +724,23 @@ class Meta: db_table = "core_api_related_app" +class GatewayAppBinding(TimestampedModelMixin, OperatorModelMixin): + """ + 网关绑定的蓝鲸应用 + - 仅影响 HomePage 中运维开发分数的计算 + """ + + gateway = models.ForeignKey(Gateway, on_delete=models.CASCADE) + bk_app_code = models.CharField(max_length=32, db_index=True) + + def __str__(self): + return f"" + + class Meta: + db_table = "core_gateway_app_binding" + unique_together = ("gateway", "bk_app_code") + + # ============================================ gateway instance ============================================ diff --git a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py index 8212e62eb..13bf6a9ab 100644 --- a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py +++ b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py @@ -114,6 +114,7 @@ class TestGatewayCreateInputSLZ: "maintainers": ["guest"], "developers": ["t1", "t2"], "is_public": True, + "bk_app_codes": ["app1", "app2"], }, { "name": "test", @@ -121,6 +122,25 @@ class TestGatewayCreateInputSLZ: "maintainers": ["guest", "admin"], "developers": ["t1", "t2"], "is_public": True, + "bk_app_codes": ["app1", "app2"], + }, + ), + # ok, default value + ( + False, + { + "name": "test", + "description": "test", + "maintainers": ["guest"], + "is_public": True, + }, + { + "name": "test", + "description": "test", + "maintainers": ["guest", "admin"], + "developers": [], + "is_public": True, + "bk_app_codes": [], }, ), # name length < 3 @@ -232,6 +252,7 @@ def test_to_representation(self, fake_gateway, mocker): "docs_url": "http://apigw.demo.com/docs/", "public_key_fingerprint": calculate_fingerprint(jwt.public_key), "is_official": False, + "bk_app_codes": [], } assert slz.data == expected @@ -247,12 +268,14 @@ class TestGatewayUpdateInputSLZ: "developers": ["foo"], "description": "test", "is_public": True, + "bk_app_codes": ["app1", "app2"], }, { "maintainers": ["admin"], "developers": ["foo"], "description": "test", "is_public": True, + "bk_app_codes": ["app1", "app2"], }, ), # input include status @@ -268,6 +291,7 @@ class TestGatewayUpdateInputSLZ: "developers": [], "description": "test", "is_public": True, + "bk_app_codes": [], }, ), ], diff --git a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py index a36cfacea..96c1790e4 100644 --- a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py +++ b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py @@ -18,7 +18,7 @@ from apigateway.biz.gateway import GatewayHandler from apigateway.biz.gateway_jwt import GatewayJWTHandler from apigateway.core.constants import GatewayStatusEnum -from apigateway.core.models import JWT, Gateway, Stage +from apigateway.core.models import JWT, Gateway, GatewayAppBinding, Stage class TestGatewayListCreateApi: @@ -38,6 +38,7 @@ def test_create(self, request_view, faker, unique_gateway_name): "description": faker.pystr(), "maintainers": ["admin"], "is_public": False, + "bk_app_codes": ["app1"], } resp = request_view( @@ -53,6 +54,7 @@ def test_create(self, request_view, faker, unique_gateway_name): assert result["data"]["id"] == gateway.id assert Stage.objects.filter(gateway=gateway).exists() assert JWT.objects.filter(gateway=gateway).count() == 1 + assert GatewayAppBinding.objects.filter(gateway=gateway).count() == 1 class TestGatewayRetrieveUpdateDestroyApi: @@ -75,6 +77,7 @@ def test_update(self, request_view, faker, fake_gateway): "description": faker.pystr(), "maintainers": ["admin"], "is_public": faker.random_element([True, False]), + "bk_app_codes": ["app1"], } resp = request_view( method="PUT", @@ -87,6 +90,7 @@ def test_update(self, request_view, faker, fake_gateway): assert resp.status_code == 204 assert gateway.description == data["description"] assert gateway.is_public is data["is_public"] + assert GatewayAppBinding.objects.filter(gateway=gateway).count() == 1 def test_destroy(self, request_view, fake_gateway): fake_gateway.status = GatewayStatusEnum.INACTIVE.value diff --git a/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py b/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py index 8fe5bf5a8..e80e3a9bc 100644 --- a/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py +++ b/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py @@ -30,7 +30,16 @@ GatewayTypeEnum, StageStatusEnum, ) -from apigateway.core.models import JWT, Context, Gateway, GatewayRelatedApp, Release, Resource, Stage +from apigateway.core.models import ( + JWT, + Context, + Gateway, + GatewayAppBinding, + GatewayRelatedApp, + Release, + Resource, + Stage, +) class TestGatewayHandler: @@ -223,7 +232,7 @@ def test_save_related_data(self, mocker, fake_gateway): } ), ) - GatewayHandler.save_related_data(fake_gateway, "default", "admin", "test") + GatewayHandler.save_related_data(fake_gateway, "default", "admin", "test", app_codes_to_binding=["app1"]) assert Context.objects.filter( scope_type=ContextScopeTypeEnum.GATEWAY.value, @@ -235,6 +244,7 @@ def test_save_related_data(self, mocker, fake_gateway): assert Stage.objects.filter(gateway=fake_gateway).exists() assert AlarmStrategy.objects.filter(gateway=fake_gateway).exists() assert GatewayRelatedApp.objects.filter(gateway=fake_gateway, bk_app_code="test").exists() + assert GatewayAppBinding.objects.filter(gateway=fake_gateway).exists() def test_delete_gateway( self, diff --git a/src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py b/src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py new file mode 100644 index 000000000..a405d527f --- /dev/null +++ b/src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# +from apigateway.biz.gateway_app_binding import GatewayAppBindingHandler +from apigateway.core.models import GatewayAppBinding + + +class TestGatewayAppBindingHandler: + def test_update_gateway_app_bindings(self, fake_gateway): + GatewayAppBindingHandler.update_gateway_app_bindings(fake_gateway, ["app1", "app2"]) + assert GatewayAppBinding.objects.filter(gateway=fake_gateway).count() == 2 + + GatewayAppBindingHandler.update_gateway_app_bindings(fake_gateway, ["app3", "app2"]) + assert GatewayAppBinding.objects.filter(gateway=fake_gateway).count() == 2 + + GatewayAppBindingHandler.update_gateway_app_bindings(fake_gateway, ["app1"]) + assert GatewayAppBinding.objects.filter(gateway=fake_gateway).count() == 1 + + GatewayAppBindingHandler.update_gateway_app_bindings(fake_gateway, []) + assert GatewayAppBinding.objects.filter(gateway=fake_gateway).count() == 0 + + def test_get_bound_app_codes(self, fake_gateway): + GatewayAppBindingHandler.update_gateway_app_bindings(fake_gateway, ["app1", "app2"]) + result = GatewayAppBindingHandler.get_bound_app_codes(gateway=fake_gateway) + assert set(result) == {"app1", "app2"} From a397875cb032071795fd641469009f35c18d976f Mon Sep 17 00:00:00 2001 From: alex-smile <443677891@qq.com> Date: Tue, 7 Nov 2023 14:45:42 +0800 Subject: [PATCH 2/7] bk_app_codes required=False, not default list --- .../apigateway/apigateway/apis/web/gateway/serializers.py | 6 +++--- .../apigateway/apigateway/apis/web/gateway/views.py | 7 ++++--- .../apigateway/tests/apis/web/gateway/test_serializers.py | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py b/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py index c2e36c2c3..7f7c235ef 100644 --- a/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py +++ b/src/dashboard/apigateway/apigateway/apis/web/gateway/serializers.py @@ -85,7 +85,7 @@ class GatewayCreateInputSLZ(serializers.ModelSerializer): child=serializers.CharField(), allow_empty=True, default=list, help_text="网关开发者" ) bk_app_codes = serializers.ListField( - child=serializers.RegexField(APP_CODE_PATTERN), allow_empty=True, default=list, help_text="网关关联的应用" + child=serializers.RegexField(APP_CODE_PATTERN), allow_empty=True, required=False, help_text="网关关联的应用" ) class Meta: @@ -207,7 +207,7 @@ def get_is_official(self, obj): return GatewayTypeHandler.is_official(self.context["auth_config"].gateway_type) def get_bk_app_codes(self, obj): - return self.context.get("bk_app_codes", []) + return self.context["bk_app_codes"] class GatewayUpdateInputSLZ(serializers.ModelSerializer): @@ -216,7 +216,7 @@ class GatewayUpdateInputSLZ(serializers.ModelSerializer): child=serializers.CharField(), allow_empty=True, default=list, help_text="网关开发者" ) bk_app_codes = serializers.ListField( - child=serializers.RegexField(APP_CODE_PATTERN), allow_empty=True, default=list, help_text="网关关联的应用" + child=serializers.RegexField(APP_CODE_PATTERN), allow_empty=True, required=False, help_text="网关关联的应用" ) class Meta: diff --git a/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py b/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py index 3eed30215..66d526add 100644 --- a/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py +++ b/src/dashboard/apigateway/apigateway/apis/web/gateway/views.py @@ -105,7 +105,7 @@ def create(self, request, *args, **kwargs): slz = GatewayCreateInputSLZ(data=request.data, context={"created_by": request.user.username}) slz.is_valid(raise_exception=True) - bk_app_codes = slz.validated_data.pop("bk_app_codes") + bk_app_codes = slz.validated_data.pop("bk_app_codes", None) # 1. save gateway slz.save( @@ -191,11 +191,12 @@ def update(self, request, *args, **kwargs): slz = GatewayUpdateInputSLZ(instance=instance, data=request.data, partial=partial) slz.is_valid(raise_exception=True) - bk_app_codes = slz.validated_data.pop("bk_app_codes") + bk_app_codes = slz.validated_data.pop("bk_app_codes", None) slz.save(updated_by=request.user.username) - GatewayAppBindingHandler.update_gateway_app_bindings(instance, bk_app_codes) + if bk_app_codes is not None: + GatewayAppBindingHandler.update_gateway_app_bindings(instance, bk_app_codes) GatewayHandler.record_audit_log_success( username=request.user.username, diff --git a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py index 13bf6a9ab..a5ae71530 100644 --- a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py +++ b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py @@ -140,7 +140,6 @@ class TestGatewayCreateInputSLZ: "maintainers": ["guest", "admin"], "developers": [], "is_public": True, - "bk_app_codes": [], }, ), # name length < 3 @@ -291,7 +290,6 @@ class TestGatewayUpdateInputSLZ: "developers": [], "description": "test", "is_public": True, - "bk_app_codes": [], }, ), ], From 203e475df6854961004e3b3e83370d152db65344 Mon Sep 17 00:00:00 2001 From: alex-smile <443677891@qq.com> Date: Tue, 7 Nov 2023 15:24:51 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apigateway/apigateway/apis/open/gateway/serializers.py | 5 ++--- .../apigateway/tests/apis/web/gateway/test_serializers.py | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dashboard/apigateway/apigateway/apis/open/gateway/serializers.py b/src/dashboard/apigateway/apigateway/apis/open/gateway/serializers.py index f5739a04b..10b6853e5 100644 --- a/src/dashboard/apigateway/apigateway/apis/open/gateway/serializers.py +++ b/src/dashboard/apigateway/apigateway/apis/open/gateway/serializers.py @@ -55,9 +55,8 @@ def get_user_auth_type(self, obj): return self.context["gateway_auth_configs"][obj.id].user_auth_type def get_maintainers(self, obj): - # 网关对外的维护者,便于用户咨询网关问题,默认使用开发者;maintainers 为有权限管理网关的管理者 - # TODO: 是否应该使用开发者,如何让网关管理员知道开发者用于 API 文档中展示为网关的维护者 - return obj.developers or obj.maintainers + # TODO: 网关对外的维护者(助手号),便于用户咨询网关问题,需要单独使用一个新字段去维护? + return obj.maintainers class GatewayRetrieveV1OutputSLZ(GatewayListV1OutputSLZ): diff --git a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py index a5ae71530..b43cc57ad 100644 --- a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py +++ b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_serializers.py @@ -231,6 +231,7 @@ def test_to_representation(self, fake_gateway, mocker): gateway_type=GatewayTypeEnum.CLOUDS_API.value, allow_update_gateway_auth=True, ), + "bk_app_codes": [], }, ) jwt = GatewayJWTHandler.create_jwt(fake_gateway) From f3d6633864d107c95cb48ee6b803fee963aa7572 Mon Sep 17 00:00:00 2001 From: alex-smile <443677891@qq.com> Date: Wed, 8 Nov 2023 12:27:34 +0800 Subject: [PATCH 4/7] mv GatewayAppBinding to gateway module --- .../apigateway/apps/gateway/__init__.py | 0 .../apigateway/apps/gateway/admin.py | 29 ++++++++++++ .../apigateway/apps/gateway/apps.py | 22 +++++++++ .../apigateway/apps/gateway/models.py | 39 +++++++++++++++ .../migrations/0004_auto_20230901_1525.py | 2 +- .../migrations/0009_auto_20230902_1307.py | 2 +- .../migrations/0010_auto_20230902_1307.py | 2 +- .../migrations/0016_auto_20230818_1200.py | 2 +- .../migrations/0017_auto_20230901_1716.py | 2 +- .../apigateway/biz/gateway_app_binding.py | 3 +- .../apigateway/apigateway/conf/default.py | 1 + .../apigateway/apigateway/core/admin.py | 8 ---- ...818_1200.py => 0033_auto_20230818_1200.py} | 2 +- .../core/migrations/0033_gatewayappbinding.py | 47 ------------------- ...onfig.py => 0034_backend_backendconfig.py} | 2 +- ...824_1737.py => 0035_auto_20230824_1737.py} | 2 +- ...proxy_backend.py => 0036_proxy_backend.py} | 2 +- ...902_1307.py => 0037_auto_20230902_1307.py} | 2 +- ...023_1526.py => 0038_auto_20231023_1526.py} | 2 +- .../apigateway/apigateway/core/models.py | 17 ------- .../tests/apis/web/gateway/test_views.py | 3 +- .../tests/biz/gateway/test_gateway.py | 2 +- .../tests/biz/test_gateway_app_binding.py | 2 +- 23 files changed, 108 insertions(+), 87 deletions(-) create mode 100644 src/dashboard/apigateway/apigateway/apps/gateway/__init__.py create mode 100644 src/dashboard/apigateway/apigateway/apps/gateway/admin.py create mode 100644 src/dashboard/apigateway/apigateway/apps/gateway/apps.py create mode 100644 src/dashboard/apigateway/apigateway/apps/gateway/models.py rename src/dashboard/apigateway/apigateway/core/migrations/{0034_auto_20230818_1200.py => 0033_auto_20230818_1200.py} (99%) delete mode 100644 src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py rename src/dashboard/apigateway/apigateway/core/migrations/{0035_backend_backendconfig.py => 0034_backend_backendconfig.py} (98%) rename src/dashboard/apigateway/apigateway/core/migrations/{0036_auto_20230824_1737.py => 0035_auto_20230824_1737.py} (97%) rename src/dashboard/apigateway/apigateway/core/migrations/{0037_proxy_backend.py => 0036_proxy_backend.py} (96%) rename src/dashboard/apigateway/apigateway/core/migrations/{0038_auto_20230902_1307.py => 0037_auto_20230902_1307.py} (98%) rename src/dashboard/apigateway/apigateway/core/migrations/{0039_auto_20231023_1526.py => 0038_auto_20231023_1526.py} (97%) diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/__init__.py b/src/dashboard/apigateway/apigateway/apps/gateway/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/admin.py b/src/dashboard/apigateway/apigateway/apps/gateway/admin.py new file mode 100644 index 000000000..6ea25544f --- /dev/null +++ b/src/dashboard/apigateway/apigateway/apps/gateway/admin.py @@ -0,0 +1,29 @@ +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# +from django.contrib import admin + +from .models import GatewayAppBinding + + +class GatewayAppBindingAdmin(admin.ModelAdmin): + list_display = ["id", "gateway", "bk_app_code", "updated_time"] + search_fields = ["gateway__id", "bk_app_code"] + list_filter = ["gateway"] + + +admin.site.register(GatewayAppBinding, GatewayAppBindingAdmin) diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/apps.py b/src/dashboard/apigateway/apigateway/apps/gateway/apps.py new file mode 100644 index 000000000..d8a55cefc --- /dev/null +++ b/src/dashboard/apigateway/apigateway/apps/gateway/apps.py @@ -0,0 +1,22 @@ +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# +from django.apps import AppConfig + + +class GatewayConfig(AppConfig): + name = "apigateway.apps.gateway" diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/models.py b/src/dashboard/apigateway/apigateway/apps/gateway/models.py new file mode 100644 index 000000000..2d16a930f --- /dev/null +++ b/src/dashboard/apigateway/apigateway/apps/gateway/models.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# +from django.db import models + +from apigateway.common.mixins.models import OperatorModelMixin, TimestampedModelMixin +from apigateway.core.models import Gateway + + +class GatewayAppBinding(TimestampedModelMixin, OperatorModelMixin): + """ + 网关绑定的蓝鲸应用 + - 仅影响 HomePage 中运维开发分数的计算 + """ + + gateway = models.ForeignKey(Gateway, on_delete=models.CASCADE) + bk_app_code = models.CharField(max_length=32, db_index=True) + + def __str__(self): + return f"" + + class Meta: + db_table = "core_gateway_app_binding" + unique_together = ("gateway", "bk_app_code") diff --git a/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py b/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py index 7f43ad634..c5f0fd720 100644 --- a/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py +++ b/src/dashboard/apigateway/apigateway/apps/label/migrations/0004_auto_20230901_1525.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0037_proxy_backend'), + ('core', '0036_proxy_backend'), ('label', '0003_auto_20230227_2006'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py b/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py index 5a4b66e24..47bce3d9c 100644 --- a/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py +++ b/src/dashboard/apigateway/apigateway/apps/monitor/migrations/0009_auto_20230902_1307.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0038_auto_20230902_1307'), + ('core', '0037_auto_20230902_1307'), ('monitor', '0008_auto_20230227_2006'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py b/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py index 9e7bf1e25..4b7f02043 100644 --- a/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py +++ b/src/dashboard/apigateway/apigateway/apps/permission/migrations/0010_auto_20230902_1307.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0038_auto_20230902_1307'), + ('core', '0037_auto_20230902_1307'), ('permission', '0009_auto_20210219_2129'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py b/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py index cdd5ad222..e246861e0 100644 --- a/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py +++ b/src/dashboard/apigateway/apigateway/apps/support/migrations/0016_auto_20230818_1200.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0034_auto_20230818_1200'), + ('core', '0033_auto_20230818_1200'), ('support', '0015_auto_20230227_2006'), ] diff --git a/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py b/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py index fba9294b3..5e5c8d4d6 100644 --- a/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py +++ b/src/dashboard/apigateway/apigateway/apps/support/migrations/0017_auto_20230901_1716.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0037_proxy_backend'), + ('core', '0036_proxy_backend'), ('support', '0016_auto_20230818_1200'), ] diff --git a/src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py b/src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py index 5786517e1..e6bde578b 100644 --- a/src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py +++ b/src/dashboard/apigateway/apigateway/biz/gateway_app_binding.py @@ -18,7 +18,8 @@ # from typing import List -from apigateway.core.models import Gateway, GatewayAppBinding +from apigateway.apps.gateway.models import GatewayAppBinding +from apigateway.core.models import Gateway class GatewayAppBindingHandler: diff --git a/src/dashboard/apigateway/apigateway/conf/default.py b/src/dashboard/apigateway/apigateway/conf/default.py index 1b7eb5c97..2f79bd706 100644 --- a/src/dashboard/apigateway/apigateway/conf/default.py +++ b/src/dashboard/apigateway/apigateway/conf/default.py @@ -88,6 +88,7 @@ "apigateway.apps.monitor", "apigateway.schema", "apigateway.core", + "apigateway.apps.gateway", "apigateway.apps.access_strategy", "apigateway.apps.plugin", "apigateway.apps.label", diff --git a/src/dashboard/apigateway/apigateway/core/admin.py b/src/dashboard/apigateway/apigateway/core/admin.py index f867672c9..75c844504 100644 --- a/src/dashboard/apigateway/apigateway/core/admin.py +++ b/src/dashboard/apigateway/apigateway/core/admin.py @@ -25,7 +25,6 @@ BackendConfig, Context, Gateway, - GatewayAppBinding, GatewayRelatedApp, MicroGateway, MicroGatewayReleaseHistory, @@ -169,12 +168,6 @@ class SslCertificateBindingAdmin(admin.ModelAdmin): list_filter = ["gateway"] -class GatewayAppBindingAdmin(admin.ModelAdmin): - list_display = ["id", "gateway", "bk_app_code", "updated_time"] - search_fields = ["gateway__id", "bk_app_code"] - list_filter = ["gateway"] - - admin.site.register(Gateway, GatewayAdmin) admin.site.register(Stage, StageAdmin) admin.site.register(Resource, ResourceAdmin) @@ -194,4 +187,3 @@ class GatewayAppBindingAdmin(admin.ModelAdmin): admin.site.register(BackendConfig, BackendConfigAdmin) admin.site.register(SslCertificate, SslCertificateAdmin) admin.site.register(SslCertificateBinding, SslCertificateBindingAdmin) -admin.site.register(GatewayAppBinding, GatewayAppBindingAdmin) diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0034_auto_20230818_1200.py b/src/dashboard/apigateway/apigateway/core/migrations/0033_auto_20230818_1200.py similarity index 99% rename from src/dashboard/apigateway/apigateway/core/migrations/0034_auto_20230818_1200.py rename to src/dashboard/apigateway/apigateway/core/migrations/0033_auto_20230818_1200.py index ee828be8e..29bbe978a 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0034_auto_20230818_1200.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0033_auto_20230818_1200.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0033_gatewayappbinding'), + ('core', '0032_gateway__developers'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py b/src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py deleted file mode 100644 index 5deab8f79..000000000 --- a/src/dashboard/apigateway/apigateway/core/migrations/0033_gatewayappbinding.py +++ /dev/null @@ -1,47 +0,0 @@ -# -# TencentBlueKing is pleased to support the open source community by making -# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. -# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. -# Licensed under the MIT License (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# http://opensource.org/licenses/MIT -# -# Unless required by applicable law or agreed to in writing, software distributed under -# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific language governing permissions and -# limitations under the License. -# -# We undertake not to change the open source license (MIT license) applicable -# to the current version of the project delivered to anyone in the future. -# -# Generated by Django 3.2.18 on 2023-11-07 03:51 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0032_gateway__developers'), - ] - - operations = [ - migrations.CreateModel( - name='GatewayAppBinding', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created_time', models.DateTimeField(auto_now_add=True, null=True)), - ('updated_time', models.DateTimeField(auto_now=True, null=True)), - ('created_by', models.CharField(blank=True, max_length=32, null=True)), - ('updated_by', models.CharField(blank=True, max_length=32, null=True)), - ('bk_app_code', models.CharField(db_index=True, max_length=32)), - ('gateway', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.gateway')), - ], - options={ - 'db_table': 'core_gateway_app_binding', - 'unique_together': {('gateway', 'bk_app_code')}, - }, - ), - ] \ No newline at end of file diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0035_backend_backendconfig.py b/src/dashboard/apigateway/apigateway/core/migrations/0034_backend_backendconfig.py similarity index 98% rename from src/dashboard/apigateway/apigateway/core/migrations/0035_backend_backendconfig.py rename to src/dashboard/apigateway/apigateway/core/migrations/0034_backend_backendconfig.py index 6f46457b3..0ac63cd2c 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0035_backend_backendconfig.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0034_backend_backendconfig.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0034_auto_20230818_1200'), + ('core', '0033_auto_20230818_1200'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0036_auto_20230824_1737.py b/src/dashboard/apigateway/apigateway/core/migrations/0035_auto_20230824_1737.py similarity index 97% rename from src/dashboard/apigateway/apigateway/core/migrations/0036_auto_20230824_1737.py rename to src/dashboard/apigateway/apigateway/core/migrations/0035_auto_20230824_1737.py index dc93b706a..2ab6ad713 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0036_auto_20230824_1737.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0035_auto_20230824_1737.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0035_backend_backendconfig'), + ('core', '0034_backend_backendconfig'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0037_proxy_backend.py b/src/dashboard/apigateway/apigateway/core/migrations/0036_proxy_backend.py similarity index 96% rename from src/dashboard/apigateway/apigateway/core/migrations/0037_proxy_backend.py rename to src/dashboard/apigateway/apigateway/core/migrations/0036_proxy_backend.py index fe0adbf8f..6d0f1335e 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0037_proxy_backend.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0036_proxy_backend.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0036_auto_20230824_1737'), + ('core', '0035_auto_20230824_1737'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20230902_1307.py b/src/dashboard/apigateway/apigateway/core/migrations/0037_auto_20230902_1307.py similarity index 98% rename from src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20230902_1307.py rename to src/dashboard/apigateway/apigateway/core/migrations/0037_auto_20230902_1307.py index 26f5c2dac..16fb28be9 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20230902_1307.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0037_auto_20230902_1307.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0037_proxy_backend'), + ('core', '0036_proxy_backend'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0039_auto_20231023_1526.py b/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py similarity index 97% rename from src/dashboard/apigateway/apigateway/core/migrations/0039_auto_20231023_1526.py rename to src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py index b58a7916c..71e4d9649 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0039_auto_20231023_1526.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0038_auto_20230902_1307'), + ('core', '0037_auto_20230902_1307'), ] operations = [ diff --git a/src/dashboard/apigateway/apigateway/core/models.py b/src/dashboard/apigateway/apigateway/core/models.py index 128a90d7c..3493d3ba6 100644 --- a/src/dashboard/apigateway/apigateway/core/models.py +++ b/src/dashboard/apigateway/apigateway/core/models.py @@ -724,23 +724,6 @@ class Meta: db_table = "core_api_related_app" -class GatewayAppBinding(TimestampedModelMixin, OperatorModelMixin): - """ - 网关绑定的蓝鲸应用 - - 仅影响 HomePage 中运维开发分数的计算 - """ - - gateway = models.ForeignKey(Gateway, on_delete=models.CASCADE) - bk_app_code = models.CharField(max_length=32, db_index=True) - - def __str__(self): - return f"" - - class Meta: - db_table = "core_gateway_app_binding" - unique_together = ("gateway", "bk_app_code") - - # ============================================ gateway instance ============================================ diff --git a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py index 96c1790e4..a79004180 100644 --- a/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py +++ b/src/dashboard/apigateway/apigateway/tests/apis/web/gateway/test_views.py @@ -15,10 +15,11 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. # +from apigateway.apps.gateway.models import GatewayAppBinding from apigateway.biz.gateway import GatewayHandler from apigateway.biz.gateway_jwt import GatewayJWTHandler from apigateway.core.constants import GatewayStatusEnum -from apigateway.core.models import JWT, Gateway, GatewayAppBinding, Stage +from apigateway.core.models import JWT, Gateway, Stage class TestGatewayListCreateApi: diff --git a/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py b/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py index e80e3a9bc..97a6fb4a8 100644 --- a/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py +++ b/src/dashboard/apigateway/apigateway/tests/biz/gateway/test_gateway.py @@ -19,6 +19,7 @@ from django.core.exceptions import ObjectDoesNotExist from django_dynamic_fixture import G +from apigateway.apps.gateway.models import GatewayAppBinding from apigateway.apps.monitor.models import AlarmStrategy from apigateway.apps.support.models import ReleasedResourceDoc from apigateway.biz.gateway import GatewayHandler @@ -34,7 +35,6 @@ JWT, Context, Gateway, - GatewayAppBinding, GatewayRelatedApp, Release, Resource, diff --git a/src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py b/src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py index a405d527f..60b132e91 100644 --- a/src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py +++ b/src/dashboard/apigateway/apigateway/tests/biz/test_gateway_app_binding.py @@ -16,8 +16,8 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. # +from apigateway.apps.gateway.models import GatewayAppBinding from apigateway.biz.gateway_app_binding import GatewayAppBindingHandler -from apigateway.core.models import GatewayAppBinding class TestGatewayAppBindingHandler: From ca675caca729523d200d9a8fa3630f5a38e73599 Mon Sep 17 00:00:00 2001 From: alex-smile <443677891@qq.com> Date: Wed, 8 Nov 2023 12:35:19 +0800 Subject: [PATCH 5/7] add gateway migrations --- .../apps/gateway/migrations/0001_initial.py | 32 +++++++++++++++++++ .../apps/gateway/migrations/__init__.py | 0 .../apigateway/apps/gateway/models.py | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py create mode 100644 src/dashboard/apigateway/apigateway/apps/gateway/migrations/__init__.py diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py new file mode 100644 index 000000000..9224c8a10 --- /dev/null +++ b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 3.2.18 on 2023-11-08 04:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('core', '0038_auto_20231023_1526'), + ] + + operations = [ + migrations.CreateModel( + name='GatewayAppBinding', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_time', models.DateTimeField(auto_now_add=True, null=True)), + ('updated_time', models.DateTimeField(auto_now=True, null=True)), + ('created_by', models.CharField(blank=True, max_length=32, null=True)), + ('updated_by', models.CharField(blank=True, max_length=32, null=True)), + ('bk_app_code', models.CharField(db_index=True, max_length=32)), + ('gateway', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.gateway')), + ], + options={ + 'db_table': 'gateway_app_binding', + 'unique_together': {('gateway', 'bk_app_code')}, + }, + ), + ] diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/__init__.py b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/models.py b/src/dashboard/apigateway/apigateway/apps/gateway/models.py index 2d16a930f..20ddee7eb 100644 --- a/src/dashboard/apigateway/apigateway/apps/gateway/models.py +++ b/src/dashboard/apigateway/apigateway/apps/gateway/models.py @@ -35,5 +35,5 @@ def __str__(self): return f"" class Meta: - db_table = "core_gateway_app_binding" + db_table = "gateway_app_binding" unique_together = ("gateway", "bk_app_code") From a2a919ab63c874ba2a5e4895d6c8cd75a3940e0b Mon Sep 17 00:00:00 2001 From: alex-smile <443677891@qq.com> Date: Wed, 8 Nov 2023 12:38:54 +0800 Subject: [PATCH 6/7] add gateway migrations --- .../apigateway/apps/gateway/migrations/0001_initial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py index 9224c8a10..f6da69309 100644 --- a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py +++ b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py @@ -9,7 +9,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('core', '0038_auto_20231023_1526'), + ('core', '0032_gateway__developers'), ] operations = [ From 4f80edb74282408120500e17e7bed292c087a722 Mon Sep 17 00:00:00 2001 From: alex-smile <443677891@qq.com> Date: Wed, 8 Nov 2023 13:23:11 +0800 Subject: [PATCH 7/7] add license --- .../apigateway/apps/gateway/__init__.py | 17 +++++++++++++++++ .../apps/gateway/migrations/0001_initial.py | 17 +++++++++++++++++ .../apps/gateway/migrations/__init__.py | 17 +++++++++++++++++ .../core/migrations/0038_auto_20231023_1526.py | 17 +++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/__init__.py b/src/dashboard/apigateway/apigateway/apps/gateway/__init__.py index e69de29bb..2941673fe 100644 --- a/src/dashboard/apigateway/apigateway/apps/gateway/__init__.py +++ b/src/dashboard/apigateway/apigateway/apps/gateway/__init__.py @@ -0,0 +1,17 @@ +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py index f6da69309..2f7434290 100644 --- a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py +++ b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/0001_initial.py @@ -1,3 +1,20 @@ +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# # Generated by Django 3.2.18 on 2023-11-08 04:35 from django.db import migrations, models diff --git a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/__init__.py b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/__init__.py index e69de29bb..2941673fe 100644 --- a/src/dashboard/apigateway/apigateway/apps/gateway/migrations/__init__.py +++ b/src/dashboard/apigateway/apigateway/apps/gateway/migrations/__init__.py @@ -0,0 +1,17 @@ +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# diff --git a/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py b/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py index 71e4d9649..a12ac6606 100644 --- a/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py +++ b/src/dashboard/apigateway/apigateway/core/migrations/0038_auto_20231023_1526.py @@ -1,3 +1,20 @@ +# +# TencentBlueKing is pleased to support the open source community by making +# 蓝鲸智云 - API 网关(BlueKing - APIGateway) available. +# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +# Licensed under the MIT License (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://opensource.org/licenses/MIT +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# +# We undertake not to change the open source license (MIT license) applicable +# to the current version of the project delivered to anyone in the future. +# # Generated by Django 3.2.18 on 2023-10-23 07:26 from django.db import migrations, models