Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加租户集接口文档 #8333

Open
wants to merge 1 commit into
base: feature-tenant
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions docs/apidoc/apigw/backend/bk_apigw_resources_bk-cmdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13187,3 +13187,131 @@ paths:
userVerifiedRequired: false
disabledStages: []
descriptionEn:
/api/v3/findmany/tenant_set:
post:
operationId: list_tenant_set
description: 查询租户集
tags:
- tenant_set
responses:
default:
description: ''
x-bk-apigateway-resource:
isPublic: false
allowApplyPermission: true
matchSubpath: false
backend:
type: HTTP
method: post
path: /api/v3/findmany/tenant_set
matchSubpath: false
timeout: 0
upstreams: { }
transformHeaders: { }
pluginConfigs:
- type: bk-rate-limit
yaml: |
rates:
__default:
- period: 1
tokens: 100
authConfig:
userVerifiedRequired: false
disabledStages: [ ]
descriptionEn:
/api/v3/findmany/tenant_set/{tenant_set_id}/tenant:
post:
operationId: list_tenant_in_tenant_set
description: 查询租户集中的租户列表
tags:
- tenant_set
responses:
default:
description: ''
x-bk-apigateway-resource:
isPublic: false
allowApplyPermission: true
matchSubpath: false
backend:
type: HTTP
method: post
path: /api/v3/findmany/tenant_set/{tenant_set_id}/tenant
matchSubpath: false
timeout: 0
upstreams: { }
transformHeaders: { }
pluginConfigs:
- type: bk-rate-limit
yaml: |
rates:
__default:
- period: 1
tokens: 100
authConfig:
userVerifiedRequired: false
disabledStages: [ ]
descriptionEn:
/api/v3/findmany/tenant_set/{tenant_set_id}/tenant/{tenant_id}/biz:
post:
operationId: search_business_in_tenant_set
description: 查询租户集中的业务
tags:
- tenant_set
responses:
default:
description: ''
x-bk-apigateway-resource:
isPublic: false
allowApplyPermission: true
matchSubpath: false
backend:
type: HTTP
method: post
path: /api/v3/findmany/tenant_set/{tenant_set_id}/tenant/{tenant_id}/biz
matchSubpath: false
timeout: 0
upstreams: {}
transformHeaders: {}
pluginConfigs:
- type: bk-rate-limit
yaml: |
rates:
__default:
- period: 1
tokens: 100
authConfig:
userVerifiedRequired: false
disabledStages: []
descriptionEn:
/api/v3/findmany/tenant_set/{tenant_set_id}/tenant/{tenant_id}/biz/{bk_biz_id}/hosts:
post:
operationId: list_biz_hosts_in_tenant_set
description: 查询租户集中业务下的主机
tags:
- tenant_set
responses:
default:
description: ''
x-bk-apigateway-resource:
isPublic: false
allowApplyPermission: true
matchSubpath: false
backend:
type: HTTP
method: post
path: /api/v3/findmany/tenant_set/{tenant_set_id}/tenant/{tenant_id}/biz/{bk_biz_id}/hosts
matchSubpath: false
timeout: 0
upstreams: {}
transformHeaders: {}
pluginConfigs:
- type: bk-rate-limit
yaml: |
rates:
__default:
- period: 1
tokens: 100
authConfig:
userVerifiedRequired: false
disabledStages: []
descriptionEn:
209 changes: 209 additions & 0 deletions docs/apidoc/apigw/backend/zh/list_biz_hosts_in_tenant_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
### 描述

查询租户集中业务下的主机(版本:v3.15.1+,权限:租户集访问权限)

### 输入参数

| 参数名称 | 参数类型 | 必选 | 描述 |
|----------------------|--------|----|-----------------------------------------------------|
| tenant_set_id | int | 是 | 租户集id |
| tenant_id | string | 是 | 租户id |
| bk_biz_id | int | 是 | 业务id |
| page | object | 是 | 分页条件 |
| bk_set_ids | array | 否 | 集群ID列表,最多200条 **bk_set_ids和set_cond只能使用其中一个** |
| set_cond | array | 否 | 集群查询条件 **bk_set_ids和set_cond只能使用其中一个** |
| bk_module_ids | array | 否 | 模块ID列表,最多500条 **bk_module_ids和module_cond只能使用其中一个** |
| module_cond | array | 否 | 模块查询条件 **bk_module_ids和module_cond只能使用其中一个** |
| host_property_filter | object | 否 | 主机属性组合查询条件 |
| fields | array | 是 | 主机属性列表,控制返回结果的主机里有哪些字段,能够加速接口请求和减少网络流量传输 |

#### host_property_filter

该参数为主机属性字段过滤规则的组合,用于根据主机属性字段搜索主机。组合支持AND 和 OR 两种方式,可以嵌套,最多嵌套2层。
过滤规则为四元组 `field`, `operator`, `value`

| 参数名称 | 参数类型 | 必选 | 描述 |
|-----------|--------|----|--------|
| condition | string | 否 | 组合查询条件 |
| rules | array | 否 | 规则 |

#### rules

| 参数名称 | 参数类型 | 必选 | 描述 |
|----------|--------|----|---------------------------------------------------------------------------------------------------|
| field | string | 是 | 字段名 |
| operator | string | 是 | 操作符,可选值 equal,not_equal,in,not_in,less,less_or_equal,greater,greater_or_equal,between,not_between |
| value | - | 否 | 操作数,不同的operator对应不同的value格式 |

组装规则可参考: <https://github.com/Tencent/bk-cmdb/blob/master/src/common/querybuilder/README.md>

#### set_cond

