鉴权
使用 AWS Sig v4 签名
创建 access key
MiniBase >= 2.11 可直接去控制台运维中心/系统配置-API 凭证中创建,< 2.11 需要联系运维同学手动创建
调用示例
Python3
pip install
*botocore*``~=1.21.64
import json
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
from botocore.credentials import Credentials
from botocore.httpsession import URLLib3Session
credential = Credentials("<access_key>", "<secret_key>")
siger = SigV4Auth(credential, "minibasebe", "pri")
session = URLLib3Session()
body = {"body": "test"}
req = AWSRequest(
method="POST",
url="http://minibase.tld/minibase/portal/openapi/v1/test",
headers={"X-Custom-Header": "somevalue"},
data=json.dumps(body),
params={"test_query": "test"},
)
siger.add_auth(req)
resp = session.send(req.prepare())
print(resp.headers)
print(resp.text)
Java
pom.xml
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
<version>2.16.60</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>auth</artifactId>
<version>2.16.60</version>
</dependency>
</dependencies>
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.signer.Aws4Signer;
import software.amazon.awssdk.auth.signer.params.Aws4SignerParams;
import software.amazon.awssdk.http.*;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.regions.Region;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
public class Demo {
public static void main(String[] args) {
AwsCredentials awsCreds = AwsBasicCredentials.create("<access_key>", "<secret_key>");
Aws4SignerParams signerParams = Aws4SignerParams.builder()
.awsCredentials(awsCreds)
.signingName("minibasebe")
.signingRegion(Region.of("pri"))
.build();
Aws4Signer signer = Aws4Signer.create();
SdkHttpClient c = ApacheHttpClient.create();
ContentStreamProvider content = new ContentStreamProviderImpl();
SdkHttpFullRequest r = SdkHttpFullRequest.builder()
.method(SdkHttpMethod.POST).protocol("http").host("minibase.tld").port(80)
.encodedPath("/minibase/portal/openapi/v1/test")
.appendRawQueryParameter("test_query", "test")
.appendHeader("X-Custom-Header", "somevalue")
.contentStreamProvider(content)
.build();
r = signer.sign(r, signerParams);
HttpExecuteRequest req = HttpExecuteRequest.builder().request(r).contentStreamProvider(content).build();
ExecutableHttpRequest executableReq = c.prepareRequest(req);
try {
HttpExecuteResponse resp = executableReq.call();
String result = new BufferedReader(new InputStreamReader(resp.responseBody().get())).lines()
.collect(Collectors.joining("\n"));
System.out.println(result);
} catch (IOException e) {
e.printStackTrace();
}
}
}
class ContentStreamProviderImpl implements ContentStreamProvider {
@Override
public InputStream newStream() {
return new ByteArrayInputStream("{\"body\":\"test\"}".getBytes(StandardCharsets.UTF_8));
}
}
Golang
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"time"
"github.com/aws/aws-sdk-go/aws/credentials"
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
)
func main() {
minibaseURL := url.URL{Scheme: "http", Host: "minibase.tld", Path: "/minibase/portal/openapi/v1/test"}
q := minibaseURL.Query()
q.Set("test_query", "test")
minibaseURL.RawQuery = q.Encode()
reqBodyJson := map[string]string{"body": "test"}
reqBody, _ := json.Marshal(reqBodyJson)
reqBodyReader := bytes.NewReader(reqBody)
req, _ := http.NewRequest(http.MethodPost, minibaseURL.String(), reqBodyReader)
req.Header.Set("X-Custom-Header", "somevalue")
signer := v4.NewSigner(credentials.NewStaticCredentials("<access_key>", "<secret_key>", ""))
signer.Sign(req, reqBodyReader, "minibasebe", "pri", time.Now())
resp, _ := http.DefaultClient.Do(req)
respBpdy, _ := io.ReadAll(resp.Body)
respBodyJson := new(map[string]any)
json.Unmarshal(respBpdy, respBodyJson)
fmt.Println(respBodyJson)
}
NodeJS (ES modules)
package.json
{
...
"dependencies": {
"@aws-crypto/sha256-js": "^4.0.0",
"@aws-sdk/node-http-handler": "^3.329.0",
"@aws-sdk/protocol-http": "^3.329.0",
"@aws-sdk/signature-v4": "^3.329.0"
},
...
}
TypeScript
import { Sha256 } from "@aws-crypto/sha256-js";
import { NodeHttpHandler } from "@aws-sdk/node-http-handler";
import { HttpRequest } from "@aws-sdk/protocol-http";
import { SignatureV4 } from "@aws-sdk/signature-v4";
import { IncomingMessage } from "http";
const signerInit = {
service: "minibasebe",
region: "pri",
sha256: Sha256,
credentials: {
accessKeyId: "<access_key>",
secretAccessKey: "<secret_key>",
},
};
const signer = new SignatureV4(signerInit);
const nodeHttpHandler = new NodeHttpHandler();
const hostname = "minibase.tld";
const port = 80;
const demoRequest = new HttpRequest({
method: "POST",
protocol: "http",
hostname: hostname,
port: port,
path: "/minibase/portal/openapi/v1/test",
headers: {
Host: `${hostname}:${port}`,
"X-Custom-Header": "somevalue",
},
query: {
test_query: "test",
},
body: JSON.stringify({ body: "test" }),
});
const signedRequest = (await signer.sign(demoRequest)) as HttpRequest;
const { response } = await nodeHttpHandler.handle(signedRequest);
const body = await ((body: IncomingMessage) => {
return new Promise((resolve, reject) => {
let buffer: Uint8Array[] = [];
body
.on("data", (chunk) => {
buffer.push(chunk);
})
.on("end", () => {
if (!body.complete) {
reject(new Error("The body failed to stream to the end."));
}
resolve(JSON.parse(Buffer.concat(buffer).toString()));
});
});
})(response.body);
console.log(body);
JavaScript
import { Sha256 } from "@aws-crypto/sha256-js";
import { NodeHttpHandler } from "@aws-sdk/node-http-handler";
import { HttpRequest } from "@aws-sdk/protocol-http";
import { SignatureV4 } from "@aws-sdk/signature-v4";
const signerInit = {
service: "minibasebe",
region: "pri",
sha256: Sha256,
credentials: {
accessKeyId: "<access_key>",
secretAccessKey: "<secret_key>",
},
};
const signer = new SignatureV4(signerInit);
const nodeHttpHandler = new NodeHttpHandler();
const hostname = "minibase.tld";
const port = 80;
const demoRequest = new HttpRequest({
method: "GET",
protocol: "http",
hostname: hostname,
port: port,
path: "/minibase/portal/openapi/v1/test",
headers: {
Host: `${hostname}:${port}`,
"X-Custom-Header": "somevalue",
},
query: {
test_query: "test",
},
body: JSON.stringify({ body: "test" }),
});
const signedRequest = (await signer.sign(demoRequest));
const { response } = await nodeHttpHandler.handle(signedRequest);
const body = await ((body) => {
return new Promise((resolve, reject) => {
let buffer = [];
body
.on("data", (chunk) => {
buffer.push(chunk);
})
.on("end", () => {
if (!body.complete) {
reject(new Error("The body failed to stream to the end."));
}
resolve(JSON.parse(Buffer.concat(buffer).toString()));
});
});
})(response.body);
console.log(body);
接口
1.获取所有集团
- Method: GET
- Path:
/minibase/portal/openapi/v1/orgs
- Path Params: 无
- Query: 无
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "success",
"data": [
{
"id": 1,
"name": "默认集团",
"creator_id": 1,
"users_count": 3,
"creator": {
"id": 1,
"last_login": "2021-10-20T14:43:10",
"is_superuser": true,
"status": 1,
"account": "admin",
"username": "admin123456789",
"email": null,
"mobile_number": null,
"avatar_url": "",
"current_org_id": 3,
"created_at": "2021-09-17T15:19:30",
"updated_at": "2021-10-20T14:43:10"
},
"created_at": "2021-09-17T15:19:30",
"updated_at": "2021-09-23T14:50:15"
},
{
"id": 3,
"name": "测试集团",
"creator_id": 1,
"users_count": 4,
"creator": {
"id": 1,
"last_login": "2021-10-20T14:43:10",
"is_superuser": true,
"status": 1,
"account": "admin",
"username": "admin123456789",
"email": null,
"mobile_number": null,
"avatar_url": "",
"current_org_id": 3,
"created_at": "2021-09-17T15:19:30",
"updated_at": "2021-10-20T14:43:10"
},
"created_at": "2021-09-26T19:22:44",
"updated_at": "2021-09-26T19:22:44"
}
]
}
2.获取指定集团下所有用户
- Method: GET
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/users
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
@since 1.9.0-广农信
name | required | type | desc |
---|
page | false | string | 不填写,则返回所有数据。从1开始 |
page_size | false | string | 不填写,则返回所有数据。 |
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "success",
"data": [
{
"id": 1,
"last_login": "2021-10-20T14:43:10",
"is_superuser": true,
"status": 1,
"account": "admin",
"username": "admin123456789",
"email": null,
"mobile_number": null,
"avatar_url": "",
"current_org_id": 3,
"created_at": "2021-09-17T15:19:30",
"updated_at": "2021-10-20T14:43:10"
},
{
"id": 17,
"last_login": "2021-10-14T17:37:23",
"is_superuser": false,
"status": 1,
"account": "guhui",
"username": "guhui",
"email": null,
"mobile_number": null,
"avatar_url": "",
"current_org_id": 1,
"created_at": "2021-10-08T15:38:31",
"updated_at": "2021-10-14T19:24:48"
}
]
}
3.搜索/获取所有用户
- Desc: Query 参数全部不传时返回所有用户,传多个时返回全部符合的用户,模糊匹配只对 account, username 生效
- Method: GET
- Path:
/minibase/portal/openapi/v1/users
- Path Params: 无
- Query:
name | required | type | desc |
---|
fuzzy | false | int | 0:完全匹配,1:模糊匹配(默认 0) |
user_ids | false | string | 获取制定 id 的用户:1,2,3 |
account | false | string | 使用账号搜索 |
username | false | string | 使用昵称搜索 |
is_superuser | false | int | 0:非超管,1:超管 |
product | false | string | 传这个字段则有对应产品的 extra |
sso_type | false | string | SSO 类型 |
sso_user_id | false | string | SSO 用户 ID |
with_sso | false | int | 0:不包含用户 SSO 信息,1:包含 |
page | false | string | 不填写,则返回所有数据。从1开始。@since 1.9.0-广农信 |
page_size | false | string | 不填写,则返回所有数据。
@since 1.9.0-广农信 |
with_custom_property | false | int | 1: 返回信息回信息附带自定义属性字段custom_properties
0:不返回相关字段 |
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "success",
"data": [
{
"id": 1, // 用户 id
"last_login": "2021-10-20T14:43:10", // 上次登录时间
"is_superuser": true, // 是否是超管
"status": 1, // 状态:1 启用、0 停用
"account": "admin", // 账号
"username": "admin123456789", // 姓名
"email": null, // 邮箱
"mobile_number": null, // 手机号
"avatar_url": "", // 头像
"current_org_id": 3, // 当前使用集团
"created_at": "2021-09-17T15:19:30",
"updated_at": "2021-10-20T14:43:10",
"ssos": [
{
"id": 6,
"user_id": 15,
"sso_type": "lark",
"sso_user_id": "22222"
}
],
"custom_property":{
"a":"1",
"b":["2","3"],
}
},
{
"id": 2,
"last_login": "2021-09-23T14:55:19",
"is_superuser": false,
"status": 1,
"account": "test1",
"username": "test1",
"email": null,
"mobile_number": null,
"avatar_url": "",
"current_org_id": 1,
"created_at": "2021-09-23T14:51:58",
"updated_at": "2021-09-29T14:01:46",
"ssos": [
{
"id": 6,
"user_id": 15,
"sso_type": "oauth2",
"sso_user_id": "33333"
}
]
"custom_property":{
"a":"1",
"b":["2","3"],
}
}
]
}
4.批量新建用户
- Method: POST
- Path:
/minibase/portal/openapi/v1/users
- Path Params: 无
- Query: 无
- Request Body:
[
{
"account": "user1", // 必填 账号
"username": "user1", // 必填 姓名
"password": "password1", // 必填 密码
"email": "admin@example.com", // 可选 邮箱
"mobile_number": "18888888888", // 可选 手机号
"status": 1, // 可选 状态:1 启用、0 停用
"custom_property":{ // 可选 自定义属性,属性key必须先在账号管理页面创建
"a":"1",
"b":["2","3"]
}
},
{
"account": "user2",
"username": "user2",
"password": "password2",
"email": "admin@example.com",
"mobile_number": "18888888888",
"status": 1
}
]
{
"code": 200,
"message": "success",
"data": [
{
"id": 24,
"last_login": null,
"is_superuser": false,
"status": 1,
"account": "user1",
"username": "user1",
"email": null,
"mobile_number": null,
"avatar_url": "",
"current_org_id": null,
"created_at": "2021-10-20T14:55:55.777",
"updated_at": "2021-10-20T14:55:55.777",
"custom_property":{
"a":"1",
"b":["2","3"]
}
},
{
"id": 25,
"last_login": null,
"is_superuser": false,
"status": 1,
"account": "user2",
"username": "user2",
"email": null,
"mobile_number": null,
"avatar_url": "",
"current_org_id": null,
"created_at": "2021-10-20T14:55:56.162",
"updated_at": "2021-10-20T14:55:56.162"
}
]
}
5.批量添加用户进集团
- Method: POST
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/users
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
{
"user_ids": [1, 2],
"accounts": ["user1", "user2"]
//以上user_id、accounts二选一
}
{
"code": 200,
"message": "success",
"data": null
}
6.修改指定用户
- Method: PATCH
- Path:
/minibase/portal/openapi/v1/users/{user_id}
(按照 user id 修改) - Path:
/minibase/portal/openapi/v1/users/account_{account}
(按照 account 修改) - Path Params:
name | type | desc |
---|
user_id | int | 用户 id |
account | string | 账号 |
所有参数可选,传了就修改,不传不修改
字段名 | 类型 | 示例 | 说明 |
---|
username | string | admin | 姓名 |
email | string | admin@example.com | 邮箱 |
password | string | password | 明文密码 |
mobile_number | string | 13888888888 | 手机号 |
status | int | 1 | 状态:1 启用、0 停用 |
custom_property | object | {
"a":"1",
"b":["2","3"],
}
| - >=2.12版本
- 自定义属性 只会更新已在页面定义过的自定义属性!
|
cp_action_type | string | add | |
{
"username": "admin", // 姓名
"email": "admin@example.com", // 邮箱
"password": "password", // 密码
"mobile_number": "18888888888", // 手机号
"status": 1 // 状态:1 启用、0 停用
"custom_property":{
"a":"1",
"b":["2","3"],
}, // >=2.12版本 自定义属性 只会更新已在页面定义过的自定义属性!
"cp_action_type":"add" // >=2.13版本. 自定义属性修改方式,默认为覆盖
}
Response Body:
{
"code": 200,
"message": "success",
"data": {
"id": 1,
"last_login": "2021-10-20T14:43:10",
"is_superuser": true,
"status": 1,
"account": "admin",
"username": "18888888888",
"email": "admin@example.com",
"mobile_number": null,
"avatar_url": "",
"current_org_id": 3,
"created_at": "2021-09-17T15:19:30",
"updated_at": "2021-10-20T15:09:18.044"
"a":"1", // >=2.12版本 自定义属性
"b":["2","3"], // >=2.12版本 自定义属性
}
}
用户不存在时
{
"code": 404,
"message": "USER_NOT_FOUND"
}
7.将用户移出集团
- Method: DELETE
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/users/{user_id}
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/users/account_{account}
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
user_id | int | 用户 id |
account | string | 账号 |
- Query: 无
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "success",
"data": null
}
8.创建角色
- Method: POST
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/roles
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
{
"child_ids": [ // 继承的角色 id
0
],
"description": "string", // 角色描述
"is_all_projects": true, // 开放全部项目(包括未来新建的)
"management_permissions": [ // 管理权限
"project_manage"
],
"name": "string", // 角色名称
"product_names": [ // 开放的产品
"DataFinder"
],
"project_ids": [ // 开放的项目 id
0
],
"subjects": [ // 角色成员(用户或用户组)
{
"id": 0, // type: user 时 id 或 account 任选一个,type: group 时必选
"account": "", // type: user 时 id 或 account 任选一个,type: group 时无此字段
"type": "user" // user or user_group
}
]
}
{
"code": 200,
"message": "success",
"data": {
"id": 1018,
"name": "test role 2",
"description": "test 2",
"is_preset": false,
"is_child": false,
"org": {
"id": 1,
"name": "test",
"creator": {
"origin_id": "",
"subject_type": 0,
"name": ""
}
},
"children": null,
"subjects": [
{
"type": "user",
"data": {
"id": 1,
"name": "",
"account": "admin",
"username": "ccc",
"avatar_url": "",
"description": ""
}
}
],
"permissions": []
}
}
9.创建集团
- Method: POST
- Path:
/minibase/portal/openapi/v1/orgs
- Path Params:无
- Query: 无
- Request Body:
{
"name": "xxx" // 集团名 xxx
}
{
"code": 200,
"message": "success",
"data": null
}
10.获取集团内所有角色
- Method: GET
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/roles
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
name | required | type | desc |
---|
include_subjects | false | boolean | 是否包含角色下的用户,不填写默认为true |
with_perms | false | boolean | 是否包含角色下的权限,不填写默认为true |
role_ids | false | string | 查询指定的角色id,用,隔开 |
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "success",
"data": [
{
"children": [],
"description": "string",
"id": 0,
"is_all_projects": true,
"management_permissions": [
"project_manage"
],
"name": "string",
"org": {
"creator": {
"name": "",
"origin_id": "",
"subject_type": 0
},
"name": "string"
},
"product_names": [
"DataFinder"
],
"project_ids": [
0
],
"subjects": [
{
"data": {
"account": "string",
"avatar_url": "string",
"description": "string",
"id": 0,
"name": "string",
"subject_count": 0,
"username": "string"
},
"type": "user"
}
]
}
]
}
11.修改角色
- Method: PATCH
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/roles/{role_id}
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
role_id | iint | 角色 id |
- Query: 无
- Request Body:
- 参数全部可选传入,不传即不修改
{
"child_ids": [ // 继承的角色 id
0
],
"description": "string", // 角色描述
"is_all_projects": true, // 开放全部项目(包括未来新建的)
"management_permissions": [ // 管理权限
"project_manage"
],
"name": "string", // 角色名称
"product_names": [ // 开放的产品
"DataFinder"
],
"project_ids": [ // 开放的项目 id
0
],
"subjects": [ // 角色成员(用户或用户组)
{
"id": 0, // id 或 account 任选一个
"account": "", // id 或 account 任选一个
"type": "user" // user or user_group
}
]
}
{
"code": 200,
"message": "success",
"data": null
}
12.向角色添加成员
- Method: POST
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/roles/{role_id}/subjects
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
role_id | int | 角色 id |
{
"subjects": [
{
"type": "user", // user or user_group
"id": 0, // id 或 account 任选一个
"account": ""
}
]
}
{
"code": 200,
"message": "success",
"data": null
}
13.从角色删除成员
- Method: DELETE
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/roles/{role_id}/subjects/users/{user_id}
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/roles/{role_id}/subjects/users/account_{account}
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
role_id | int | 角色 id |
user_id | int | 用户 id |
account | string | 账号 |
- Query: 无
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "success",
"data": null
}
- Method: PATCH
- Path:
/minibase/portal/openapi/v1/users/{user_id}/extra/{product_name}
- Path Params:
name | type | desc |
---|
user_id | int | 用户 id |
product_name | string | 产品名,如:datarangers |
{
...
}//需要patch的extra信息,任意json格式
{
"code": 200,
"message": "success",
"data": {}//该产品完整extra信息,任意json格式
}
- Method: GET
- Path:
/minibase/portal/openapi/v1/users/{user_id}/extra/{product_name}
- Path Params:
name | type | desc |
---|
user_id | int | 用户 id |
product_name | string | 产品名,如:datarangers |
{
"code": 200,
"message": "success",
"data": {}//该产品完整extra信息,任意json格式
}
- Method: DELETE
- Path:
/minibase/portal/openapi/v1/users/{user_id}/extra/{product_name}
- Path Params:
name | type | desc |
---|
user_id | int | 用户 id |
product_name | string | 产品名,如:datarangers |
{
...
}//需要delete的extra信息,删除body里存在字段,任意json格式
{
"code": 200,
"message": "success",
"data": {}//该产品完整extra信息,任意json格式
}
17.新增项目
- Method: POST
- Path:
/minibase/portal/openapi/v1/orgs/{orgId}/projects
- Path Params:
{
"name": "项目1",
"description": "项目1",
"extra": {
"event_usage": {"limit": 1000, "total": 999}
},
"product": "tester",
"is_permanent": false,
"started_at": "2022-04-19",
"expired_at": "2022-04-30"
}
参数名 | 参数说明 | 上级参数 | 是否必须 | 数据类型 | 备注 |
---|
name | 项目名称 | / | 是 | varchar(50) | |
description | 项目描述 | / | 是 | varchar(200) | |
extra | 额外参数 | / | 否 | object | |
event_usage | 事件配额使用信息 | extra | | object | |
limit | 时间量配额 | event_usage | | int | |
product | 产品 | / | 是 | varchar(20) | 云管平台传递的时候默认为"tester" |
is_permanent | 是否永久生效 | / | 是 | boolean | 项目是否永久生效 |
started_at | 项目生效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则started_at必传 |
expired_at | 项目失效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则expired_at必传 |
参数名 | 参数说明 | 上级参数 | 是否必须 | 数据类型 | 备注 |
---|
code | 响应编码 | / | 是 | int | 200代表成功响应。其他代表响应异常 |
message | 响应描述 | / | 是 | varchar | 响应描述 |
data | 响应内容 | / | 否 | object | 响应内容 |
name | 项目名称 | data | 是 | varchar(50) | |
description | 项目描述 | data | | varchar(200) | |
org_id | 所属集团 | data | 是 | int | |
resource_key | 资源key | data | 是 | varchar(200) | |
creator_id | 创建人员 | data | 是 | int | |
is_classified | 是否保密 | data | 是 | int | 云管平台对接不涉及 |
extra | 额外参数 | data | 否 | object | |
event_usage | 事件配额使用信息 | extra | | object | |
limit | 时间量配额 | event_usage | | int | |
create_at | 创建时间 | data | | varchar(20) | |
updated_at | 更新时间 | data | | varchar(20) | |
is_permanent | 是否永久生效 | data | 是 | boolean | 项目是否永久生效 |
started_at | 项目生效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则started_at必传 |
expired_at | 项目失效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则expired_at必传 |
18.修改项目信息
- Method: PATCH
- Path:
/minibase/portal/openapi/v1/project
s/{projectId} - Path Params:
name | type | desc |
---|
projectId | int | 项目 id |
{
"name": "项目1",
"description": "项目1",
"extra": {
"event_usage": {"limit": 1000, "total": 999}
},
"product": "tester",
"is_permanent": false,
"started_at": "2022-04-19",
"expired_at": "2022-04-30"
}
参数名 | 参数说明 | 上级参数 | 是否必须 | 数据类型 | 备注 |
---|
name | 项目名称 | / | 是 | varchar(50) | |
description | 项目描述 | / | | varchar(200) | |
extra | 额外参数 | / | 否 | object | |
event_usage | 事件配额使用信息 | extra | | object | |
limit | 时间量配额 | event_usage | | int | |
product | 产品 | / | 是 | varchar(20) | 云管平台传递的时候默认为"tester" |
is_permanent | 是否永久生效 | / | 是 | boolean | 项目是否永久生效 |
started_at | 项目生效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则started_at必传 |
expired_at | 项目失效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则expired_at必传 |
{
"message" : "success",
"data" : {
"id" : 3,
"description" : "项目122223232323444",
"is_classified" : false,
"extra" : "{\"tester\": {\"event_usage\": {\"limit\": 1000, \"total\": 999}}}",
"created_at" : "2022-05-09T21:57:37",
"is_permanent" : false,
"creator" : {
"id" : 1,
"mobile_number" : null,
"is_superuser" : true,
"current_org_id" : 1,
"current_project_id" : null,
"created_at" : "2022-05-06T21:51:57.739",
"super_id" : null,
"last_login" : "2022-05-09T21:01:37",
"updated_at" : "2022-05-09T21:01:37.337",
"username" : "test",
"volc_id" : "admin",
"account" : "admin",
"status" : 1,
"email" : null
},
"updated_at" : "2022-05-09T22:17:27.523",
"resource_key" : "minibase_portal_org_a95ff955-f3bb-4499-8b60-490c0aa711d4_project_cc8def93-f5d1-4690-98a7-20556a15f658",
"started_at" : "2022-04-19",
"expired_at" : "2022-04-30",
"creator_id" : 1,
"name" : "项目11",
"org_id" : 1
},
"code" : 200
}
参数名 | 参数说明 | 上级参数 | 是否必须 | 数据类型 | 备注 |
---|
code | 响应编码 | / | 是 | int | 200代表成功响应。其他代表响应异常 |
message | 响应描述 | / | 是 | varchar | 响应描述 |
data | 响应内容 | / | 否 | object | 响应内容 |
name | 项目名称 | data | 是 | varchar(50) | |
description | 项目描述 | data | | varchar(200) | |
org_id | 所属集团 | data | 是 | int | |
resource_key | 资源key | data | 是 | varchar(200) | |
creator_id | 创建人员 | data | 是 | int | |
is_classified | 是否保密 | data | 是 | int | 云管平台对接不涉及 |
extra | 额外参数 | data | 否 | object | |
event_usage | 事件配额使用信息 | extra | | object | |
limit | 时间量配额 | event_usage | | int | |
create_at | 创建时间 | data | | varchar(20) | |
updated_at | 更新时间 | data | | varchar(20) | |
is_permanent | 是否永久生效 | data | 是 | boolean | 项目是否永久生效 |
started_at | 项目生效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则started_at必传 |
expired_at | 项目失效时间 | / | 否 | varchar(20) | 如果is_permanent=0,则expired_at必传 |
19.获取项目
- Method: GET
- Path:
/minibase/portal/openapi/v1/projects/${project_id}
- Path Params:
name | type | desc |
---|
projectId | int | 项目 id |
{
"message" : "success",
"data" : {
"id" : 2,
"description" : "项目122223232323",
"is_classified" : false,
"extra" : "{\"tester\": {\"event_usage\": {\"limit\": 1000, \"total\": 999}}}",
"created_at" : "2022-05-09T20:58:30",
"is_permanent" : false,
"creator" : {
"id" : 1,
"mobile_number" : null,
"is_superuser" : true,
"current_org_id" : 1,
"current_project_id" : null,
"created_at" : "2022-05-06T21:51:57.739",
"super_id" : null,
"last_login" : "2022-05-09T21:01:37",
"updated_at" : "2022-05-09T21:01:37.337",
"username" : "test",
"volc_id" : "admin",
"account" : "admin",
"status" : 1,
"email" : null
},
"updated_at" : "2022-05-09T21:45:19",
"resource_key" : "minibase_portal_org_a95ff955-f3bb-4499-8b60-490c0aa711d4_project_0e51808f-915f-4243-903c-2a0cf61ef0f3",
"started_at" : "2022-04-19",
"expired_at" : "2022-04-30",
"creator_id" : 1,
"name" : "项目1",
"org_id" : 1
},
"code" : 200
}
20.用户绑定 SSO 接口
- 接口描述:已有的用户绑定 SSO。
- Method: POST
- Path:
/minibase/portal/openapi/v1/users/sso
- Query: 无
- Request Body:
{
"users": [
{
"user_id": 1, // 用户id:user_id
"account": "xxx", // 账号: account和user_id二选一
"sso_type":"", //必填sso_type:oidc,oauth2,lark,wecom,saml2,lark,jwt,custom
"sso_user_id":"", //必填
}
]
}
{
"code": 200,
"message": "success",
"data": null
}
21.获取集团根部门
- Method: GET
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/root
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
name | type | desc |
---|
with_children | bool | 获取子部门 |
recursively | bool | 递归获取子部门 |
with_users | bool | 获取部门中的用户 |
with_perms | bool | 获取部门拥有的权限 |
with_roles | bool | 获取部门所在的角色 |
{
"code": 200,
"message": "成功",
"data": {
"id": 1012,
"origin_id": "6df27b77-644f-4c0f-9777-f89c70d9ef1e",
"super_id": null,
"name": "字节跳动",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1013,
"origin_id": "d38b0cec-4815-4da0-bdec-1c4b1980c419",
"super_id": 1012,
"name": "火山引擎",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1014,
"origin_id": "968eec92-1ee9-44b5-9dc8-824d04b9cd4a",
"super_id": 1013,
"name": "数据平台",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1015,
"origin_id": "5d0a878b-9ff7-4410-85d5-454407caaef5",
"super_id": 1014,
"name": "前端",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1016,
"origin_id": "a0423738-6af5-4980-b219-d6bd43f4b2e0",
"super_id": 1015,
"name": "增长平台",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1040,
"origin_id": "a415d694-1882-480c-a981-7ffa7cd4d704",
"super_id": 1016,
"name": "业务架构",
"order": 0,
"org_id": 1,
"children": [],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
},
{
"id": 1041,
"origin_id": "caf134d6-9b26-4662-851d-c95b8f6f5e5c",
"super_id": 1016,
"name": "测试部门",
"order": 0,
"org_id": 1,
"children": [],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [
{
"id": 41,
"volc_id": "huqiang",
"super_id": "",
"account": "huqiang",
"username": "huqiang",
"status": 0,
"is_superuser": false,
"avatar_url": "/minio.minibase.avatar/6dbd9bcb1f7981f691dc01ab0585b8b56c1b1d240ca44413464e4f76.png",
"email": "",
"mobile_number": "",
"roles": null,
"groups": null,
"departments": null
}
],
"roles": [
{
"id": 1015,
"name": "role_003",
"description": "role_003"
}
],
"permissions": [
{
"res_key": "minibase_portal_org_d3327a67-01c3-49ab-9933-1584bc34363e_project_e56f5d17-6285-419f-9456-c023472a9609",
"actions": ["access"]
}
],
"perm_inherit": "to_super"
}
}
22.搜索/获取集团中的部门
- Method: GET
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
name | type | desc |
---|
with_children | bool | 获取子部门 |
recursively | bool | 递归获取子部门 |
with_users | bool | 获取部门中的用户 |
with_perms | bool | 获取部门拥有的权限 |
with_roles | bool | 获取部门所在的角色 |
q | string | 搜索 |
department_ids | array[int] | 指定部门 id 获取(逗号分隔) |
origin_ids | array[string] | 指定部门 origin id 获取(逗号分隔) |
{
"code": 200,
"message": "成功",
"data": [
{
"id": 1012,
"origin_id": "6df27b77-644f-4c0f-9777-f89c70d9ef1e",
"super_id": null,
"name": "字节跳动",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1013,
"origin_id": "d38b0cec-4815-4da0-bdec-1c4b1980c419",
"super_id": 1012,
"name": "火山引擎",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1014,
"origin_id": "968eec92-1ee9-44b5-9dc8-824d04b9cd4a",
"super_id": 1013,
"name": "数据平台",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1015,
"origin_id": "5d0a878b-9ff7-4410-85d5-454407caaef5",
"super_id": 1014,
"name": "前端",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1016,
"origin_id": "a0423738-6af5-4980-b219-d6bd43f4b2e0",
"super_id": 1015,
"name": "增长平台",
"order": 0,
"org_id": 1,
"children": [
{
"id": 1040,
"origin_id": "a415d694-1882-480c-a981-7ffa7cd4d704",
"super_id": 1016,
"name": "业务架构",
"order": 0,
"org_id": 1,
"children": [],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
},
{
"id": 1041,
"origin_id": "caf134d6-9b26-4662-851d-c95b8f6f5e5c",
"super_id": 1016,
"name": "测试部门",
"order": 0,
"org_id": 1,
"children": [],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [],
"roles": [],
"permissions": [],
"perm_inherit": "to_super"
}
],
"users": [
{
"id": 41,
"volc_id": "huqiang",
"super_id": "",
"account": "huqiang",
"username": "huqiang",
"status": 0,
"is_superuser": false,
"avatar_url": "",
"email": "",
"mobile_number": "",
"roles": null,
"groups": null,
"departments": null
}
],
"roles": [
{
"id": 1015,
"name": "role_003",
"description": "role_003"
}
],
"permissions": [
{
"res_key": "minibase_portal_org_d3327a67-01c3-49ab-9933-1584bc34363e_project_e56f5d17-6285-419f-9456-c023472a9609",
"actions": ["access"]
}
],
"perm_inherit": "to_super"
}
]
}
23.获取部门中的用户
- Method: GET
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/{department_id}/users
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/origin_id_{origin_id}/users
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
department_id | int | 部门 id |
name | type | desc |
---|
with_children | bool | 包括子部门中的用户 |
with_departments | bool | 获取用户所在的部门 |
q | string | 搜索 |
page | int | 页码 |
page_size | int | 每页个数 |
{
"code": 200,
"message": "成功",
"data": {
"total": 23,
"users": [
{
"id": 41,
"volc_id": "huqiang",
"super_id": "",
"account": "huqiang",
"username": "huqiang",
"status": 0,
"is_superuser": false,
"avatar_url": "",
"email": "",
"mobile_number": "",
"departments": [
{
"id": 1012,
"origin_id": "6df27b77-644f-4c0f-9777-f89c70d9ef1e",
"super_id": null,
"name": "字节跳动",
"order": 0,
"org_id": 1,
"perm_inherit": "to_super"
}
]
}
]
}
}
24.创建部门
- Method: POST
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
{
"name": "字节跳动",
"origin_id": "6df27b77-644f-4c0f-9777-f89c70d9ef1e",
"perm_inherit": "to_super",
"super_id": 1000
}
{
"code": 200,
"message": "成功",
"data": {
"id": 1012,
"origin_id": "6df27b77-644f-4c0f-9777-f89c70d9ef1e",
"super_id": 1000,
"name": "字节跳动",
"org_id": 1,
"perm_inherit": "to_super"
}
}
25.编辑部门
- Method: PATCH
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/{department_id}
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/origin_id_{origin_id}
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
department_id | int | 部门 id |
origin_id | string | 部门 origin id |
所有参数可选,传了就修改,不传不修改
{
"name": "string",
"perm_inherit": "to_children",
"super_id": null
}
{
"code": 200,
"message": "成功",
"data": {
"id": 1000,
"origin_id": "6df27b77-644f-4c0f-9777-f89c70d9ef1e",
"super_id": null,
"name": "string",
"org_id": 1,
"perm_inherit": "to_children"
}
}
26.向部门中添加用户
- Method: POST
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/{department_id}/users
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/origin_id_{origin_id}/users
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
department_id | int | 部门 id |
origin_id | string | 部门 origin id |
{
"accounts": ["admin", "test"],
"ids": [1, 2, 3]
}
{
"code": 200,
"message": "成功",
"data": null
}
27.从部门中移除用户
- Method: DELETE
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/{department_id}/users
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/origin_id_{origin_id}/users
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
department_id | int | 部门 id |
origin_id | string | 部门 origin id |
{
"accounts": ["admin", "test"],
"ids": [1, 2, 3]
}
{
"code": 200,
"message": "成功",
"data": null
}
28.删除部门
- Method: DELETE
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/{department_id}
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/departments/origin_id_{origin_id}
- Path Params:
name | type | desc |
---|
org_id | int | 集团 id |
department_id | int | 部门 id |
origin_id | string | 部门 origin id |
- Query: 无
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "成功",
"data": null
}
29.删除用户(>= 2.13)
- Method: DELETE
- Path:
/minibase/portal/openapi/v1/users/{user_id}
(按照 user id 删除) - Path:
/minibase/portal/openapi/v1/users/account_{account}
(按照 account 删除) - Path Params:
name | type | desc |
---|
user_id | int | 用户 id |
account | string | 账号 |
name | required | type | desc |
---|
handover_user_id | false | int | 交接人 id(id 与账号只传一个) |
handover_user_account | false | string | 交接人账号(id 与账号只传一个) |
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "成功",
"data": null
}
30.根据用户查询角色列表(>= 2.13)
- Method: GET
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/users/{user_id}/roles
(按照 集团id和用户id查询) - Path:
/minibase/portal/openapi/v1/orgs/{org_id}/users/account_{account}/roles
(按照账号查询) - Path:
/minibase/portal/openapi/v1/users/{user_id}/roles
(按照 用户id查询所有角色) - Path:
/minibase/portal/openapi/v1/users/account_{account}/roles
(按照账号查询) - Path Params:
name | type | desc |
---|
user_id | int | 用户 id |
org_id | int | 集团id |
account | string | 账号 |
name | required | type | desc |
---|
include_subjects | false | boolean | 是否包含角色下的用户,不填写默认为true |
with_perms | false | boolean | 是否包含角色下的权限,不填写默认为true |
- Request Body: 无
- Response Body: 无
31. 获取项目列表
{
"message" : "success",
"data" : [{
"id" : 2,
"description" : "项目122223232323",
"is_classified" : false,
"extra" : "{\"tester\": {\"event_usage\": {\"limit\": 1000, \"total\": 999}}}",
"created_at" : "2022-05-09T20:58:30",
"is_permanent" : false,
"creator" : {
"id" : 1,
"mobile_number" : null,
"is_superuser" : true,
"current_org_id" : 1,
"current_project_id" : null,
"created_at" : "2022-05-06T21:51:57.739",
"super_id" : null,
"last_login" : "2022-05-09T21:01:37",
"updated_at" : "2022-05-09T21:01:37.337",
"username" : "test",
"volc_id" : "admin",
"account" : "admin",
"status" : 1,
"email" : null
},
"updated_at" : "2022-05-09T21:45:19",
"resource_key" : "minibase_portal_org_a95ff955-f3bb-4499-8b60-490c0aa711d4_project_0e51808f-915f-4243-903c-2a0cf61ef0f3",
"started_at" : "2022-04-19",
"expired_at" : "2022-04-30",
"creator_id" : 1,
"name" : "项目1",
"org_id" : 1
}],
"code" : 200
}
32.删除项目(>= 2.16)
- Method: DELETE
- Path:
/minibase/portal/openapi/v1/orgs/{org_id}/projects/{project_id}
(按照 project id 删除) - Path Params:
name | type | desc |
---|
org_id | int | 集团id |
project_id | int | 用户 id |
- Request Body: 无
- Response Body:
{
"code": 200,
"message": "成功",
"data": null
}
33. 查询用户所属的部门(>= 2.17)
name | type | desc |
---|
org_id | int | 集团 id |
user_id | int | 用户 id |
account | string | 账号 |
{
"code": 200,
"message": "成功",
"data": [
{
"id": 1074,
"origin_id": "2671cfe1ee9d53gc",
"super_id": 1054,
"name": "PortalTest子部门1",
"order": 6000,
"org_id": 1
},
{
"id": 1083,
"origin_id": "1228186751d6gb3f",
"super_id": 1081,
"name": "PortalTest子部门1-1-1-1",
"order": 2000,
"org_id": 1
}
]
}