-
Notifications
You must be signed in to change notification settings - Fork 69
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
Showing
15 changed files
with
359 additions
and
12 deletions.
There are no files selected for viewing
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,41 @@ | ||
# -*- coding: utf-8 -*- | ||
# TencentBlueKing is pleased to support the open source community by making | ||
# 蓝鲸智云 - 用户管理 (bk-user) 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 functools import cached_property | ||
|
||
from rest_framework.exceptions import ValidationError | ||
from rest_framework.request import Request | ||
|
||
from bkuser.apis.apigw.authentications import InnerBearerTokenAuthentication | ||
from bkuser.apis.apigw.permissions import IsInnerBearerTokenAuthenticated | ||
|
||
|
||
class InnerApiCommonMixin: | ||
authentication_classes = [InnerBearerTokenAuthentication] | ||
permission_classes = [IsInnerBearerTokenAuthenticated] | ||
|
||
request: Request | ||
|
||
TenantHeaderKey = "HTTP_X_BK_TENANT_ID" | ||
|
||
@cached_property | ||
def tenant_id(self) -> str: | ||
tenant_id = self.request.META.get(self.TenantHeaderKey) | ||
|
||
if not tenant_id: | ||
raise ValidationError("X-Bk-Tenant-Id header is required") | ||
|
||
return tenant_id |
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,43 @@ | ||
# -*- coding: utf-8 -*- | ||
# TencentBlueKing is pleased to support the open source community by making | ||
# 蓝鲸智云 - 用户管理 (bk-user) 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 rest_framework import serializers | ||
|
||
from bkuser.apps.tenant.models import TenantUser | ||
from bkuser.biz.tenant import TenantUserHandler | ||
from bkuser.common.serializers import StringArrayField | ||
|
||
|
||
class TenantUserContactInfoListInputSLZ(serializers.Serializer): | ||
bk_usernames = StringArrayField(help_text="蓝鲸用户唯一标识,多个使用逗号分隔", max_items=100) | ||
|
||
|
||
class TenantUserContactInfoListOutputSLZ(serializers.Serializer): | ||
bk_username = serializers.CharField(help_text="蓝鲸用户唯一标识", source="id") | ||
tenant_id = serializers.CharField(help_text="租户 ID") | ||
display_name = serializers.SerializerMethodField(help_text="用户展示名称") | ||
phone = serializers.SerializerMethodField(help_text="手机号") | ||
phone_country_code = serializers.SerializerMethodField(help_text="手机国际区号") | ||
email = serializers.CharField(help_text="邮箱") | ||
|
||
def get_display_name(self, obj: TenantUser) -> str: | ||
return TenantUserHandler.generate_tenant_user_display_name(obj) | ||
|
||
def get_phone(self, obj: TenantUser) -> str: | ||
return obj.phone_info[0] | ||
|
||
def get_phone_country_code(self, obj: TenantUser) -> str: | ||
return obj.phone_info[1] |
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
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
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,47 @@ | ||
### Description | ||
|
||
(Pagination) Query user's list | ||
|
||
### Parameters | ||
|
||
| Name | Type | Required | Description | | ||
|-----------|------|----------|--------------------------------------------------------------| | ||
| page | int | No | Page number, default is 1 | | ||
| page_size | int | No | The number of pages per page, default is 10, maximum is 1000 | | ||
|
||
### Request Example | ||
|
||
``` | ||
// URL Query Parameters | ||
page=1&page_size=5 | ||
``` | ||
|
||
### Response Example for Status Code 200 | ||
|
||
```json5 | ||
{ | ||
"data": { | ||
"count": 2, | ||
"results": [ | ||
{ | ||
"bk_username": "q9k6bhqks0ckl5ew", | ||
"full_name": "张三", | ||
"display_name": "张三", | ||
}, | ||
{ | ||
"bk_username": "er0ugcammqwf1q5w", | ||
"full_name": "李四", | ||
"display_name": "李四", | ||
} | ||
], | ||
} | ||
} | ||
``` | ||
|
||
### Response Parameters Description | ||
|
||
| Name | Type | Description | | ||
|--------------|--------|-----------------------------------| | ||
| bk_username | string | Blueking user's unique identifier | | ||
| full_name | string | User's name | | ||
| display_name | string | User's display name | |
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,47 @@ | ||
### 描述 | ||
|
||
(分页)查询用户列表 | ||
|
||
### 输入参数 | ||
|
||
| 参数名称 | 参数类型 | 必选 | 描述 | | ||
|-----------|------|----|--------------------| | ||
| page | int | 否 | 页码,从 1 开始 | | ||
| page_size | int | 否 | 每页数量,默认 10,最大 1000 | | ||
|
||
### 请求示例 | ||
|
||
``` | ||
// URL Query 参数 | ||
page=1&page_size=5 | ||
``` | ||
|
||
### 状态码 200 的响应示例 | ||
|
||
```json5 | ||
{ | ||
"data": { | ||
"count": 2, | ||
"results": [ | ||
{ | ||
"bk_username": "q9k6bhqks0ckl5ew", | ||
"full_name": "张三", | ||
"display_name": "张三", | ||
}, | ||
{ | ||
"bk_username": "er0ugcammqwf1q5w", | ||
"full_name": "李四", | ||
"display_name": "李四", | ||
} | ||
], | ||
} | ||
} | ||
``` | ||
|
||
### 响应参数说明 | ||
|
||
| 参数名称 | 参数类型 | 描述 | | ||
|--------------|--------|----------| | ||
| bk_username | string | 蓝鲸用户唯一标识 | | ||
| full_name | string | 用户姓名 | | ||
| display_name | string | 用户展示名 | |
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
Oops, something went wrong.