Skip to content

Commit

Permalink
Merge pull request #1090 from alex-smile/ft_esb_update_apis_20230612
Browse files Browse the repository at this point in the history
Ft esb update apis 20230612
  • Loading branch information
alex-smile authored Jun 12, 2023
2 parents c6e6bef + b2c2ea4 commit 8e4708e
Show file tree
Hide file tree
Showing 27 changed files with 1,288 additions and 50 deletions.
2 changes: 1 addition & 1 deletion paas2/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.14.49
2.14.50
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 @@ -48,4 +48,5 @@
"datalab": getattr(settings, "DATAV3_DATALABAPI_HOST", ""),
"aiops": getattr(settings, "DATAV3_AIOPSAPI_HOST", ""),
"resourcecenter": getattr(settings, "DATAV3_RESOURCECENTERAPI_HOST", ""),
"langserver": getattr(settings, "DATAV3_LANGSERVER_HOST", ""),
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The condition parameter is all the fields defined by the model corresponding to
"info": [
{
"bk_inst_id": 0,
"bk_inst_name": "default area",
"bk_inst_name": "Default Area",
"bk_supplier_account": "123456789"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ condition 参数为查询的目标实例对应的模型定义的所有字段
"info": [
{
"bk_inst_id": 0,
"bk_inst_name": "default area",
"bk_inst_name": "Default Area",
"bk_supplier_account": "123456789"
}
]
Expand Down
63 changes: 63 additions & 0 deletions paas2/esb/components/bk/apisv2/usermanage/fe_list_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- 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, SetupConfMixin
from .toolkit import configs


class FeListUsers(Component, SetupConfMixin):
suggest_method = "GET"
label = "fe list users"
label_en = "fe list users"

sys_name = configs.SYSTEM_NAME
api_type = API_TYPE_Q

def handle(self):
comp_obj = self.prepare_other(
"generic.v2.usermanage.usermanage_component",
kwargs=self.request.kwargs,
)
comp_obj.setup_conf(
{
"name": "fe_list_users",
"dest_http_method": "GET",
"dest_path": "/api/v2/profiles/",
}
)

result = comp_obj.invoke()

# 去除敏感信息
users = result["data"]
if isinstance(users, dict):
users = users.get("results", [])
elif not isinstance(users, list):
users = []

replaced_data_for_sensitive = {
"qq": "",
"email": "",
"telephone": "",
"wx_userid": "",
"password_valid_days": -1,
"account_expiration_date": "",
"create_time": "",
"update_time": "",
"extras": {},
}
for user in users:
for key, value in replaced_data_for_sensitive.items():
if key in user:
user[key] = value

self.response.payload = result
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- 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_OP
from components.component import Component, SetupConfMixin
from .toolkit import configs


class FeUpdateUserLanguage(Component, SetupConfMixin):
suggest_method = "PUT"
label = "切换用户语言"
label_en = "update user language"

sys_name = configs.SYSTEM_NAME
api_type = API_TYPE_OP

def handle(self):
comp_obj = self.prepare_other(
"generic.v2.usermanage.usermanage_component",
kwargs=self.request.kwargs,
)
comp_obj.setup_conf(
{
"name": "update_user_language",
"dest_path": "/api/v2/profiles/{id}/languages/".format(id=self.current_user.username),
"dest_http_method": "PUT",
}
)

self.response.payload = comp_obj.invoke()
151 changes: 151 additions & 0 deletions paas2/esb/components/confapis/bk_log/apidocs/en/fast_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
## [API] Fast Create (Easy way to create collector config)

fast_create

Path: /api/v1/databus/collectors/fast_create/

HTTP Method: `POST`, `application/json`

### Request Parameters


| Field | Type| Required | Description |
|-----------|------------|--------|-----------------------------------------------------------------------------------------------|
| bk_biz_id | Int | Yes| CC biz |
| collector_config_name | string | Yes| Name|
| collector_config_name_en | string | Yes| English name |
| collector_scenario_id | string | Yes| Scenario type, ENum: (row,section,wineventlog,custom) |
| data_link_id | string| No | Data link id |
| category_id | string | Yes | Category id, ENum: (os, application, host, other_rt)|
| target_object_type | string| Yes | ENum: SERVICE, HOST|
| target_node_type | string | Yes | ENum: TOPO, INSTANCE, SERVICE_TEMPLATE, SET_TEMPLATE, DYNAMIC_GROUP|
| target_nodes | list | No | See TargetNodes Params|
| data_encoding | string | No | Charset, Default UTF-8|
| description | string | No | Description |
| environment | string | No | ENum: linux, windows |
| params | dict | yes | See Plugins params |
| etl_config | string | No | ENum: bk_log_text, bk_log_json, bk_log_delimiter, bk_log_regexp, custom, default: bk_log_text |
| etl_params | dict | No | See ETL Params |
| fields | list | No | See ETL Fields params |
| storage_cluster_id | string| Yes | ES cluster id|
| retention | int | No | Data retention |
| allocation_min_days | int | No | Validity time of hot and cold data, default: 0|
| storage_replies | int | no | Replica count|
| es_shards | int | No | ES Shard count |


#### ETL Parameters


| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| separator_regexp | string | No | Regular expression |
| separator | string | No | separator |
| retain_original_text | bool | No | Remain the original text, default: True |


#### TargetNodes Parameters


| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| id | Int | No| Service instance id |
| bk_inst_id | id | No| Node instance id |
| bk_obj_id | string | No| Node instance object |
| ip | string | No| Host instance ip |
| bk_cloud_id | int | No| BK cloud id |
| bk_supplier_id | string | No| BK supplier id |



#### Plugin Param Parameters


| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| paths | list | No| log path |
| conditions | dict | No| See Plugin Condition params|

#### Plugin Condition Parameters


| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| type | string | Yes | Filter type, ENum: match, separator |
| match_type | string | No| Filter match type, Enum: include, exclude |
| match_content | string | No| Filter content |
| separator | string | No| separator |
| separator_filters | dict | No| See Plugin Condition Separator Filters params |


#### Plugin Condition Separator Filter Parameters

| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| fieldindex | string | Yes | Location of the match |
| word | string | Yes| Match the value |
| op | string | Yes | The matching way |
| logic_op | string | Yes | logic operator |


### Request Parameters Example

```json
{
"bk_biz_id": 1,
"collector_config_name": "20220729_88",
"collector_config_name_en": "20220729_en_88",
"collector_scenario_id": "row",
"category_id": "os",
"target_object_type": "HOST",
"target_node_type": "TOPO",
"target_nodes": [{"bk_inst_id": 2, "bk_obj_id": "biz"}],
"params": {
"paths": ["/var/log"],
"conditions": {
"type": "match"
}
},
"storage_cluster_id": 1,
"es_shards": 1,
"retention": 1
}
```

### Response Parameters

| Field | Type| Description|
| ------- | ------ | ------------ |
| result | bool| true or false|
| code | int | status code |
| message | string | error message returned when result is false |
| data | dict| log content |


### Response "data" fields

| Field| Type| Description|
| ------- | ------ | ------------ |
| collector_config_id | int| Collector config id |
| bk_data_id | int | BK Monitor data id |
| subscription_id | int | BKNode subscription id |
| task_id_list | list| BKNode task id list |


### Response Example

```json
{
"result": true,
"data": {
"collector_config_id": 1,
"bk_data_id": 1,
"subscription_id": 1,
"task_id_list": [
"1"
]
},
"code": 0,
"message": ""
}
```
116 changes: 116 additions & 0 deletions paas2/esb/components/confapis/bk_log/apidocs/en/fast_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
## [API] Fast Update (Easy way to update collector config)

fast_update

Path: /api/v1/databus/collectors/{collector_config_id}/fast_update/

HTTP Method: `POST`, `application/json`

### Request Parameters


| Field | Type| Required | Description |
|-----------|------------|--------|-----|
| collector_config_name | string | Yes| Name|
| target_nodes | list | No | See TargetNodes Params|
| description | string | No | Description |
| params | dict | yes | See Plugins params |
| etl_config | string | No | ENum: bk_log_text, bk_log_json, bk_log_delimiter, bk_log_regexp, custom, default: bk_log_text |
| etl_params | dict | No | See ETL Params |
| fields | list | No | See ETL Fields params |
| retention | int | No | Data retention |
| allocation_min_days | int | No | Validity time of hot and cold data, default: 0|
| storage_replies | int | no | Replica count|
| es_shards | int | No | ES Shard count |


#### ETL Parameters

| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| separator_regexp | string | No | Regular expression |
| separator | string | No | separator |
| retain_original_text | bool | No | Remain the original text, default: True |


#### TargetNodes Parameters

| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| id | Int | No| Service instance id |
| bk_inst_id | id | No| Node instance id |
| bk_obj_id | string | No| Node instance object |
| ip | string | No| Host instance ip |
| bk_cloud_id | int | No| BK cloud id |
| bk_supplier_id | string | No| BK supplier id |



#### Plugin Param Parameters

| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| paths | list | No| log path |
| conditions | dict | No| See Plugin Condition params|


#### Plugin Condition Parameters

| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| type | string | Yes | Filter type, ENum: match, separator |
| match_type | string | No| Filter match type, Enum: include, exclude |
| match_content | string | No| Filter content |
| separator | string | No| separator |
| separator_filters | dict | No| See Plugin Condition Separator Filters params |


#### Plugin Condition Separator Filter Parameters

| Field | Type| Required | Description |
|-----------|------------|--------|------------|
| fieldindex | string | Yes | Location of the match |
| word | string | Yes| Match the value |
| op | string | Yes | The matching way |
| logic_op | string | Yes | logic operator |


### Request Parameters Example

```json
{
"es_shards": 1,
"storage_replies": 1,
"description": "11111"
}
```

### Response Parameters

| Field | Type| Description|
| ------- | ------ | ------------ |
| result | bool| true or false|
| code | int | status code |
| message | string | error message returned when result is false |
| data | dict| log content |


### Response "data" fields

| Field| Type| Description|
| ------- | ------ | ------------ |
| collector_config_id | int| Collector config id |


### Response Example

```json
{
"result": true,
"data": {
"collector_config_id": 1,
},
"code": 0,
"message": ""
}
```
Loading

0 comments on commit 8e4708e

Please sign in to comment.