应用
整体说明
应用 API 可以使用组织的密钥或者应用级别密钥。
所有接口路径前缀都是 /openapi/company/{组织短名字}/app/{应用短名字}/
,需要将路径中的短名字换成实际的值,比如 /openapi/company/50b55/app/6a814/
应用整体接口
获取应用下的所有资源
获取应用下的所有资源,用于外部系统控制爱速搭的权限分配。
地址:GET /openapi/company/{组织短名字}/app/{应用短名字}/resources
返回示例:
{
"status": 0,
"msg": "",
"data": {
"page": {
"name": "页面",
"items": [
{
"id": "k1Jw8ME8Gq",
"name": "页面名"
}
]
},
"dataModel": {
"name": "数据模型",
"items": [
{
"id": "M9QEWvywp8",
"name": "数据模型名"
}
]
},
"dataSource": {
"name": "数据源",
"items": [
{
"id": "k1Jw8ME8Gq",
"name": "数据源名"
}
]
},
"component": {
"name": "自定义组件",
"items": [
{
"id": "LM6wPMEJdb",
"name": "自定义组件名"
}
]
},
"APICenter": {
"name": "API",
"items": [
{
"id": "pezEbloLAB",
"name": "api名"
}
]
},
"APICenterGroup": {
"name": "API 分组",
"items": [
{
"id": "grOwVRwNXG",
"name": "分组名"
}
]
},
"role": {
"name": "角色",
"items": [
{
"id": "pezEbloLAB",
"name": "应用管理员"
}
]
}
}
}
获取应用下的对象存储资源列表
地址:GET /openapi/company/{组织短名字}/app/{应用短名字}/objectstorage
返回示例:
{
"status": 0,
"msg": "",
"data": {
"items": [
{
"id": "xxxx",
"appId": "0QkEDJPoyn",
"companyId": "k1Jw8ME8Gq",
"bucket": "xxxx",
"endpoint": "xxxx",
"region": "",
"filePathPattern": "{{date:YYYY-MM}}/{{md5}}{{ext}}",
"bigFilePathPattern": "{{date:YYYY-MM}}/{{name}}{{ext}}",
"fname": "md5",
"bfname": "name",
"s3ForcePathStyle": false,
"folder": "files",
"host": "",
"isDefault": true,
"key": "xxx",
"name": "测试",
"status": 1,
"type": "bos",
"createdAt": "2022-09-15T07:44:14.000Z",
"createdBy": "xxx"
}
],
"count": 1
}
}
角色相关接口
获取应用下的角色列表
地址:GET /openapi/company/{组织短名字}/app/{应用短名字}/role
返回示例:
{
"status": 0,
"msg": "",
"data": {
"items": [
{
"name": "应用管理员", // 角色名称,角色名称在一个应用内不可重名
"id": "pezEbloLAB", // 角色唯一 id
"description": "系统自动创建,应用级别角色,只在应用「nw」中可见。", // 描述新
"scope": "app", // 这是应用级别
"isBultin": true, // 是否是默认创建的
"editable": true, // 是否可编辑
"deleteable": true // 是否可删除
}
]
}
}
创建应用内角色
地址:Post /openapi/company/{组织短名字}/app/{应用短名字}/role
提交内容:{"name": "角色名"}
更新角色
地址:Post /openapi/company/{组织短名字}/app/{应用短名字}/role/${id}
提交内容:{"name": "角色名"}
删除角色
地址:Delete /openapi/company/{组织短名字}/app/{应用短名字}/role/{角色 id}
需要将角色 id 放到 url 中
获取角色中的用户列表
地址:Get /openapi/company/{组织短名字}/app/{应用短名字}/role/{角色 id}/member
返回示例:
{
"status": 0,
"msg": "",
"data": {
// 角色下包含的用户类别
"users": [
{
"nickName": "xxx", // 用户昵称
"email": "xxx@yyy.com", // 用户邮箱
"roleId": "l2pEKAo1Ry",
"id": "XdkEyJZMRp", // 用户 id
"removable": true
}
],
// 角色下包含的部门列表
"departments": [
{
"roleId": "l2pEKAo1Ry",
"id": "4MDE4xELmX", // 部门 id
"name": "部门名"
}
],
// 角色下包含的角色列表
"roles": [
{
"roleId": "l2pEKAo1Ry",
"id": "3Y4wzNwQ7P",
"name": "子角色名"
}
]
}
}
往角色中添加用户
用于给指定角色添加用户,支持通过 邮箱
或者 uid
添加用户,批量添加用 ,
分隔。
地址:Post /openapi/company/{组织短名字}/app/{应用短名字}/role/{角色 id}/member/user
提交内容:{"email": "xxx@yyy.com", uid: "uid1,uid2"}
往角色中添加角色
地址:Post /openapi/company/{组织短名字}/app/{应用短名字}/role/{角色 id}/member/role
提交内容:{"role": " 角色 ID"}
获取子角色
地址:Get /openapi/company/{组织短名字}/app/{应用短名字}/role/{角色 id}/subRoles
提交内容:{"role": " 角色 ID"}
角色中移除成员
地址:Delete /openapi/company/{组织短名字}/app/{应用短名字}/role/{角色 id}/member/{成员 id}
角色中添加部门
地址:Post /openapi/company/{组织短名字}/app/{应用短名字}/role/{角色 id}/member/department
提交内容:{department : ["部门 id1", "部门 id2"]}
获取用户在某个应用中的角色
地址: Get /openapi/company/{组织短名字}/app/{应用短名字}/role/member/{用户ID}/roles
返回参数格式如下:
{
"status": 0,
"msg": "",
"data": {
"companyId": "k1Jw8ME8Gq",
"appId": "7dAE5Ko59n",
"userId": "k1Jw8ME8Gq",
"roles": [
{
"roleId": "lKVZOnEBdk", // 角色ID
"roleName": "MyApp-管理员" // 角色名称
},
{
"roleId": "dl6EgeojP1",
"roleName": "MyApp-用户"
}
]
}
}
权限相关接口
获取应用下有哪些 ACL 配置项
用于告知第三方爱速搭中有哪些可以配置的权限,比如页面可以配置「可见」、「可写」、「可删」这三项。
地址:Get /openapi/company/{组织短名字}/app/{应用短名字}/acl/options
返回示例:
{
"status": 0,
"msg": "",
"data": [
{
"name": "page",
"options": [
{
"name": "read",
"label": "可见"
},
{
"name": "write",
"label": "可写"
},
{
"name": "delete",
"label": "可删"
}
]
},
{
"name": "dataModel",
"options": [
{
"name": "read",
"label": "可见"
},
{
"name": "write",
"label": "可写"
},
{
"name": "delete",
"label": "可删"
}
]
},
{
"name": "dataSource",
"options": [
{
"name": "read",
"label": "可见"
},
{
"name": "write",
"label": "可写"
},
{
"name": "delete",
"label": "可删"
}
]
},
{
"name": "component",
"options": [
{
"name": "read",
"label": "可见"
},
{
"name": "write",
"label": "可写"
},
{
"name": "delete",
"label": "可删"
}
]
},
{
"name": "APICenter",
"options": [
{
"name": "read",
"label": "可见"
},
{
"name": "write",
"label": "可写"
},
{
"name": "delete",
"label": "可删"
},
{
"name": "call",
"label": "调用"
}
]
},
{
"name": "APICenterGroup",
"options": [
{
"name": "read",
"label": "可见"
},
{
"name": "write",
"label": "可写"
},
{
"name": "delete",
"label": "可删"
}
]
},
{
"name": "role",
"options": [
{
"name": "write",
"label": "可写"
},
{
"name": "delete",
"label": "可删"
}
]
}
]
}
获取某个角色应用运行时所拥有的资源权限
地址:Get /openapi/company/{组织短名字}/app/{应用短名字}/acl/runtime?env={环境类型}&roleName={角色名}
返回参数格式如下:
{
"status": 0,
"data": {
"readAcl": true,
"editAcl": true,
"dataManageAcl": true,
"viewLogAcl": true,
"resourceAcl": {
"pages": [
{
"id": "dl6EgeojP1",
"key": "home",
"title": "首页",
"acl": {"read": true}
}
]
}
}
}
设置某个角色所拥有的资源权限
地址:Post /openapi/company/{组织短名字}/app/{应用短名字}/acl/role?roleName={角色名}
提交内容示例,提交内容是数组,可以同时设置多个资源的权限:
[
{
"type": "APICenter", // 修改 api 中心的权限
"id": "LM6wPMEJdb", // 对应的 api id
"acl": {"read": true, "write": false, "call": true, "delete": false} // 权限详情,具体某个资源有哪些请参考前面接口返回的内容
},
{
"type": "page", // 修改某个页面的权限
"id": "dl6EgeojP1", // 对应的页面 id
"acl": "*" // 除了前面说到的方式,还可以使用 * 来方便设置这个资源的所有权限
}
]
获取某个应用可配置的权限点
地址: Get /openapi/company/{组织短名字}/app/{应用短名字}/acl
返回参数格式如下:
{
"status": 0,
"msg": "",
"data": {
"app": {
"key": "877f21d1cc5a",
"name": "XXX应用",
"subResources": [
{
"label": "应用访问",
"value": "read"
},
{
"label": "应用管理",
"value": "edit"
},
{
"label": "数据管理",
"value": "dataManage"
}
]
},
"page": {
"name": "页面",
"items": [
{
"id": "k1Jw8ME8Gq",
"name": "页面名",
"subResources": [
{
"label": "可打印",
"value": "print"
},
{
"label": "可导出",
"value": "export"
},
{
"label": "xxx接口可调用",
"value": "api.muEb9u9DdpbaGiFMhWqdjm.call"
}
],
"children": [
// 页面本身是树形结构的,所以用 tree 的格式返回
]
}
]
},
"dataModel": {
"name": "数据模型",
"items": [
{
"id": "M9QEWvywp8",
"name": "数据模型名"
}
]
},
"dataSource": {
"name": "数据源",
"items": [
{
"id": "k1Jw8ME8Gq",
"name": "数据源名"
}
]
},
"component": {
"name": "自定义组件",
"items": [
{
"id": "LM6wPMEJdb",
"name": "自定义组件名"
}
]
},
"APICenter": {
"name": "API",
"items": [
{
"id": "pezEbloLAB",
"name": "api名"
}
]
},
"APICenterGroup": {
"name": "API 分组",
"items": [
{
"id": "grOwVRwNXG",
"name": "分组名"
}
]
},
"role": {
"name": "角色",
"items": [
{
"id": "pezEbloLAB",
"name": "应用管理员"
}
]
}
}
}
获取某个应用运行态权限值
地址: Get /openapi/company/{组织短名字}/app/{应用短名字}/acl/runtime?env={环境类型}
返回参数格式如下:
{
"status": 0,
"data": {
"id": "3mrZq9ZjNR",
"readAcl": ["role:pezEbAOwLA", "role:yMJwpLmwpx"],
"editAcl": ["role:lKVZOXnoBd", "role:7dAE5Kro59"],
"dataManageAcl": ["role:lKVZOXnoBd", "role:7dAE5Kro59"],
"resourceAcl": {
"pages": [
{
"id": "8Yrw1RREK9",
"acl": {
"read": ["role:pezEbAOwLA"],
"owner": {
"write": true,
"delete": true
},
"3mrZq9ZjNR": {
"write": true,
"delete": true
},
"role:pezEbAOwLA": {
"read": true
}
},
"title": "首页",
"aclOptions": [{"label": "可读", "value": "read"}],
"children": [
{
"id": "3nywlG0ogX",
"acl": {
"read": ["role:pezEbAOwLA"],
"owner": {
"write": true,
"delete": true
},
"3mrZq9ZjNR": {
"write": true,
"delete": true
},
"role:pezEbAOwLA": {
"read": true
}
},
"title": "A",
"children": [],
"aclOptions": [
{"label": "可读", "value": "read"},
{
"label": "openapi测试",
"value": "api:atKvj7m4nSCc4GQHJUsW37:call"
}
]
}
]
}
]
}
}
}
设置某个应用运行态权限值
地址: post /openapi/company/{组织短名字}/app/{应用短名字}/runtime/acl?env={环境类型}
返回参数格式如下:
{
"id": "3mrZq9ZjNR",
"readAcl": ["role:LM6wPMEJdb"],
"editAcl": ["role:3mrZq9ZjNR", "role:Nq4omrw1g7"],
"dataManageAcl": ["role:3mrZq9ZjNR", "role:Nq4omrw1g7"],
"viewLogAcl": ["role:3mrZq9ZjNR", "role:Nq4omrw1g7"],
"resourceAcl": {
"pages": [
{
"id": "dl6EgeojP1",
"key": "home",
"title": "首页",
"children": [
{
"id": "lKVZOnEBdk",
"key": "test",
"title": "test",
"children": [],
"aclOptions": [
{"label": "可读", "value": "read"},
{
"label": "openapi测试",
"value": "api:atKvj7m4nSCc4GQHJUsW37:call"
}
],
"acl": {
"read": ["role:Nq4omrw1g7", "role:ygMwaloQAO"],
"owner": {"write": true, "delete": true},
"k1Jw8ME8Gq": {"write": true, "delete": true},
"role:Nq4omrw1g7": {
"read": true,
"api:atKvj7m4nSCc4GQHJUsW37:call": true
},
"role:ygMwaloQAO": {
"read": true,
"write": true,
"delete": true,
"api:atKvj7m4nSCc4GQHJUsW37:call": true
}
}
}
],
"aclOptions": [{"label": "可读", "value": "read"}],
"acl": {
"read": ["role:ygMwaloQAO", "role:Nq4omrw1g7"],
"owner": {"write": true, "delete": true},
"k1Jw8ME8Gq": {"write": true, "delete": true},
"role:Nq4omrw1g7": {"read": true},
"role:ygMwaloQAO": {"read": true, "write": true, "delete": true}
}
}
]
}
}
API 中心
调用 API 中心的接口
地址:
/openapi/company/{组织短名字}/app/{应用短名字}/page/{页面 id}/apicenterproxy/{api 的 key
需要有个页面 id,因为 api 在不同页面可能会有不同权限
git推送
地址: post /openapi/company/{组织短名字}/app/{应用短名字}/gitPush
提交内容
{
"gitEmail":"zhangsan@qq.com",
"gitUsername":"zhangsan",
"gitDesc":"git描述,可为空",
"repo":"git@github.com:z1769057083/dd.git",
"repoSrc":"存储目录,可为空",
"commit":"init",
"from":"dev",
"owner":"zhangsan@qq.com",
"branch":"main"
}
返回参数格式如下:
{
"status": 0,
"msg": "推送结果",
"data": {
"pushResult": "推送成功",
"stdout": "[main 1eb7333] init4\n 1 file changed, 1 insertion(+), 1 deletion(-)\n推送成功\n\nremote: Resolving deltas: 0% (0/2) \rremote: Resolving deltas: 50% (1/2) \rremote: Resolving deltas: 100% (2/2) \rremote: Resolving deltas: 100% (2/2), completed with 2 local objects. \nTo ssh://ssh.github.com:443/z1769057083/adada-..-4.git\n 53e2543..1eb7333 main -> main\n"
}
}