You need to enable JavaScript to run this app.
导航
OpenAPI接口文档
最近更新时间:2024.11.04 11:08:14首次发布时间:2023.09.18 17:03:24
鉴权

使用 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:
nametypedesc
org_idint集团 id
  • Query:

@since 1.9.0-广农信

namerequiredtypedesc
pagefalsestring不填写,则返回所有数据。从1开始
page_sizefalsestring不填写,则返回所有数据。
  • 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:
namerequiredtypedesc
fuzzyfalseint0:完全匹配,1:模糊匹配(默认 0)
user_idsfalsestring获取制定 id 的用户:1,2,3
accountfalsestring使用账号搜索
usernamefalsestring使用昵称搜索
is_superuserfalseint0:非超管,1:超管
productfalsestring传这个字段则有对应产品的 extra
sso_typefalsestringSSO 类型
sso_user_idfalsestringSSO 用户 ID
with_ssofalseint0:不包含用户 SSO 信息,1:包含
pagefalsestring不填写,则返回所有数据。从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
    }
]
  • Response Body:
{
    "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:
nametypedesc
org_idint集团 id
  • Query: 无
  • Request Body:
{
  "user_ids": [1, 2],
  "accounts": ["user1", "user2"] 
  //以上user_id、accounts二选一
}
  • Response Body:
{
    "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:
nametypedesc
user_idint用户 id
accountstring账号
  • Query: 无
  • Request Body:

所有参数可选,传了就修改,不传不修改

字段名类型示例说明
usernamestringadmin姓名
emailstringadmin@example.com邮箱
passwordstringpassword明文密码
mobile_numberstring13888888888手机号
statusint1状态:1 启用、0 停用

custom_property

object

{
    "a":"1",
    "b":["2","3"],
}
  • >=2.12版本
  • 自定义属性 只会更新已在页面定义过的自定义属性!

cp_action_type

string

add

  • >=2.13版本
  • 自定义属性修改方式,默认为覆盖
{
    "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:
nametypedesc
org_idint集团 id
user_idint用户 id
accountstring账号
  • 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:
nametypedesc
org_idint集团 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,  // type: user 时 id 或 account 任选一个,type: group 时必选
      "account": "",  // type: user 时 id 或 account 任选一个,type: group 时无此字段
      "type": "user"  // user or user_group
    }
  ]
}
  • Response Body:
{
    "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
}
  • Response Body:
{
  "code":  200,
  "message": "success",
  "data":  null
}

10.获取集团内所有角色

  • Method: GET
  • Path: /minibase/portal/openapi/v1/orgs/{org_id}/roles
  • Path Params:
nametypedesc
org_idint集团 id
  • Query:
namerequiredtypedesc
include_subjectsfalseboolean是否包含角色下的用户,不填写默认为true
with_permsfalseboolean是否包含角色下的权限,不填写默认为true
role_idsfalsestring查询指定的角色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:
nametypedesc
org_idint集团 id
role_idiint角色 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
    }
  ]
}
  • Response Body:
{
  "code":  200,
  "message": "success",
  "data":  null
}

12.向角色添加成员

  • Method: POST
  • Path: /minibase/portal/openapi/v1/orgs/{org_id}/roles/{role_id}/subjects
  • Path Params:
nametypedesc
org_idint集团 id
role_idint角色 id
  • Query: 无
  • Request Body:
{
  "subjects": [
    {
      "type": "user",  // user or user_group
      "id": 0,  // id 或 account 任选一个
      "account": ""
    }
  ]
}
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
role_idint角色 id
user_idint用户 id
accountstring账号
  • Query: 无
  • Request Body: 无
  • Response Body:
{
  "code":  200,
  "message": "success",
  "data":  null
}

14.修改用户extra信息

  • Method: PATCH
  • Path: /minibase/portal/openapi/v1/users/{user_id}/extra/{product_name}
  • Path Params:
nametypedesc
user_idint用户 id
product_namestring产品名,如:datarangers
  • Query: 无
  • Request Body:
{
...
}//需要patch的extra信息,任意json格式
  • Response Body:
{
  "code":  200,
  "message": "success",
  "data":  {}//该产品完整extra信息,任意json格式
}

15.获取用户extra信息

  • Method: GET
  • Path: /minibase/portal/openapi/v1/users/{user_id}/extra/{product_name}
  • Path Params:
nametypedesc
user_idint用户 id
product_namestring产品名,如:datarangers
  • Query: 无
  • Response Body:
{
  "code":  200,
  "message": "success",
  "data":  {}//该产品完整extra信息,任意json格式
}

16.删除用户extra信息

  • Method: DELETE
  • Path: /minibase/portal/openapi/v1/users/{user_id}/extra/{product_name}
  • Path Params:
nametypedesc
user_idint用户 id
product_namestring产品名,如:datarangers
  • Query: 无
  • Request Body:
{
...
}//需要delete的extra信息,删除body里存在字段,任意json格式
  • Response Body:
{
  "code":  200,
  "message": "success",
  "data":  {}//该产品完整extra信息,任意json格式
}

17.新增项目

  • Method: POST
  • Path: /minibase/portal/openapi/v1/orgs/{orgId}/projects
  • Path Params:
字段名字段描述类型
orgId集团IDintÅ
  • Query: 无
  • Request Body:
{
  "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"
}
  • Request Body参数说明:
参数名参数说明上级参数是否必须数据类型备注
name项目名称/varchar(50)
description项目描述/varchar(200)
extra额外参数/object
event_usage事件配额使用信息extraobject
limit时间量配额event_usageint
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必传
  • Response Body参数说明:
参数名参数说明上级参数是否必须数据类型备注
code响应编码/int200代表成功响应。其他代表响应异常
message响应描述/varchar响应描述
data响应内容/object响应内容
name项目名称datavarchar(50)
description项目描述datavarchar(200)
org_id所属集团dataint
resource_key资源keydatavarchar(200)
creator_id创建人员dataint
is_classified是否保密dataint云管平台对接不涉及
extra额外参数dataobject
event_usage事件配额使用信息extraobject
limit时间量配额event_usageint
create_at创建时间datavarchar(20)
updated_at更新时间datavarchar(20)
is_permanent是否永久生效databoolean项目是否永久生效
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/projects/{projectId}
  • Path Params:
nametypedesc
projectIdint项目 id
  • Query: 无
  • Request Body:
{
  "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"
}
  • Request Body参数说明:
参数名参数说明上级参数是否必须数据类型备注
name项目名称/varchar(50)
description项目描述/varchar(200)
extra额外参数/object
event_usage事件配额使用信息extraobject
limit时间量配额event_usageint
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必传
  • Response Body:
{
  "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
}
  • Response Body参数说明:
参数名参数说明上级参数是否必须数据类型备注
code响应编码/int200代表成功响应。其他代表响应异常
message响应描述/varchar响应描述
data响应内容/object响应内容
name项目名称datavarchar(50)
description项目描述datavarchar(200)
org_id所属集团dataint
resource_key资源keydatavarchar(200)
creator_id创建人员dataint
is_classified是否保密dataint云管平台对接不涉及
extra额外参数dataobject
event_usage事件配额使用信息extraobject
limit时间量配额event_usageint
create_at创建时间datavarchar(20)
updated_at更新时间datavarchar(20)
is_permanent是否永久生效databoolean项目是否永久生效
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:
nametypedesc
projectIdint项目 id
  • Query: 无
  • Response Body:
{
  "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":"",    //必填
        }
    ]
}
  • Response Body:
{
  "code":  200,
  "message": "success",
  "data":  null
}

21.获取集团根部门

  • Method: GET
  • Path: /minibase/portal/openapi/v1/orgs/{org_id}/departments/root
  • Path Params:
nametypedesc
org_idint集团 id
  • Query:
nametypedesc
with_childrenbool获取子部门
recursivelybool递归获取子部门
with_usersbool获取部门中的用户
with_permsbool获取部门拥有的权限
with_rolesbool获取部门所在的角色
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
  • Query:
nametypedesc
with_childrenbool获取子部门
recursivelybool递归获取子部门
with_usersbool获取部门中的用户
with_permsbool获取部门拥有的权限
with_rolesbool获取部门所在的角色
qstring搜索
department_idsarray[int]指定部门 id 获取(逗号分隔)
origin_idsarray[string]指定部门 origin id 获取(逗号分隔)
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
department_idint部门 id
  • Query:
nametypedesc
with_childrenbool包括子部门中的用户
with_departmentsbool获取用户所在的部门
qstring搜索
pageint页码
page_sizeint每页个数
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
  • Query: 无
  • Request Body:
{
  "name": "字节跳动",
  "origin_id": "6df27b77-644f-4c0f-9777-f89c70d9ef1e",
  "perm_inherit": "to_super",
  "super_id": 1000
}
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
department_idint部门 id
origin_idstring部门 origin id
  • Query: 无
  • Request Body:

所有参数可选,传了就修改,不传不修改

{
  "name": "string",
  "perm_inherit": "to_children",
  "super_id": null
}
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
department_idint部门 id
origin_idstring部门 origin id
  • Query: 无
  • Request Body:
{
  "accounts": ["admin", "test"],
  "ids": [1, 2, 3]
}
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
department_idint部门 id
origin_idstring部门 origin id
  • Query: 无
  • Request Body:
{
  "accounts": ["admin", "test"],
  "ids": [1, 2, 3]
}
  • Response Body:
{
  "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:
nametypedesc
org_idint集团 id
department_idint部门 id
origin_idstring部门 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:
nametypedesc
user_idint用户 id
accountstring账号
  • Query:
namerequiredtypedesc
handover_user_idfalseint交接人 id(id 与账号只传一个)
handover_user_accountfalsestring交接人账号(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:
nametypedesc
user_idint用户 id
org_idint集团id
accountstring账号
  • Query:
namerequiredtypedesc
include_subjectsfalseboolean是否包含角色下的用户,不填写默认为true
with_permsfalseboolean是否包含角色下的权限,不填写默认为true
  • Request Body: 无
  • Response Body: 无

31. 获取项目列表

  • Method: GET

  • Path: /minibase/portal/openapi/v1/projects/

  • Path Params:

  • Query: 无

  • Response Body:

{
  "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:
nametypedesc
org_idint集团id
project_idint用户 id
  • Request Body: 无
  • Response Body:
{
  "code": 200,
  "message": "成功",
  "data": null
}

33. 查询用户所属的部门(>= 2.17)

  • Method: GET

  • Path: /minibase/portal/openapi/v1/orgs/{org_id}/users/{user_id}/departments(按照 user id 查询)

  • Path: /minibase/portal/openapi/v1/orgs/{org_id}/users/account_{account}/departments(按照用户账号查询)

  • Path Params:

nametypedesc
org_idint集团 id
user_idint用户 id
accountstring账号
  • Query: 无

  • Response Body:

{
    "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
        }
    ]
}