| 参数名称 | 参数类型 | 必选 | 描述 |
|----------|--------|----|-------------------|
| field | string | 是 | 取值为集群的字段 |
| operator | string | 是 | 取值为:$eq $ne |
| value | string | 是 | field配置的集群字段所对应的值 |

#### module_cond

| 参数名称 | 参数类型 | 必选 | 描述 |
|----------|--------|----|-------------------|
| field | string | 是 | 取值为模块的字段 |
| operator | string | 是 | 取值为:$eq $ne |
| value | string | 是 | field配置的模块字段所对应的值 |

#### page

| 参数名称 | 参数类型 | 必选 | 描述 |
|-------|--------|----|--------------|
| start | int | 是 | 记录开始位置 |
| limit | int | 是 | 每页限制条数,最大500 |
| sort | string | 否 | 排序字段 |

### 调用示例

```json
{
"tenant_set_id": 1,
"tenant_id": "a",
"bk_biz_id": 3,
"page": {
"start": 0,
"limit": 10,
"sort": "bk_host_id"
},
"set_cond": [
{
"field": "bk_set_name",
"operator": "$eq",
"value": "set1"
}
],
"bk_module_ids": [
54,
56
],
"fields": [
"bk_host_id",
"bk_cloud_id",
"bk_host_innerip",
"bk_os_type",
"bk_mac"
],
"host_property_filter": {
"condition": "AND",
"rules": [
{
"field": "bk_host_innerip",
"operator": "equal",
"value": "127.0.0.1"
},
{
"condition": "OR",
"rules": [
{
"field": "bk_os_type",
"operator": "not_in",
"value": [
"3"
]
},
{
"field": "bk_cloud_id",
"operator": "equal",
"value": 0
}
]
}
]
}
}
```

### 响应示例

```json
{
"result": true,
"code": 0,
"message": "success",
"permission": null,
"data": {
"count": 2,
"info": [
{
"bk_cloud_id": 0,
"bk_host_id": 1,
"bk_host_innerip": "192.168.15.18",
"bk_mac": "",
"bk_os_type": null
},
{
"bk_cloud_id": 0,
"bk_host_id": 2,
"bk_host_innerip": "192.168.15.4",
"bk_mac": "",
"bk_os_type": null
}
]
}
}
```

### 响应参数说明

| 参数名称 | 参数类型 | 描述 |
|------------|--------|----------------------------|
| result | bool | 请求成功与否。true:请求成功;false请求失败 |
| code | int | 错误编码。 0表示success,>0表示失败错误 |
| message | string | 请求失败返回的错误信息 |
| permission | object | 权限信息 |
| data | object | 请求返回的数据 |

#### data

| 参数名称 | 参数类型 | 描述 |
|-------|-------|--------|
| count | int | 记录条数 |
| info | array | 主机实际数据 |

#### data.info

| 参数名称 | 参数类型 | 描述 |
|----------------------|--------|-------------------|
| bk_host_name | string | 主机名 |
| bk_host_innerip | string | 内网IP |
| bk_host_id | int | 主机ID |
| bk_cloud_id | int | 管控区域 |
| import_from | string | 主机导入来源,以api方式导入为3 |
| bk_asset_id | string | 固资编号 |
| bk_cloud_inst_id | string | 云主机实例ID |
| bk_cloud_vendor | string | 云厂商 |
| bk_cloud_host_status | string | 云主机状态 |
| bk_comment | string | 备注 |
| bk_cpu | int | CPU逻辑核心数 |
| bk_cpu_architecture | string | CPU架构 |
| bk_cpu_module | string | CPU型号 |
| bk_disk | int | 磁盘容量(GB) |
| bk_host_outerip | string | 主机外网IP |
| bk_host_innerip_v6 | string | 主机内网IPv6 |
| bk_host_outerip_v6 | string | 主机外网IPv6 |
| bk_isp_name | string | 所属运营商 |
| bk_mac | string | 主机内网MAC地址 |
| bk_mem | int | 主机名内存容量(MB) |
| bk_os_bit | string | 操作系统位数 |
| bk_os_name | string | 操作系统名称 |
| bk_os_type | string | 操作系统类型 |
| bk_os_version | string | 操作系统版本 |
| bk_outer_mac | string | 主机外网MAC地址 |
| bk_province_name | string | 所在省份 |
| bk_service_term | int | 质保年限 |
| bk_sla | string | SLA级别 |
| bk_sn | string | 设备SN |
| bk_state | string | 当前状态 |
| bk_state_name | string | 所在国家 |
| operator | string | 主要维护人 |
| bk_bak_operator | string | 备份维护人 |

**注意:此处的返回值仅对系统内置的属性字段做了说明,其余返回值取决于用户自己定义的属性字段**
44 changes: 44 additions & 0 deletions docs/apidoc/apigw/backend/zh/list_tenant_in_tenant_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### 描述

查询租户集中的租户(版本:v3.15.1+,权限:租户集访问权限)

### 输入参数

| 参数名称 | 参数类型 | 必选 | 描述 |
|---------------|------|----|-------|
| tenant_set_id | int | 是 | 租户集id |

### 调用示例

```json
{
"tenant_set_id": 1
}
```

### 响应示例

```json
{
"data": [
{
"id": "default",
"name": "Default",
"status": "enabled"
},
{
"id": "test",
"name": "Test",
"status": "disabled"
}
]
}
```

### 响应参数说明

| 参数名称 | 参数类型 | 描述 |
|--------|--------|---------------------------------|
| id | string | 租户 ID |
| name | string | 租户名 |
| status | string | 租户状态,enabled 表示启用,disabled 表示禁用 |
Loading