Skip to content

Commit

Permalink
Merge pull request #520 from alex-smile/ft_upgrade_merge_develop
Browse files Browse the repository at this point in the history
同步 develop 分支中代码
  • Loading branch information
wklken authored Sep 2, 2021
2 parents 3fdc9b6 + 0eab12a commit 1d8fa13
Show file tree
Hide file tree
Showing 138 changed files with 9,112 additions and 6,886 deletions.
2 changes: 1 addition & 1 deletion paas2/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.5
2.13.6
4 changes: 2 additions & 2 deletions paas2/esb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ poetry.lock: pyproject.toml
poetry lock --no-update

requirements_dev.txt: poetry.lock
poetry export -f requirements.txt --without-hashes --dev -o requirements_dev.txt
poetry export -f requirements.txt --without-hashes --dev | grep -v "index-url" > requirements_dev.txt

requirements.txt: poetry.lock requirements_dev.txt
poetry export -f requirements.txt --without-hashes -o requirements.txt
poetry export -f requirements.txt --without-hashes | grep -v "index-url" > requirements.txt

VERSION: pyproject.toml
poetry version | awk '{print $$2}' > VERSION
Expand Down
14 changes: 14 additions & 0 deletions paas2/esb/common/base_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
from common.log import logger


EMPTY_VALUES = (None, "", [], (), {})


class CustomJSONEncoder(json.JSONEncoder):
"""
JSONEncoder subclass that knows how to encode date/time and decimal types.
Expand Down Expand Up @@ -278,3 +281,14 @@ def html_escape(html, is_json=False):
html = html.replace('"', """)
html = html.replace("'", "'")
return html


def get_first_not_empty_value(data, keys, default=None):
"""
获取 keys 中第一个数据非空的字段数据
"""
for key in keys:
if data.get(key) not in EMPTY_VALUES:
return data[key]

return default
1 change: 1 addition & 0 deletions paas2/esb/components/bk/apis/data/toolkit/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@
"algorithm": getattr(settings, "DATAV3_ALGORITHMAPI_HOST", ""),
"queryengine": getattr(settings, "DATAV3_QUERYENGINEAPI_HOST", ""),
"datalab": getattr(settings, "DATAV3_DATALABAPI_HOST", ""),
"aiops": getattr(settings, "DATAV3_AIOPSAPI_HOST", ""),
}
33 changes: 33 additions & 0 deletions paas2/esb/components/bk/apis/esb/get_weixin_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS
Community Edition) available.
Copyright (C) 2017-2018 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.
"""

from common.constants import API_TYPE_Q
from components.component import Component
from esb.bkcore.models import ESBChannel

from .toolkit import configs


class GetWeixinConfig(Component):
""""""

sys_name = configs.SYSTEM_NAME
api_type = API_TYPE_Q

def handle(self):
wx_channel_path = "/cmsi/send_weixin/"
channel = ESBChannel.objects.filter(path=wx_channel_path).first()

self.response.payload = {
"result": True,
"data": channel.comp_conf_dict if channel else {},
}
11 changes: 11 additions & 0 deletions paas2/esb/components/bk/apisv2/bk_ssm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS
Community Edition) available.
Copyright (C) 2017-2018 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.
"""
11 changes: 11 additions & 0 deletions paas2/esb/components/bk/apisv2/bk_ssm/toolkit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS
Community Edition) available.
Copyright (C) 2017-2018 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.
"""
27 changes: 27 additions & 0 deletions paas2/esb/components/bk/apisv2/bk_ssm/toolkit/configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS
Community Edition) available.
Copyright (C) 2017-2018 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.
"""

from django.conf import settings

from esb.utils import SmartHost


SYSTEM_NAME = "BK_SSM"

headers = {
"x-bk-app-code": "bk_paas",
"x-bk-app-secret": settings.ESB_TOKEN,
}

