用户管理
属性¶
用户对象一般包含如下属性,新建、更新、查询时,需要根据情况设置或者获取这些信息。
metadata 参数于 v25.43.3 引入
| 参数 | 类型 | 说明 |
|---|---|---|
| uid | string | 用户唯一标识符 |
| status | int | 用户状态,0=已注销、1=正常、2=未激活、3=已休眠、4=已禁用 |
| username | string | 用户登录名,若创建用户时未声明,系统会自动生成 |
| phone | string | 用户手机号码 |
| string | 用户邮箱 | |
| nickname | string | 用户名称 |
| desc | string | 用户介绍 |
| role | int | 用户角色,1=业务用户、2=审计员、3=系统管理员,默认为业务用户 |
| tier | int | 用户等级,1=数据专家、2=全民数据科学家、3=全民数据探索家。未传递该参数则使用系统配置的默认用户等级 |
| type | int | 用户类型,0=临时用户、1=正式用户,默认为正式用户 |
| metadata | dict | 用户额外信息,存储用户自定义数据,单点登录和 IM 端会同步更新匹配到的字段值,可用于控制用户数据权限,以及基于工作区规则和工作区成员组规则加入工作区和成员组 |
username,phone 和 email 作为某一用户的唯一标识符,全局唯一,不能重复
接口¶
创建用户¶
POST /openapi/v1/accounts/
请求体:
{
"uid": "xxx",
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"password": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {},
}
参数说明
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| uid | string | 是 | 用户 uid,格式为 uuid4,不填写默认生成 |
| username | string | 否 | 用户登录名 |
| phone | string | 否 | 用户手机号码 |
| string | 否 | 用户邮箱 | |
| nickname | string | 否 | 用户名,用于显示 |
| desc | string | 否 | 用户介绍 |
| password | string | 否 | 用户登录密码,不设置表示禁止密码登录。如果需要密码登录,需用户自行或者联系系统管理员重设密码后,才能启用密码登录 |
| role | int | 否 | 用户角色,1=业务用户、2=审计员、3=系统管理员,默认为业务用户 |
| tier | int | 否 | 用户等级,1=数据专家、2=全民数据科学家、3=全民数据探索家。未传递该参数则使用系统配置的默认用户等级 |
| type | int | 否 | 用户类型,0=临时用户、1=正式用户,默认为正式用户 |
| metadata | dict | 否 | 用户额外信息 |
返回结果
{
"errcode": 200,
"errmsg": "success",
"data": {
"uid": "xxxxxxxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
}
批量创建用户¶
POST /openapi/v1/accounts/create-accounts/
请求体:
{
"accounts": [
{
"uid": "xxxxxxxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"password": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
},
{
"uid": "xxxxxxxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"password": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
]
}
参数说明
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| accounts | array | 是 | 用户信息数组,数据结构与单个创建用户相同 |
返回结果
{
"errcode": 200,
"errmsg": "success",
"data": [
{
"uid": "xxxxxxxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
},
{
"uid": "xxxxxxxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"password": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
]
}
更新用户¶
PUT /openapi/v1/accounts/{account_uid}/
请求体:
{
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"password": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
返回结果
{
"errcode": 200,
"errmsg": "success",
"data": {
"uid": "xxxxxxxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
}
批量更新用户¶
PUT /openapi/v1/accounts/update-accounts/
请求头:
{
"Authorization": "连接密钥"
}
请求体:
{
"accounts": [
{
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"password": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
},
{
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"password": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
]
}
返回结果
{
"errcode": 200,
"errmsg": "success",
"data": [
{
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
},
{
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
]
}
获取用户列表¶
GET /openapi/v1/accounts/
可以使用 q 参数,搜索登录名,用户名称,用户介绍,手机号或者邮箱。例如 /openapi/v1/accounts/?q=18812345678
返回结果
{
"errcode": 200,
"errmsg": "success",
"data": [
{
"uid": "xxxxxxxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxxxxx@xxxx",
"nickname": "xxxx",
"desc": "xxxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
]
}
获取用户¶
GET /openapi/v1/accounts/{account_uid}/
返回结果
{
"errcode": 200,
"errmsg": "success",
"data": {
"uid": "xxx",
"status": 1,
"username": "xxx",
"phone": "xxx",
"email": "xxx",
"nickname": "xxx",
"desc": "xxx",
"role": 1,
"tier": 1,
"type": 1,
"metadata": {}
}
}
根据标志符获取用户¶
POST /openapi/v1/accounts/fetch/
本接口在 v25.10 版本中引入
请求体:
{
"username": "用户的唯一标识符,可以是登录名、手机号或者邮箱"
}
返回结果
如果根据唯一标识符找到用户,返回用户信息。否则返回空
删除用户¶
DELETE /openapi/v1/accounts/{account_uid}/
返回结果
{
"errcode": 200,
"errmsg": "success"
}
批量删除用户¶
DELETE /openapi/v1/accounts/delete-accounts/
请求体:
{
"accountUids": [
"xxxx",
"xxxx"
]
}
返回结果
{
"errcode": 200,
"errmsg": "success"
}
获取单个用户的工作区列表¶
GET /openapi/v1/accounts/{account_uid}/projects/
请求体:
{
"role": 1,
"count": 1,
"offset": 0,
"limit": 10
}
参数说明
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| role | int | 否 | 用户角色,1=业务用户、2=审计员、3=系统管理员 |
| count | int | 否 | 查询总数 |
| offset | int | 是 | 偏移量 |
| limit | int | 是 | 查询条数 |
返回结果
{
"errcode": 200,
"errmsg": "success",
"data": [
{
"id": 1,
"name": "xxx",
"desc": "xxx",
"owner": {
"uid": "xxx",
"email": "xxx",
"nickname": "xxx",
"desc": "xxx",
"status": 1
},
"locked": true
}
]
}
参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作区编号 |
| name | string | 工作区名称 |
| desc | string | 工作区介绍 |
| owner.uid | string | 工作区负责人 uid |
| owner.email | string | 工作区负责人邮箱 |
| owner.nickname | string | 工作区负责人用户名 |
| owner.desc | string | 工作区负责人介绍 |
| owner.status | int | 工作区负责人状态 |
| locked | bool | 工作区是否可编辑 |