-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67f424f
commit 0ab7e9c
Showing
16 changed files
with
462 additions
and
6 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/dashboard/apigateway/apigateway/apis/web/api_test/data_models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# 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 datetime import datetime | ||
from typing import Dict, Literal, Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class ApiDebugHistoryRequest(BaseModel): | ||
request_url: Optional[str] = Field(help="请求路由") | ||
request_method: Literal["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"] = Field( | ||
"GET", help="HTTP 方法,默认为GET" | ||
) | ||
type: Literal["HTTP", "GRPC", "WEBSOCKET"] = Field("HTTP", help="请求类型,默认为HTTP") | ||
authorization: Dict[str, str] = Field(None, help="认证信息") | ||
path_params: Dict[str, str] = Field({}, help="路径参数") | ||
query_params: Dict[str, str] = Field({}, help="查询参数") | ||
body: Optional[str] = Field(None, help="请求体") | ||
headers: Dict[str, str] = Field({}, help="请求头") | ||
subpath: Optional[str] = Field(None, help="子路径") | ||
use_test_app: bool = Field(False, help="是否使用测试应用") | ||
use_user_from_cookies: bool = Field(False, help="是否使用 cookies 中的用户信息") | ||
request_time: Optional[datetime] = Field(None, help="请求时间") | ||
spec_version: Optional[int] = Field(1, help="请求版本") | ||
|
||
|
||
class ApiDebugHistoryResponse(BaseModel): | ||
status_code: Optional[int] = Field(500, help="返回结果的状态码") | ||
proxy_time: float = Field(..., gt=0, help="处理时间,单位为秒,包含两位小数") | ||
body: Optional[str] = Field(None) | ||
spec_version: Optional[int] = Field(1, help="返回的结果版本") | ||
error: Optional[str] = Field(None, help="错误信息") | ||
|
||
# 格式化时间 | ||
def format_proxy_time(self) -> str: | ||
return f"{self.proxy_time:.2f}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/dashboard/apigateway/apigateway/apps/api_debug/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
# |
18 changes: 18 additions & 0 deletions
18
src/dashboard/apigateway/apigateway/apps/api_debug/admin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Register your models here. | ||
# | ||
# 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. | ||
# |
22 changes: 22 additions & 0 deletions
22
src/dashboard/apigateway/apigateway/apps/api_debug/apps.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 PermissionConfig(AppConfig): | ||
name = "apigateway.apps.api_debug" |
20 changes: 20 additions & 0 deletions
20
src/dashboard/apigateway/apigateway/apps/api_debug/constants.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. | ||
# | ||
API_TEST_METHOD_CHOICES = [("HTTP", "HTTP"), ("GRPC", "GRPC"), ("WEBSOCKET", "WEBSOCKET")] | ||
|
||
SPEC_VERSION = 1 |
37 changes: 37 additions & 0 deletions
37
src/dashboard/apigateway/apigateway/apps/api_debug/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Generated by Django 3.2.25 on 2024-07-26 02:51 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import jsonfield.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('core', '0040_auto_20240517_1422'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='APIDebugHistory', | ||
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)), | ||
('resource_name', models.CharField(help_text='资源名称', max_length=32)), | ||
('request', jsonfield.fields.JSONField(blank=True, help_text='请求参数')), | ||
('response', jsonfield.fields.JSONField(blank=True, help_text='返回结果')), | ||
('gateway', models.ForeignKey(db_column='gateway_id', on_delete=django.db.models.deletion.CASCADE, to='core.gateway')), | ||
('stage', models.ForeignKey(db_column='stage_id', on_delete=django.db.models.deletion.CASCADE, to='core.stage')), | ||
], | ||
options={ | ||
'verbose_name': 'APIDebugHistory', | ||
'verbose_name_plural': 'APIDebugHistory', | ||
'db_table': 'api_debug_history', | ||
}, | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
src/dashboard/apigateway/apigateway/apps/api_debug/migrations/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
# |
Oops, something went wrong.