host = SmartHost(
host_prod=getattr(settings, "BK_SSM_API_URL", "")
)
48 changes: 48 additions & 0 deletions paas2/esb/components/bk/apisv2/bk_ssm/verify_access_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS
Community Edition) available.
Copyright (C) 2017-2018 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.
"""
import json

from django import forms

from common.forms import BaseComponentForm
from common.constants import API_TYPE_OP, HTTP_METHOD
from components.component import Component
from .toolkit import configs


class VerifyAccessToken(Component):
suggest_method = HTTP_METHOD.POST
label = u"验证 AccessToken"
label_en = "verify access_token"

sys_name = configs.SYSTEM_NAME
api_type = API_TYPE_OP

class Form(BaseComponentForm):
access_token = forms.CharField(label="access token", required=True)

def handle(self):
result = self.outgoing.http_client.post(
host=configs.host,
path="/api/v1/auth/access-tokens/verify",
data=json.dumps(self.form_data),
headers=self._prepare_headers(),
)

result["result"] = result["code"] == 0

self.response.payload = result

def _prepare_headers(self):
headers = {"Content-Type": "application/json"}
headers.update(configs.headers)
return headers
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class TransferHostToResourcemodule(Component):
class Form(BaseComponentForm):
bk_biz_id = forms.IntegerField(label="business id", required=True)
bk_host_id = TypeCheckField(label="host id", promise_type=list, required=True)
bk_module_id = forms.IntegerField(label="module id", required=False)

def clean(self):
return self.get_cleaned_data_when_exist()

def handle(self):
client = tools.CCClient(self)
Expand Down
3 changes: 2 additions & 1 deletion paas2/esb/components/bk/apisv2/sops/sops_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def handle(self):
"Bk-App-Code": self.request.app_code,
},
)

try:
response["code"] = 0 if response["result"] else 1306000
response.setdefault("code", 0 if response["result"] else 1306000)
except Exception:
raise error_codes.THIRD_PARTY_RESULT_ERROR.format_prompt(args=configs.SYSTEM_NAME)

Expand Down
1 change: 1 addition & 0 deletions paas2/esb/components/bk/apisv2/usermanage/fs_list_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def _get_list_users_params(self):
"domain",
"category_id",
"logo",
"staff_status",
]
),
}
Expand Down
154 changes: 154 additions & 0 deletions paas2/esb/components/confapis/bk_log/bk_log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
dest_http_method: POST
is_hidden: True

- path: /v2/bk_log/esquery_monitor/
name: esquery_monitor
label: 日志平台索引集查询接口
label_en: bk_log index-set search api for bkmonitor
method: POST
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/esquery/search/
dest_http_method: POST
is_hidden: True

- path: /v2/bk_log/esquery_dsl/
name: esquery_dsl
label: ES-DSL查询接口
Expand Down Expand Up @@ -112,6 +123,28 @@
dest_http_method: GET
is_hidden: True

- path: /v2/bk_log/search_index_set/{index_set_id}/context/
name: search_context
label: 日志平台-检索-上下文
label_en: bk_log search context
method: POST
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/search/index_set/{index_set_id}/context/
dest_http_method: POST
is_hidden: True

- path: /v2/bk_log/search_index_set/{index_set_id}/tailf/
name: search_tailf
label: 日志平台-检索-实时日志
label_en: bk_log search tail
method: POST
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/search/index_set/{index_set_id}/tailf/
dest_http_method: POST
is_hidden: True

- path: /v2/bk_log/create_index_set/
name: create_index_set
label: 日志平台-创建索引集
Expand Down Expand Up @@ -155,3 +188,124 @@
dest_path: /api/v1/databus/collectors/{collector_config_id}/tail/
dest_http_method: GET
is_hidden: True

- path: /v2/bk_log/databus_collectors/
name: create_databus_collectors
label: 日志平台-创建采集项
label_en: bk_log create collector
method: POST
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/collectors/
dest_http_method: POST
is_hidden: True

- path: /v2/bk_log/databus_collectors/
name: update_databus_collectors
label: 日志平台-更新采集项
label_en: bk_log update collector
method: PUT
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/collectors/
dest_http_method: PUT
is_hidden: True

- path: /v2/bk_log/databus_collectors/
name: list_databus_collectors
label: 日志平台-采集项列表
label_en: bk_log list collector
method: GET
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/collectors/
dest_http_method: GET
is_hidden: True

- path: /v2/bk_log/databus_collectors/{collector_config_id}/
name: retrieve_databus_collector
label: 日志平台-获取采集项详情
label_en: bk_log get collector info
method: GET
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/collectors/{collector_config_id}/
dest_http_method: GET
is_hidden: True

- path: /v2/bk_log/databus_collectors/{collector_config_id}/update_or_create_clean_config/
name: databus_collectors_replace_clean_config
label: 日志平台-清洗入库
label_en: bk_log collector clean config
method: POST
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/collectors/{collector_config_id}/update_or_create_clean_config/
dest_http_method: POST
is_hidden: True

- path: /v2/bk_log/databus_collectors/list_collectors_by_host/
name: list_collectors_by_host
label: 日志平台-根据IP获取采集项列表
label_en: bk_log list collector by host
method: GET
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/collectors/list_collectors_by_host/
dest_http_method: GET
is_hidden: True

- path: /v2/bk_log/databus_storage/
name: list_databus_storage
label: 日志平台-存储列表
label_en: bk_log list databus storage
method: GET
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/storage/
dest_http_method: GET
is_hidden: True

- path: /v2/bk_log/databus_storage/{cluster_id}/
name: get_databus_storage
label: 日志平台-存储详情
label_en: bk_log get databus storage
method: GET
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/storage/{cluster_id}/
dest_http_method: GET
is_hidden: True

- path: /v2/bk_log/databus_storage/
name: create_databus_storage
label: 日志平台-创建存储
label_en: bk_log create databus storage
method: POST
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/storage/
dest_http_method: POST
is_hidden: True

- path: /v2/bk_log/databus_storage/
name: update_databus_storage
label: 日志平台-更新存储
label_en: bk_log update databus storage
method: PUT
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/storage/
dest_http_method: PUT
is_hidden: True

- path: /v2/bk_log/databus_storage/connectivity_detect/
name: databus_storage_connectivity_detect
label: 日志平台-连通性测试
label_en: bk_log es connectivity detect
method: POST
api_type: query
comp_codename: generic.v2.bk_log.bk_log_component
dest_path: /api/v1/databus/storage/connectivity_detect/
dest_http_method: POST
is_hidden: True
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ create object attribute
"ispre": false,
"isreadonly": false,
"isrequired": false,
"option": {"min":"1","max":"2"},
"option": "",
"unit": "1",
"placeholder": "test",
"bk_property_group": "default",
Expand Down
Loading

0 comments on commit 1d8fa13

Please sign in to comment.